babylon.module.d.ts 5.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680
  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/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. let Epsilon: number;
  272. export { Epsilon };
  273. /**
  274. * Class used to hold a RBG color
  275. */
  276. export class Color3 {
  277. /**
  278. * Defines the red component (between 0 and 1, default is 0)
  279. */
  280. r: number;
  281. /**
  282. * Defines the green component (between 0 and 1, default is 0)
  283. */
  284. g: number;
  285. /**
  286. * Defines the blue component (between 0 and 1, default is 0)
  287. */
  288. b: number;
  289. /**
  290. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  291. * @param r defines the red component (between 0 and 1, default is 0)
  292. * @param g defines the green component (between 0 and 1, default is 0)
  293. * @param b defines the blue component (between 0 and 1, default is 0)
  294. */
  295. constructor(
  296. /**
  297. * Defines the red component (between 0 and 1, default is 0)
  298. */
  299. r?: number,
  300. /**
  301. * Defines the green component (between 0 and 1, default is 0)
  302. */
  303. g?: number,
  304. /**
  305. * Defines the blue component (between 0 and 1, default is 0)
  306. */
  307. b?: number);
  308. /**
  309. * Creates a string with the Color3 current values
  310. * @returns the string representation of the Color3 object
  311. */
  312. toString(): string;
  313. /**
  314. * Returns the string "Color3"
  315. * @returns "Color3"
  316. */
  317. getClassName(): string;
  318. /**
  319. * Compute the Color3 hash code
  320. * @returns an unique number that can be used to hash Color3 objects
  321. */
  322. getHashCode(): number;
  323. /**
  324. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  325. * @param array defines the array where to store the r,g,b components
  326. * @param index defines an optional index in the target array to define where to start storing values
  327. * @returns the current Color3 object
  328. */
  329. toArray(array: FloatArray, index?: number): Color3;
  330. /**
  331. * Returns a new Color4 object from the current Color3 and the given alpha
  332. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  333. * @returns a new Color4 object
  334. */
  335. toColor4(alpha?: number): Color4;
  336. /**
  337. * Returns a new array populated with 3 numeric elements : red, green and blue values
  338. * @returns the new array
  339. */
  340. asArray(): number[];
  341. /**
  342. * Returns the luminance value
  343. * @returns a float value
  344. */
  345. toLuminance(): number;
  346. /**
  347. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  348. * @param otherColor defines the second operand
  349. * @returns the new Color3 object
  350. */
  351. multiply(otherColor: DeepImmutable<Color3>): Color3;
  352. /**
  353. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  354. * @param otherColor defines the second operand
  355. * @param result defines the Color3 object where to store the result
  356. * @returns the current Color3
  357. */
  358. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  359. /**
  360. * Determines equality between Color3 objects
  361. * @param otherColor defines the second operand
  362. * @returns true if the rgb values are equal to the given ones
  363. */
  364. equals(otherColor: DeepImmutable<Color3>): boolean;
  365. /**
  366. * Determines equality between the current Color3 object and a set of r,b,g values
  367. * @param r defines the red component to check
  368. * @param g defines the green component to check
  369. * @param b defines the blue component to check
  370. * @returns true if the rgb values are equal to the given ones
  371. */
  372. equalsFloats(r: number, g: number, b: number): boolean;
  373. /**
  374. * Multiplies in place each rgb value by scale
  375. * @param scale defines the scaling factor
  376. * @returns the updated Color3
  377. */
  378. scale(scale: number): Color3;
  379. /**
  380. * Multiplies the rgb values by scale and stores the result into "result"
  381. * @param scale defines the scaling factor
  382. * @param result defines the Color3 object where to store the result
  383. * @returns the unmodified current Color3
  384. */
  385. scaleToRef(scale: number, result: Color3): Color3;
  386. /**
  387. * Scale the current Color3 values by a factor and add the result to a given Color3
  388. * @param scale defines the scale factor
  389. * @param result defines color to store the result into
  390. * @returns the unmodified current Color3
  391. */
  392. scaleAndAddToRef(scale: number, result: Color3): Color3;
  393. /**
  394. * Clamps the rgb values by the min and max values and stores the result into "result"
  395. * @param min defines minimum clamping value (default is 0)
  396. * @param max defines maximum clamping value (default is 1)
  397. * @param result defines color to store the result into
  398. * @returns the original Color3
  399. */
  400. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  401. /**
  402. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  403. * @param otherColor defines the second operand
  404. * @returns the new Color3
  405. */
  406. add(otherColor: DeepImmutable<Color3>): Color3;
  407. /**
  408. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  409. * @param otherColor defines the second operand
  410. * @param result defines Color3 object to store the result into
  411. * @returns the unmodified current Color3
  412. */
  413. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  414. /**
  415. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  416. * @param otherColor defines the second operand
  417. * @returns the new Color3
  418. */
  419. subtract(otherColor: DeepImmutable<Color3>): Color3;
  420. /**
  421. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  422. * @param otherColor defines the second operand
  423. * @param result defines Color3 object to store the result into
  424. * @returns the unmodified current Color3
  425. */
  426. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  427. /**
  428. * Copy the current object
  429. * @returns a new Color3 copied the current one
  430. */
  431. clone(): Color3;
  432. /**
  433. * Copies the rgb values from the source in the current Color3
  434. * @param source defines the source Color3 object
  435. * @returns the updated Color3 object
  436. */
  437. copyFrom(source: DeepImmutable<Color3>): Color3;
  438. /**
  439. * Updates the Color3 rgb values from the given floats
  440. * @param r defines the red component to read from
  441. * @param g defines the green component to read from
  442. * @param b defines the blue component to read from
  443. * @returns the current Color3 object
  444. */
  445. copyFromFloats(r: number, g: number, b: number): Color3;
  446. /**
  447. * Updates the Color3 rgb values from the given floats
  448. * @param r defines the red component to read from
  449. * @param g defines the green component to read from
  450. * @param b defines the blue component to read from
  451. * @returns the current Color3 object
  452. */
  453. set(r: number, g: number, b: number): Color3;
  454. /**
  455. * Compute the Color3 hexadecimal code as a string
  456. * @returns a string containing the hexadecimal representation of the Color3 object
  457. */
  458. toHexString(): string;
  459. /**
  460. * Computes a new Color3 converted from the current one to linear space
  461. * @returns a new Color3 object
  462. */
  463. toLinearSpace(): Color3;
  464. /**
  465. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  466. * @param convertedColor defines the Color3 object where to store the linear space version
  467. * @returns the unmodified Color3
  468. */
  469. toLinearSpaceToRef(convertedColor: Color3): Color3;
  470. /**
  471. * Computes a new Color3 converted from the current one to gamma space
  472. * @returns a new Color3 object
  473. */
  474. toGammaSpace(): Color3;
  475. /**
  476. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  477. * @param convertedColor defines the Color3 object where to store the gamma space version
  478. * @returns the unmodified Color3
  479. */
  480. toGammaSpaceToRef(convertedColor: Color3): Color3;
  481. private static _BlackReadOnly;
  482. /**
  483. * Creates a new Color3 from the string containing valid hexadecimal values
  484. * @param hex defines a string containing valid hexadecimal values
  485. * @returns a new Color3 object
  486. */
  487. static FromHexString(hex: string): Color3;
  488. /**
  489. * Creates a new Color3 from the starting index of the given array
  490. * @param array defines the source array
  491. * @param offset defines an offset in the source array
  492. * @returns a new Color3 object
  493. */
  494. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  495. /**
  496. * Creates a new Color3 from integer values (< 256)
  497. * @param r defines the red component to read from (value between 0 and 255)
  498. * @param g defines the green component to read from (value between 0 and 255)
  499. * @param b defines the blue component to read from (value between 0 and 255)
  500. * @returns a new Color3 object
  501. */
  502. static FromInts(r: number, g: number, b: number): Color3;
  503. /**
  504. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  505. * @param start defines the start Color3 value
  506. * @param end defines the end Color3 value
  507. * @param amount defines the gradient value between start and end
  508. * @returns a new Color3 object
  509. */
  510. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  511. /**
  512. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  513. * @param left defines the start value
  514. * @param right defines the end value
  515. * @param amount defines the gradient factor
  516. * @param result defines the Color3 object where to store the result
  517. */
  518. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  519. /**
  520. * Returns a Color3 value containing a red color
  521. * @returns a new Color3 object
  522. */
  523. static Red(): Color3;
  524. /**
  525. * Returns a Color3 value containing a green color
  526. * @returns a new Color3 object
  527. */
  528. static Green(): Color3;
  529. /**
  530. * Returns a Color3 value containing a blue color
  531. * @returns a new Color3 object
  532. */
  533. static Blue(): Color3;
  534. /**
  535. * Returns a Color3 value containing a black color
  536. * @returns a new Color3 object
  537. */
  538. static Black(): Color3;
  539. /**
  540. * Gets a Color3 value containing a black color that must not be updated
  541. */
  542. static readonly BlackReadOnly: DeepImmutable<Color3>;
  543. /**
  544. * Returns a Color3 value containing a white color
  545. * @returns a new Color3 object
  546. */
  547. static White(): Color3;
  548. /**
  549. * Returns a Color3 value containing a purple color
  550. * @returns a new Color3 object
  551. */
  552. static Purple(): Color3;
  553. /**
  554. * Returns a Color3 value containing a magenta color
  555. * @returns a new Color3 object
  556. */
  557. static Magenta(): Color3;
  558. /**
  559. * Returns a Color3 value containing a yellow color
  560. * @returns a new Color3 object
  561. */
  562. static Yellow(): Color3;
  563. /**
  564. * Returns a Color3 value containing a gray color
  565. * @returns a new Color3 object
  566. */
  567. static Gray(): Color3;
  568. /**
  569. * Returns a Color3 value containing a teal color
  570. * @returns a new Color3 object
  571. */
  572. static Teal(): Color3;
  573. /**
  574. * Returns a Color3 value containing a random color
  575. * @returns a new Color3 object
  576. */
  577. static Random(): Color3;
  578. }
  579. /**
  580. * Class used to hold a RBGA color
  581. */
  582. export class Color4 {
  583. /**
  584. * Defines the red component (between 0 and 1, default is 0)
  585. */
  586. r: number;
  587. /**
  588. * Defines the green component (between 0 and 1, default is 0)
  589. */
  590. g: number;
  591. /**
  592. * Defines the blue component (between 0 and 1, default is 0)
  593. */
  594. b: number;
  595. /**
  596. * Defines the alpha component (between 0 and 1, default is 1)
  597. */
  598. a: number;
  599. /**
  600. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  601. * @param r defines the red component (between 0 and 1, default is 0)
  602. * @param g defines the green component (between 0 and 1, default is 0)
  603. * @param b defines the blue component (between 0 and 1, default is 0)
  604. * @param a defines the alpha component (between 0 and 1, default is 1)
  605. */
  606. constructor(
  607. /**
  608. * Defines the red component (between 0 and 1, default is 0)
  609. */
  610. r?: number,
  611. /**
  612. * Defines the green component (between 0 and 1, default is 0)
  613. */
  614. g?: number,
  615. /**
  616. * Defines the blue component (between 0 and 1, default is 0)
  617. */
  618. b?: number,
  619. /**
  620. * Defines the alpha component (between 0 and 1, default is 1)
  621. */
  622. a?: number);
  623. /**
  624. * Adds in place the given Color4 values to the current Color4 object
  625. * @param right defines the second operand
  626. * @returns the current updated Color4 object
  627. */
  628. addInPlace(right: DeepImmutable<Color4>): Color4;
  629. /**
  630. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  631. * @returns the new array
  632. */
  633. asArray(): number[];
  634. /**
  635. * Stores from the starting index in the given array the Color4 successive values
  636. * @param array defines the array where to store the r,g,b components
  637. * @param index defines an optional index in the target array to define where to start storing values
  638. * @returns the current Color4 object
  639. */
  640. toArray(array: number[], index?: number): Color4;
  641. /**
  642. * Determines equality between Color4 objects
  643. * @param otherColor defines the second operand
  644. * @returns true if the rgba values are equal to the given ones
  645. */
  646. equals(otherColor: DeepImmutable<Color4>): boolean;
  647. /**
  648. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  649. * @param right defines the second operand
  650. * @returns a new Color4 object
  651. */
  652. add(right: DeepImmutable<Color4>): Color4;
  653. /**
  654. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  655. * @param right defines the second operand
  656. * @returns a new Color4 object
  657. */
  658. subtract(right: DeepImmutable<Color4>): Color4;
  659. /**
  660. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  661. * @param right defines the second operand
  662. * @param result defines the Color4 object where to store the result
  663. * @returns the current Color4 object
  664. */
  665. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  666. /**
  667. * Creates a new Color4 with the current Color4 values multiplied by scale
  668. * @param scale defines the scaling factor to apply
  669. * @returns a new Color4 object
  670. */
  671. scale(scale: number): Color4;
  672. /**
  673. * Multiplies the current Color4 values by scale and stores the result in "result"
  674. * @param scale defines the scaling factor to apply
  675. * @param result defines the Color4 object where to store the result
  676. * @returns the current unmodified Color4
  677. */
  678. scaleToRef(scale: number, result: Color4): Color4;
  679. /**
  680. * Scale the current Color4 values by a factor and add the result to a given Color4
  681. * @param scale defines the scale factor
  682. * @param result defines the Color4 object where to store the result
  683. * @returns the unmodified current Color4
  684. */
  685. scaleAndAddToRef(scale: number, result: Color4): Color4;
  686. /**
  687. * Clamps the rgb values by the min and max values and stores the result into "result"
  688. * @param min defines minimum clamping value (default is 0)
  689. * @param max defines maximum clamping value (default is 1)
  690. * @param result defines color to store the result into.
  691. * @returns the cuurent Color4
  692. */
  693. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  694. /**
  695. * Multipy an Color4 value by another and return a new Color4 object
  696. * @param color defines the Color4 value to multiply by
  697. * @returns a new Color4 object
  698. */
  699. multiply(color: Color4): Color4;
  700. /**
  701. * Multipy a Color4 value by another and push the result in a reference value
  702. * @param color defines the Color4 value to multiply by
  703. * @param result defines the Color4 to fill the result in
  704. * @returns the result Color4
  705. */
  706. multiplyToRef(color: Color4, result: Color4): Color4;
  707. /**
  708. * Creates a string with the Color4 current values
  709. * @returns the string representation of the Color4 object
  710. */
  711. toString(): string;
  712. /**
  713. * Returns the string "Color4"
  714. * @returns "Color4"
  715. */
  716. getClassName(): string;
  717. /**
  718. * Compute the Color4 hash code
  719. * @returns an unique number that can be used to hash Color4 objects
  720. */
  721. getHashCode(): number;
  722. /**
  723. * Creates a new Color4 copied from the current one
  724. * @returns a new Color4 object
  725. */
  726. clone(): Color4;
  727. /**
  728. * Copies the given Color4 values into the current one
  729. * @param source defines the source Color4 object
  730. * @returns the current updated Color4 object
  731. */
  732. copyFrom(source: Color4): Color4;
  733. /**
  734. * Copies the given float values into the current one
  735. * @param r defines the red component to read from
  736. * @param g defines the green component to read from
  737. * @param b defines the blue component to read from
  738. * @param a defines the alpha component to read from
  739. * @returns the current updated Color4 object
  740. */
  741. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  742. /**
  743. * Copies the given float values into the current one
  744. * @param r defines the red component to read from
  745. * @param g defines the green component to read from
  746. * @param b defines the blue component to read from
  747. * @param a defines the alpha component to read from
  748. * @returns the current updated Color4 object
  749. */
  750. set(r: number, g: number, b: number, a: number): Color4;
  751. /**
  752. * Compute the Color4 hexadecimal code as a string
  753. * @returns a string containing the hexadecimal representation of the Color4 object
  754. */
  755. toHexString(): string;
  756. /**
  757. * Computes a new Color4 converted from the current one to linear space
  758. * @returns a new Color4 object
  759. */
  760. toLinearSpace(): Color4;
  761. /**
  762. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  763. * @param convertedColor defines the Color4 object where to store the linear space version
  764. * @returns the unmodified Color4
  765. */
  766. toLinearSpaceToRef(convertedColor: Color4): Color4;
  767. /**
  768. * Computes a new Color4 converted from the current one to gamma space
  769. * @returns a new Color4 object
  770. */
  771. toGammaSpace(): Color4;
  772. /**
  773. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  774. * @param convertedColor defines the Color4 object where to store the gamma space version
  775. * @returns the unmodified Color4
  776. */
  777. toGammaSpaceToRef(convertedColor: Color4): Color4;
  778. /**
  779. * Creates a new Color4 from the string containing valid hexadecimal values
  780. * @param hex defines a string containing valid hexadecimal values
  781. * @returns a new Color4 object
  782. */
  783. static FromHexString(hex: string): Color4;
  784. /**
  785. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  786. * @param left defines the start value
  787. * @param right defines the end value
  788. * @param amount defines the gradient factor
  789. * @returns a new Color4 object
  790. */
  791. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  792. /**
  793. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  794. * @param left defines the start value
  795. * @param right defines the end value
  796. * @param amount defines the gradient factor
  797. * @param result defines the Color4 object where to store data
  798. */
  799. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  800. /**
  801. * Creates a new Color4 from a Color3 and an alpha value
  802. * @param color3 defines the source Color3 to read from
  803. * @param alpha defines the alpha component (1.0 by default)
  804. * @returns a new Color4 object
  805. */
  806. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  807. /**
  808. * Creates a new Color4 from the starting index element of the given array
  809. * @param array defines the source array to read from
  810. * @param offset defines the offset in the source array
  811. * @returns a new Color4 object
  812. */
  813. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  814. /**
  815. * Creates a new Color3 from integer values (< 256)
  816. * @param r defines the red component to read from (value between 0 and 255)
  817. * @param g defines the green component to read from (value between 0 and 255)
  818. * @param b defines the blue component to read from (value between 0 and 255)
  819. * @param a defines the alpha component to read from (value between 0 and 255)
  820. * @returns a new Color3 object
  821. */
  822. static FromInts(r: number, g: number, b: number, a: number): Color4;
  823. /**
  824. * Check the content of a given array and convert it to an array containing RGBA data
  825. * If the original array was already containing count * 4 values then it is returned directly
  826. * @param colors defines the array to check
  827. * @param count defines the number of RGBA data to expect
  828. * @returns an array containing count * 4 values (RGBA)
  829. */
  830. static CheckColors4(colors: number[], count: number): number[];
  831. }
  832. /**
  833. * Class representing a vector containing 2 coordinates
  834. */
  835. export class Vector2 {
  836. /** defines the first coordinate */
  837. x: number;
  838. /** defines the second coordinate */
  839. y: number;
  840. /**
  841. * Creates a new Vector2 from the given x and y coordinates
  842. * @param x defines the first coordinate
  843. * @param y defines the second coordinate
  844. */
  845. constructor(
  846. /** defines the first coordinate */
  847. x?: number,
  848. /** defines the second coordinate */
  849. y?: number);
  850. /**
  851. * Gets a string with the Vector2 coordinates
  852. * @returns a string with the Vector2 coordinates
  853. */
  854. toString(): string;
  855. /**
  856. * Gets class name
  857. * @returns the string "Vector2"
  858. */
  859. getClassName(): string;
  860. /**
  861. * Gets current vector hash code
  862. * @returns the Vector2 hash code as a number
  863. */
  864. getHashCode(): number;
  865. /**
  866. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  867. * @param array defines the source array
  868. * @param index defines the offset in source array
  869. * @returns the current Vector2
  870. */
  871. toArray(array: FloatArray, index?: number): Vector2;
  872. /**
  873. * Copy the current vector to an array
  874. * @returns a new array with 2 elements: the Vector2 coordinates.
  875. */
  876. asArray(): number[];
  877. /**
  878. * Sets the Vector2 coordinates with the given Vector2 coordinates
  879. * @param source defines the source Vector2
  880. * @returns the current updated Vector2
  881. */
  882. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  883. /**
  884. * Sets the Vector2 coordinates with the given floats
  885. * @param x defines the first coordinate
  886. * @param y defines the second coordinate
  887. * @returns the current updated Vector2
  888. */
  889. copyFromFloats(x: number, y: number): Vector2;
  890. /**
  891. * Sets the Vector2 coordinates with the given floats
  892. * @param x defines the first coordinate
  893. * @param y defines the second coordinate
  894. * @returns the current updated Vector2
  895. */
  896. set(x: number, y: number): Vector2;
  897. /**
  898. * Add another vector with the current one
  899. * @param otherVector defines the other vector
  900. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  901. */
  902. add(otherVector: DeepImmutable<Vector2>): Vector2;
  903. /**
  904. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  905. * @param otherVector defines the other vector
  906. * @param result defines the target vector
  907. * @returns the unmodified current Vector2
  908. */
  909. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  910. /**
  911. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  912. * @param otherVector defines the other vector
  913. * @returns the current updated Vector2
  914. */
  915. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  916. /**
  917. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  918. * @param otherVector defines the other vector
  919. * @returns a new Vector2
  920. */
  921. addVector3(otherVector: Vector3): Vector2;
  922. /**
  923. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  924. * @param otherVector defines the other vector
  925. * @returns a new Vector2
  926. */
  927. subtract(otherVector: Vector2): Vector2;
  928. /**
  929. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  930. * @param otherVector defines the other vector
  931. * @param result defines the target vector
  932. * @returns the unmodified current Vector2
  933. */
  934. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  935. /**
  936. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  937. * @param otherVector defines the other vector
  938. * @returns the current updated Vector2
  939. */
  940. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  941. /**
  942. * Multiplies in place the current Vector2 coordinates by the given ones
  943. * @param otherVector defines the other vector
  944. * @returns the current updated Vector2
  945. */
  946. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  947. /**
  948. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  949. * @param otherVector defines the other vector
  950. * @returns a new Vector2
  951. */
  952. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  953. /**
  954. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  955. * @param otherVector defines the other vector
  956. * @param result defines the target vector
  957. * @returns the unmodified current Vector2
  958. */
  959. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  960. /**
  961. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  962. * @param x defines the first coordinate
  963. * @param y defines the second coordinate
  964. * @returns a new Vector2
  965. */
  966. multiplyByFloats(x: number, y: number): Vector2;
  967. /**
  968. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  969. * @param otherVector defines the other vector
  970. * @returns a new Vector2
  971. */
  972. divide(otherVector: Vector2): Vector2;
  973. /**
  974. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  975. * @param otherVector defines the other vector
  976. * @param result defines the target vector
  977. * @returns the unmodified current Vector2
  978. */
  979. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  980. /**
  981. * Divides the current Vector2 coordinates by the given ones
  982. * @param otherVector defines the other vector
  983. * @returns the current updated Vector2
  984. */
  985. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  986. /**
  987. * Gets a new Vector2 with current Vector2 negated coordinates
  988. * @returns a new Vector2
  989. */
  990. negate(): Vector2;
  991. /**
  992. * Multiply the Vector2 coordinates by scale
  993. * @param scale defines the scaling factor
  994. * @returns the current updated Vector2
  995. */
  996. scaleInPlace(scale: number): Vector2;
  997. /**
  998. * Returns a new Vector2 scaled by "scale" from the current Vector2
  999. * @param scale defines the scaling factor
  1000. * @returns a new Vector2
  1001. */
  1002. scale(scale: number): Vector2;
  1003. /**
  1004. * Scale the current Vector2 values by a factor to a given Vector2
  1005. * @param scale defines the scale factor
  1006. * @param result defines the Vector2 object where to store the result
  1007. * @returns the unmodified current Vector2
  1008. */
  1009. scaleToRef(scale: number, result: Vector2): Vector2;
  1010. /**
  1011. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1012. * @param scale defines the scale factor
  1013. * @param result defines the Vector2 object where to store the result
  1014. * @returns the unmodified current Vector2
  1015. */
  1016. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1017. /**
  1018. * Gets a boolean if two vectors are equals
  1019. * @param otherVector defines the other vector
  1020. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1021. */
  1022. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1023. /**
  1024. * Gets a boolean if two vectors are equals (using an epsilon value)
  1025. * @param otherVector defines the other vector
  1026. * @param epsilon defines the minimal distance to consider equality
  1027. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1028. */
  1029. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1030. /**
  1031. * Gets a new Vector2 from current Vector2 floored values
  1032. * @returns a new Vector2
  1033. */
  1034. floor(): Vector2;
  1035. /**
  1036. * Gets a new Vector2 from current Vector2 floored values
  1037. * @returns a new Vector2
  1038. */
  1039. fract(): Vector2;
  1040. /**
  1041. * Gets the length of the vector
  1042. * @returns the vector length (float)
  1043. */
  1044. length(): number;
  1045. /**
  1046. * Gets the vector squared length
  1047. * @returns the vector squared length (float)
  1048. */
  1049. lengthSquared(): number;
  1050. /**
  1051. * Normalize the vector
  1052. * @returns the current updated Vector2
  1053. */
  1054. normalize(): Vector2;
  1055. /**
  1056. * Gets a new Vector2 copied from the Vector2
  1057. * @returns a new Vector2
  1058. */
  1059. clone(): Vector2;
  1060. /**
  1061. * Gets a new Vector2(0, 0)
  1062. * @returns a new Vector2
  1063. */
  1064. static Zero(): Vector2;
  1065. /**
  1066. * Gets a new Vector2(1, 1)
  1067. * @returns a new Vector2
  1068. */
  1069. static One(): Vector2;
  1070. /**
  1071. * Gets a new Vector2 set from the given index element of the given array
  1072. * @param array defines the data source
  1073. * @param offset defines the offset in the data source
  1074. * @returns a new Vector2
  1075. */
  1076. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1077. /**
  1078. * Sets "result" from the given index element of the given array
  1079. * @param array defines the data source
  1080. * @param offset defines the offset in the data source
  1081. * @param result defines the target vector
  1082. */
  1083. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1084. /**
  1085. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1086. * @param value1 defines 1st point of control
  1087. * @param value2 defines 2nd point of control
  1088. * @param value3 defines 3rd point of control
  1089. * @param value4 defines 4th point of control
  1090. * @param amount defines the interpolation factor
  1091. * @returns a new Vector2
  1092. */
  1093. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1094. /**
  1095. * 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".
  1096. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1097. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1098. * @param value defines the value to clamp
  1099. * @param min defines the lower limit
  1100. * @param max defines the upper limit
  1101. * @returns a new Vector2
  1102. */
  1103. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1104. /**
  1105. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1106. * @param value1 defines the 1st control point
  1107. * @param tangent1 defines the outgoing tangent
  1108. * @param value2 defines the 2nd control point
  1109. * @param tangent2 defines the incoming tangent
  1110. * @param amount defines the interpolation factor
  1111. * @returns a new Vector2
  1112. */
  1113. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1114. /**
  1115. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1116. * @param start defines the start vector
  1117. * @param end defines the end vector
  1118. * @param amount defines the interpolation factor
  1119. * @returns a new Vector2
  1120. */
  1121. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1122. /**
  1123. * Gets the dot product of the vector "left" and the vector "right"
  1124. * @param left defines first vector
  1125. * @param right defines second vector
  1126. * @returns the dot product (float)
  1127. */
  1128. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1129. /**
  1130. * Returns a new Vector2 equal to the normalized given vector
  1131. * @param vector defines the vector to normalize
  1132. * @returns a new Vector2
  1133. */
  1134. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1135. /**
  1136. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1137. * @param left defines 1st vector
  1138. * @param right defines 2nd vector
  1139. * @returns a new Vector2
  1140. */
  1141. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1142. /**
  1143. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1144. * @param left defines 1st vector
  1145. * @param right defines 2nd vector
  1146. * @returns a new Vector2
  1147. */
  1148. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1149. /**
  1150. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1151. * @param vector defines the vector to transform
  1152. * @param transformation defines the matrix to apply
  1153. * @returns a new Vector2
  1154. */
  1155. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1156. /**
  1157. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1158. * @param vector defines the vector to transform
  1159. * @param transformation defines the matrix to apply
  1160. * @param result defines the target vector
  1161. */
  1162. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1163. /**
  1164. * Determines if a given vector is included in a triangle
  1165. * @param p defines the vector to test
  1166. * @param p0 defines 1st triangle point
  1167. * @param p1 defines 2nd triangle point
  1168. * @param p2 defines 3rd triangle point
  1169. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1170. */
  1171. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1172. /**
  1173. * Gets the distance between the vectors "value1" and "value2"
  1174. * @param value1 defines first vector
  1175. * @param value2 defines second vector
  1176. * @returns the distance between vectors
  1177. */
  1178. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1179. /**
  1180. * Returns the squared distance between the vectors "value1" and "value2"
  1181. * @param value1 defines first vector
  1182. * @param value2 defines second vector
  1183. * @returns the squared distance between vectors
  1184. */
  1185. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1186. /**
  1187. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1188. * @param value1 defines first vector
  1189. * @param value2 defines second vector
  1190. * @returns a new Vector2
  1191. */
  1192. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1193. /**
  1194. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1195. * @param p defines the middle point
  1196. * @param segA defines one point of the segment
  1197. * @param segB defines the other point of the segment
  1198. * @returns the shortest distance
  1199. */
  1200. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1201. }
  1202. /**
  1203. * Classed used to store (x,y,z) vector representation
  1204. * A Vector3 is the main object used in 3D geometry
  1205. * It can represent etiher the coordinates of a point the space, either a direction
  1206. * Reminder: js uses a left handed forward facing system
  1207. */
  1208. export class Vector3 {
  1209. /**
  1210. * Defines the first coordinates (on X axis)
  1211. */
  1212. x: number;
  1213. /**
  1214. * Defines the second coordinates (on Y axis)
  1215. */
  1216. y: number;
  1217. /**
  1218. * Defines the third coordinates (on Z axis)
  1219. */
  1220. z: number;
  1221. private static _UpReadOnly;
  1222. /**
  1223. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1224. * @param x defines the first coordinates (on X axis)
  1225. * @param y defines the second coordinates (on Y axis)
  1226. * @param z defines the third coordinates (on Z axis)
  1227. */
  1228. constructor(
  1229. /**
  1230. * Defines the first coordinates (on X axis)
  1231. */
  1232. x?: number,
  1233. /**
  1234. * Defines the second coordinates (on Y axis)
  1235. */
  1236. y?: number,
  1237. /**
  1238. * Defines the third coordinates (on Z axis)
  1239. */
  1240. z?: number);
  1241. /**
  1242. * Creates a string representation of the Vector3
  1243. * @returns a string with the Vector3 coordinates.
  1244. */
  1245. toString(): string;
  1246. /**
  1247. * Gets the class name
  1248. * @returns the string "Vector3"
  1249. */
  1250. getClassName(): string;
  1251. /**
  1252. * Creates the Vector3 hash code
  1253. * @returns a number which tends to be unique between Vector3 instances
  1254. */
  1255. getHashCode(): number;
  1256. /**
  1257. * Creates an array containing three elements : the coordinates of the Vector3
  1258. * @returns a new array of numbers
  1259. */
  1260. asArray(): number[];
  1261. /**
  1262. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1263. * @param array defines the destination array
  1264. * @param index defines the offset in the destination array
  1265. * @returns the current Vector3
  1266. */
  1267. toArray(array: FloatArray, index?: number): Vector3;
  1268. /**
  1269. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1270. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1271. */
  1272. toQuaternion(): Quaternion;
  1273. /**
  1274. * Adds the given vector to the current Vector3
  1275. * @param otherVector defines the second operand
  1276. * @returns the current updated Vector3
  1277. */
  1278. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1279. /**
  1280. * Adds the given coordinates to the current Vector3
  1281. * @param x defines the x coordinate of the operand
  1282. * @param y defines the y coordinate of the operand
  1283. * @param z defines the z coordinate of the operand
  1284. * @returns the current updated Vector3
  1285. */
  1286. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1287. /**
  1288. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1289. * @param otherVector defines the second operand
  1290. * @returns the resulting Vector3
  1291. */
  1292. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1293. /**
  1294. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1295. * @param otherVector defines the second operand
  1296. * @param result defines the Vector3 object where to store the result
  1297. * @returns the current Vector3
  1298. */
  1299. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1300. /**
  1301. * Subtract the given vector from the current Vector3
  1302. * @param otherVector defines the second operand
  1303. * @returns the current updated Vector3
  1304. */
  1305. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1306. /**
  1307. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1308. * @param otherVector defines the second operand
  1309. * @returns the resulting Vector3
  1310. */
  1311. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1312. /**
  1313. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1314. * @param otherVector defines the second operand
  1315. * @param result defines the Vector3 object where to store the result
  1316. * @returns the current Vector3
  1317. */
  1318. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1319. /**
  1320. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1321. * @param x defines the x coordinate of the operand
  1322. * @param y defines the y coordinate of the operand
  1323. * @param z defines the z coordinate of the operand
  1324. * @returns the resulting Vector3
  1325. */
  1326. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1327. /**
  1328. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1329. * @param x defines the x coordinate of the operand
  1330. * @param y defines the y coordinate of the operand
  1331. * @param z defines the z coordinate of the operand
  1332. * @param result defines the Vector3 object where to store the result
  1333. * @returns the current Vector3
  1334. */
  1335. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1336. /**
  1337. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1338. * @returns a new Vector3
  1339. */
  1340. negate(): Vector3;
  1341. /**
  1342. * Multiplies the Vector3 coordinates by the float "scale"
  1343. * @param scale defines the multiplier factor
  1344. * @returns the current updated Vector3
  1345. */
  1346. scaleInPlace(scale: number): Vector3;
  1347. /**
  1348. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1349. * @param scale defines the multiplier factor
  1350. * @returns a new Vector3
  1351. */
  1352. scale(scale: number): Vector3;
  1353. /**
  1354. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1355. * @param scale defines the multiplier factor
  1356. * @param result defines the Vector3 object where to store the result
  1357. * @returns the current Vector3
  1358. */
  1359. scaleToRef(scale: number, result: Vector3): Vector3;
  1360. /**
  1361. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1362. * @param scale defines the scale factor
  1363. * @param result defines the Vector3 object where to store the result
  1364. * @returns the unmodified current Vector3
  1365. */
  1366. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1367. /**
  1368. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1369. * @param otherVector defines the second operand
  1370. * @returns true if both vectors are equals
  1371. */
  1372. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1373. /**
  1374. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1375. * @param otherVector defines the second operand
  1376. * @param epsilon defines the minimal distance to define values as equals
  1377. * @returns true if both vectors are distant less than epsilon
  1378. */
  1379. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1380. /**
  1381. * Returns true if the current Vector3 coordinates equals the given floats
  1382. * @param x defines the x coordinate of the operand
  1383. * @param y defines the y coordinate of the operand
  1384. * @param z defines the z coordinate of the operand
  1385. * @returns true if both vectors are equals
  1386. */
  1387. equalsToFloats(x: number, y: number, z: number): boolean;
  1388. /**
  1389. * Multiplies the current Vector3 coordinates by the given ones
  1390. * @param otherVector defines the second operand
  1391. * @returns the current updated Vector3
  1392. */
  1393. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1394. /**
  1395. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1396. * @param otherVector defines the second operand
  1397. * @returns the new Vector3
  1398. */
  1399. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1400. /**
  1401. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1402. * @param otherVector defines the second operand
  1403. * @param result defines the Vector3 object where to store the result
  1404. * @returns the current Vector3
  1405. */
  1406. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1407. /**
  1408. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1409. * @param x defines the x coordinate of the operand
  1410. * @param y defines the y coordinate of the operand
  1411. * @param z defines the z coordinate of the operand
  1412. * @returns the new Vector3
  1413. */
  1414. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1415. /**
  1416. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1417. * @param otherVector defines the second operand
  1418. * @returns the new Vector3
  1419. */
  1420. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1421. /**
  1422. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1423. * @param otherVector defines the second operand
  1424. * @param result defines the Vector3 object where to store the result
  1425. * @returns the current Vector3
  1426. */
  1427. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1428. /**
  1429. * Divides the current Vector3 coordinates by the given ones.
  1430. * @param otherVector defines the second operand
  1431. * @returns the current updated Vector3
  1432. */
  1433. divideInPlace(otherVector: Vector3): Vector3;
  1434. /**
  1435. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1436. * @param other defines the second operand
  1437. * @returns the current updated Vector3
  1438. */
  1439. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1440. /**
  1441. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1442. * @param other defines the second operand
  1443. * @returns the current updated Vector3
  1444. */
  1445. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1446. /**
  1447. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1448. * @param x defines the x coordinate of the operand
  1449. * @param y defines the y coordinate of the operand
  1450. * @param z defines the z coordinate of the operand
  1451. * @returns the current updated Vector3
  1452. */
  1453. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1454. /**
  1455. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1456. * @param x defines the x coordinate of the operand
  1457. * @param y defines the y coordinate of the operand
  1458. * @param z defines the z coordinate of the operand
  1459. * @returns the current updated Vector3
  1460. */
  1461. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1462. /**
  1463. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1464. * Check if is non uniform within a certain amount of decimal places to account for this
  1465. * @param epsilon the amount the values can differ
  1466. * @returns if the the vector is non uniform to a certain number of decimal places
  1467. */
  1468. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1469. /**
  1470. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1471. */
  1472. readonly isNonUniform: boolean;
  1473. /**
  1474. * Gets a new Vector3 from current Vector3 floored values
  1475. * @returns a new Vector3
  1476. */
  1477. floor(): Vector3;
  1478. /**
  1479. * Gets a new Vector3 from current Vector3 floored values
  1480. * @returns a new Vector3
  1481. */
  1482. fract(): Vector3;
  1483. /**
  1484. * Gets the length of the Vector3
  1485. * @returns the length of the Vecto3
  1486. */
  1487. length(): number;
  1488. /**
  1489. * Gets the squared length of the Vector3
  1490. * @returns squared length of the Vector3
  1491. */
  1492. lengthSquared(): number;
  1493. /**
  1494. * Normalize the current Vector3.
  1495. * Please note that this is an in place operation.
  1496. * @returns the current updated Vector3
  1497. */
  1498. normalize(): Vector3;
  1499. /**
  1500. * Reorders the x y z properties of the vector in place
  1501. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1502. * @returns the current updated vector
  1503. */
  1504. reorderInPlace(order: string): this;
  1505. /**
  1506. * Rotates the vector around 0,0,0 by a quaternion
  1507. * @param quaternion the rotation quaternion
  1508. * @param result vector to store the result
  1509. * @returns the resulting vector
  1510. */
  1511. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1512. /**
  1513. * Rotates a vector around a given point
  1514. * @param quaternion the rotation quaternion
  1515. * @param point the point to rotate around
  1516. * @param result vector to store the result
  1517. * @returns the resulting vector
  1518. */
  1519. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1520. /**
  1521. * Normalize the current Vector3 with the given input length.
  1522. * Please note that this is an in place operation.
  1523. * @param len the length of the vector
  1524. * @returns the current updated Vector3
  1525. */
  1526. normalizeFromLength(len: number): Vector3;
  1527. /**
  1528. * Normalize the current Vector3 to a new vector
  1529. * @returns the new Vector3
  1530. */
  1531. normalizeToNew(): Vector3;
  1532. /**
  1533. * Normalize the current Vector3 to the reference
  1534. * @param reference define the Vector3 to update
  1535. * @returns the updated Vector3
  1536. */
  1537. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1538. /**
  1539. * Creates a new Vector3 copied from the current Vector3
  1540. * @returns the new Vector3
  1541. */
  1542. clone(): Vector3;
  1543. /**
  1544. * Copies the given vector coordinates to the current Vector3 ones
  1545. * @param source defines the source Vector3
  1546. * @returns the current updated Vector3
  1547. */
  1548. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1549. /**
  1550. * Copies the given floats to the current Vector3 coordinates
  1551. * @param x defines the x coordinate of the operand
  1552. * @param y defines the y coordinate of the operand
  1553. * @param z defines the z coordinate of the operand
  1554. * @returns the current updated Vector3
  1555. */
  1556. copyFromFloats(x: number, y: number, z: number): Vector3;
  1557. /**
  1558. * Copies the given floats to the current Vector3 coordinates
  1559. * @param x defines the x coordinate of the operand
  1560. * @param y defines the y coordinate of the operand
  1561. * @param z defines the z coordinate of the operand
  1562. * @returns the current updated Vector3
  1563. */
  1564. set(x: number, y: number, z: number): Vector3;
  1565. /**
  1566. * Copies the given float to the current Vector3 coordinates
  1567. * @param v defines the x, y and z coordinates of the operand
  1568. * @returns the current updated Vector3
  1569. */
  1570. setAll(v: number): Vector3;
  1571. /**
  1572. * Get the clip factor between two vectors
  1573. * @param vector0 defines the first operand
  1574. * @param vector1 defines the second operand
  1575. * @param axis defines the axis to use
  1576. * @param size defines the size along the axis
  1577. * @returns the clip factor
  1578. */
  1579. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1580. /**
  1581. * Get angle between two vectors
  1582. * @param vector0 angle between vector0 and vector1
  1583. * @param vector1 angle between vector0 and vector1
  1584. * @param normal direction of the normal
  1585. * @return the angle between vector0 and vector1
  1586. */
  1587. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1588. /**
  1589. * Returns a new Vector3 set from the index "offset" of the given array
  1590. * @param array defines the source array
  1591. * @param offset defines the offset in the source array
  1592. * @returns the new Vector3
  1593. */
  1594. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1595. /**
  1596. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1597. * This function is deprecated. Use FromArray instead
  1598. * @param array defines the source array
  1599. * @param offset defines the offset in the source array
  1600. * @returns the new Vector3
  1601. */
  1602. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1603. /**
  1604. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1605. * @param array defines the source array
  1606. * @param offset defines the offset in the source array
  1607. * @param result defines the Vector3 where to store the result
  1608. */
  1609. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1610. /**
  1611. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1612. * This function is deprecated. Use FromArrayToRef instead.
  1613. * @param array defines the source array
  1614. * @param offset defines the offset in the source array
  1615. * @param result defines the Vector3 where to store the result
  1616. */
  1617. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1618. /**
  1619. * Sets the given vector "result" with the given floats.
  1620. * @param x defines the x coordinate of the source
  1621. * @param y defines the y coordinate of the source
  1622. * @param z defines the z coordinate of the source
  1623. * @param result defines the Vector3 where to store the result
  1624. */
  1625. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1626. /**
  1627. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1628. * @returns a new empty Vector3
  1629. */
  1630. static Zero(): Vector3;
  1631. /**
  1632. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1633. * @returns a new unit Vector3
  1634. */
  1635. static One(): Vector3;
  1636. /**
  1637. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1638. * @returns a new up Vector3
  1639. */
  1640. static Up(): Vector3;
  1641. /**
  1642. * Gets a up Vector3 that must not be updated
  1643. */
  1644. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1647. * @returns a new down Vector3
  1648. */
  1649. static Down(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1652. * @returns a new forward Vector3
  1653. */
  1654. static Forward(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1657. * @returns a new forward Vector3
  1658. */
  1659. static Backward(): Vector3;
  1660. /**
  1661. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1662. * @returns a new right Vector3
  1663. */
  1664. static Right(): Vector3;
  1665. /**
  1666. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1667. * @returns a new left Vector3
  1668. */
  1669. static Left(): Vector3;
  1670. /**
  1671. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1672. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1673. * @param vector defines the Vector3 to transform
  1674. * @param transformation defines the transformation matrix
  1675. * @returns the transformed Vector3
  1676. */
  1677. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1678. /**
  1679. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1680. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1681. * @param vector defines the Vector3 to transform
  1682. * @param transformation defines the transformation matrix
  1683. * @param result defines the Vector3 where to store the result
  1684. */
  1685. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1686. /**
  1687. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1688. * This method computes tranformed coordinates only, not transformed direction vectors
  1689. * @param x define the x coordinate of the source vector
  1690. * @param y define the y coordinate of the source vector
  1691. * @param z define the z coordinate of the source vector
  1692. * @param transformation defines the transformation matrix
  1693. * @param result defines the Vector3 where to store the result
  1694. */
  1695. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1696. /**
  1697. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1698. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1699. * @param vector defines the Vector3 to transform
  1700. * @param transformation defines the transformation matrix
  1701. * @returns the new Vector3
  1702. */
  1703. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1704. /**
  1705. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1706. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1707. * @param vector defines the Vector3 to transform
  1708. * @param transformation defines the transformation matrix
  1709. * @param result defines the Vector3 where to store the result
  1710. */
  1711. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1712. /**
  1713. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1714. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1715. * @param x define the x coordinate of the source vector
  1716. * @param y define the y coordinate of the source vector
  1717. * @param z define the z coordinate of the source vector
  1718. * @param transformation defines the transformation matrix
  1719. * @param result defines the Vector3 where to store the result
  1720. */
  1721. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1722. /**
  1723. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1724. * @param value1 defines the first control point
  1725. * @param value2 defines the second control point
  1726. * @param value3 defines the third control point
  1727. * @param value4 defines the fourth control point
  1728. * @param amount defines the amount on the spline to use
  1729. * @returns the new Vector3
  1730. */
  1731. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1732. /**
  1733. * 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"
  1734. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1735. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1736. * @param value defines the current value
  1737. * @param min defines the lower range value
  1738. * @param max defines the upper range value
  1739. * @returns the new Vector3
  1740. */
  1741. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1742. /**
  1743. * 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"
  1744. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1745. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1746. * @param value defines the current value
  1747. * @param min defines the lower range value
  1748. * @param max defines the upper range value
  1749. * @param result defines the Vector3 where to store the result
  1750. */
  1751. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1752. /**
  1753. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1754. * @param value1 defines the first control point
  1755. * @param tangent1 defines the first tangent vector
  1756. * @param value2 defines the second control point
  1757. * @param tangent2 defines the second tangent vector
  1758. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1759. * @returns the new Vector3
  1760. */
  1761. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1762. /**
  1763. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1764. * @param start defines the start value
  1765. * @param end defines the end value
  1766. * @param amount max defines amount between both (between 0 and 1)
  1767. * @returns the new Vector3
  1768. */
  1769. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1770. /**
  1771. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1772. * @param start defines the start value
  1773. * @param end defines the end value
  1774. * @param amount max defines amount between both (between 0 and 1)
  1775. * @param result defines the Vector3 where to store the result
  1776. */
  1777. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1778. /**
  1779. * Returns the dot product (float) between the vectors "left" and "right"
  1780. * @param left defines the left operand
  1781. * @param right defines the right operand
  1782. * @returns the dot product
  1783. */
  1784. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1785. /**
  1786. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1787. * The cross product is then orthogonal to both "left" and "right"
  1788. * @param left defines the left operand
  1789. * @param right defines the right operand
  1790. * @returns the cross product
  1791. */
  1792. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the cross product of "left" and "right"
  1795. * The cross product is then orthogonal to both "left" and "right"
  1796. * @param left defines the left operand
  1797. * @param right defines the right operand
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1801. /**
  1802. * Returns a new Vector3 as the normalization of the given vector
  1803. * @param vector defines the Vector3 to normalize
  1804. * @returns the new Vector3
  1805. */
  1806. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1807. /**
  1808. * Sets the given vector "result" with the normalization of the given first vector
  1809. * @param vector defines the Vector3 to normalize
  1810. * @param result defines the Vector3 where to store the result
  1811. */
  1812. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1813. /**
  1814. * Project a Vector3 onto screen space
  1815. * @param vector defines the Vector3 to project
  1816. * @param world defines the world matrix to use
  1817. * @param transform defines the transform (view x projection) matrix to use
  1818. * @param viewport defines the screen viewport to use
  1819. * @returns the new Vector3
  1820. */
  1821. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1822. /** @hidden */
  1823. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1824. /**
  1825. * Unproject from screen space to object space
  1826. * @param source defines the screen space Vector3 to use
  1827. * @param viewportWidth defines the current width of the viewport
  1828. * @param viewportHeight defines the current height of the viewport
  1829. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1830. * @param transform defines the transform (view x projection) matrix to use
  1831. * @returns the new Vector3
  1832. */
  1833. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1834. /**
  1835. * Unproject from screen space to object space
  1836. * @param source defines the screen space Vector3 to use
  1837. * @param viewportWidth defines the current width of the viewport
  1838. * @param viewportHeight defines the current height of the viewport
  1839. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1840. * @param view defines the view matrix to use
  1841. * @param projection defines the projection matrix to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1845. /**
  1846. * Unproject from screen space to object space
  1847. * @param source defines the screen space Vector3 to use
  1848. * @param viewportWidth defines the current width of the viewport
  1849. * @param viewportHeight defines the current height of the viewport
  1850. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1851. * @param view defines the view matrix to use
  1852. * @param projection defines the projection matrix to use
  1853. * @param result defines the Vector3 where to store the result
  1854. */
  1855. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1856. /**
  1857. * Unproject from screen space to object space
  1858. * @param sourceX defines the screen space x coordinate to use
  1859. * @param sourceY defines the screen space y coordinate to use
  1860. * @param sourceZ defines the screen space z coordinate to use
  1861. * @param viewportWidth defines the current width of the viewport
  1862. * @param viewportHeight defines the current height of the viewport
  1863. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1864. * @param view defines the view matrix to use
  1865. * @param projection defines the projection matrix to use
  1866. * @param result defines the Vector3 where to store the result
  1867. */
  1868. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1869. /**
  1870. * Gets the minimal coordinate values between two Vector3
  1871. * @param left defines the first operand
  1872. * @param right defines the second operand
  1873. * @returns the new Vector3
  1874. */
  1875. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1876. /**
  1877. * Gets the maximal coordinate values between two Vector3
  1878. * @param left defines the first operand
  1879. * @param right defines the second operand
  1880. * @returns the new Vector3
  1881. */
  1882. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1883. /**
  1884. * Returns the distance between the vectors "value1" and "value2"
  1885. * @param value1 defines the first operand
  1886. * @param value2 defines the second operand
  1887. * @returns the distance
  1888. */
  1889. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1890. /**
  1891. * Returns the squared distance between the vectors "value1" and "value2"
  1892. * @param value1 defines the first operand
  1893. * @param value2 defines the second operand
  1894. * @returns the squared distance
  1895. */
  1896. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1897. /**
  1898. * Returns a new Vector3 located at the center between "value1" and "value2"
  1899. * @param value1 defines the first operand
  1900. * @param value2 defines the second operand
  1901. * @returns the new Vector3
  1902. */
  1903. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1904. /**
  1905. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1906. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1907. * to something in order to rotate it from its local system to the given target system
  1908. * Note: axis1, axis2 and axis3 are normalized during this operation
  1909. * @param axis1 defines the first axis
  1910. * @param axis2 defines the second axis
  1911. * @param axis3 defines the third axis
  1912. * @returns a new Vector3
  1913. */
  1914. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1915. /**
  1916. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1917. * @param axis1 defines the first axis
  1918. * @param axis2 defines the second axis
  1919. * @param axis3 defines the third axis
  1920. * @param ref defines the Vector3 where to store the result
  1921. */
  1922. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1923. }
  1924. /**
  1925. * Vector4 class created for EulerAngle class conversion to Quaternion
  1926. */
  1927. export class Vector4 {
  1928. /** x value of the vector */
  1929. x: number;
  1930. /** y value of the vector */
  1931. y: number;
  1932. /** z value of the vector */
  1933. z: number;
  1934. /** w value of the vector */
  1935. w: number;
  1936. /**
  1937. * Creates a Vector4 object from the given floats.
  1938. * @param x x value of the vector
  1939. * @param y y value of the vector
  1940. * @param z z value of the vector
  1941. * @param w w value of the vector
  1942. */
  1943. constructor(
  1944. /** x value of the vector */
  1945. x: number,
  1946. /** y value of the vector */
  1947. y: number,
  1948. /** z value of the vector */
  1949. z: number,
  1950. /** w value of the vector */
  1951. w: number);
  1952. /**
  1953. * Returns the string with the Vector4 coordinates.
  1954. * @returns a string containing all the vector values
  1955. */
  1956. toString(): string;
  1957. /**
  1958. * Returns the string "Vector4".
  1959. * @returns "Vector4"
  1960. */
  1961. getClassName(): string;
  1962. /**
  1963. * Returns the Vector4 hash code.
  1964. * @returns a unique hash code
  1965. */
  1966. getHashCode(): number;
  1967. /**
  1968. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1969. * @returns the resulting array
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * Populates the given array from the given index with the Vector4 coordinates.
  1974. * @param array array to populate
  1975. * @param index index of the array to start at (default: 0)
  1976. * @returns the Vector4.
  1977. */
  1978. toArray(array: FloatArray, index?: number): Vector4;
  1979. /**
  1980. * Adds the given vector to the current Vector4.
  1981. * @param otherVector the vector to add
  1982. * @returns the updated Vector4.
  1983. */
  1984. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1985. /**
  1986. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1987. * @param otherVector the vector to add
  1988. * @returns the resulting vector
  1989. */
  1990. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1991. /**
  1992. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1993. * @param otherVector the vector to add
  1994. * @param result the vector to store the result
  1995. * @returns the current Vector4.
  1996. */
  1997. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1998. /**
  1999. * Subtract in place the given vector from the current Vector4.
  2000. * @param otherVector the vector to subtract
  2001. * @returns the updated Vector4.
  2002. */
  2003. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2004. /**
  2005. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2006. * @param otherVector the vector to add
  2007. * @returns the new vector with the result
  2008. */
  2009. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2010. /**
  2011. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2012. * @param otherVector the vector to subtract
  2013. * @param result the vector to store the result
  2014. * @returns the current Vector4.
  2015. */
  2016. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2017. /**
  2018. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2019. */
  2020. /**
  2021. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2022. * @param x value to subtract
  2023. * @param y value to subtract
  2024. * @param z value to subtract
  2025. * @param w value to subtract
  2026. * @returns new vector containing the result
  2027. */
  2028. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2029. /**
  2030. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2031. * @param x value to subtract
  2032. * @param y value to subtract
  2033. * @param z value to subtract
  2034. * @param w value to subtract
  2035. * @param result the vector to store the result in
  2036. * @returns the current Vector4.
  2037. */
  2038. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2039. /**
  2040. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2041. * @returns a new vector with the negated values
  2042. */
  2043. negate(): Vector4;
  2044. /**
  2045. * Multiplies the current Vector4 coordinates by scale (float).
  2046. * @param scale the number to scale with
  2047. * @returns the updated Vector4.
  2048. */
  2049. scaleInPlace(scale: number): Vector4;
  2050. /**
  2051. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2052. * @param scale the number to scale with
  2053. * @returns a new vector with the result
  2054. */
  2055. scale(scale: number): Vector4;
  2056. /**
  2057. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2058. * @param scale the number to scale with
  2059. * @param result a vector to store the result in
  2060. * @returns the current Vector4.
  2061. */
  2062. scaleToRef(scale: number, result: Vector4): Vector4;
  2063. /**
  2064. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2065. * @param scale defines the scale factor
  2066. * @param result defines the Vector4 object where to store the result
  2067. * @returns the unmodified current Vector4
  2068. */
  2069. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2070. /**
  2071. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2072. * @param otherVector the vector to compare against
  2073. * @returns true if they are equal
  2074. */
  2075. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2076. /**
  2077. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2078. * @param otherVector vector to compare against
  2079. * @param epsilon (Default: very small number)
  2080. * @returns true if they are equal
  2081. */
  2082. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2083. /**
  2084. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2085. * @param x x value to compare against
  2086. * @param y y value to compare against
  2087. * @param z z value to compare against
  2088. * @param w w value to compare against
  2089. * @returns true if equal
  2090. */
  2091. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2092. /**
  2093. * Multiplies in place the current Vector4 by the given one.
  2094. * @param otherVector vector to multiple with
  2095. * @returns the updated Vector4.
  2096. */
  2097. multiplyInPlace(otherVector: Vector4): Vector4;
  2098. /**
  2099. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2100. * @param otherVector vector to multiple with
  2101. * @returns resulting new vector
  2102. */
  2103. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2104. /**
  2105. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2106. * @param otherVector vector to multiple with
  2107. * @param result vector to store the result
  2108. * @returns the current Vector4.
  2109. */
  2110. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2111. /**
  2112. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2113. * @param x x value multiply with
  2114. * @param y y value multiply with
  2115. * @param z z value multiply with
  2116. * @param w w value multiply with
  2117. * @returns resulting new vector
  2118. */
  2119. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2120. /**
  2121. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2122. * @param otherVector vector to devide with
  2123. * @returns resulting new vector
  2124. */
  2125. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2126. /**
  2127. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2128. * @param otherVector vector to devide with
  2129. * @param result vector to store the result
  2130. * @returns the current Vector4.
  2131. */
  2132. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2133. /**
  2134. * Divides the current Vector3 coordinates by the given ones.
  2135. * @param otherVector vector to devide with
  2136. * @returns the updated Vector3.
  2137. */
  2138. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2139. /**
  2140. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2141. * @param other defines the second operand
  2142. * @returns the current updated Vector4
  2143. */
  2144. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2145. /**
  2146. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2147. * @param other defines the second operand
  2148. * @returns the current updated Vector4
  2149. */
  2150. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2151. /**
  2152. * Gets a new Vector4 from current Vector4 floored values
  2153. * @returns a new Vector4
  2154. */
  2155. floor(): Vector4;
  2156. /**
  2157. * Gets a new Vector4 from current Vector3 floored values
  2158. * @returns a new Vector4
  2159. */
  2160. fract(): Vector4;
  2161. /**
  2162. * Returns the Vector4 length (float).
  2163. * @returns the length
  2164. */
  2165. length(): number;
  2166. /**
  2167. * Returns the Vector4 squared length (float).
  2168. * @returns the length squared
  2169. */
  2170. lengthSquared(): number;
  2171. /**
  2172. * Normalizes in place the Vector4.
  2173. * @returns the updated Vector4.
  2174. */
  2175. normalize(): Vector4;
  2176. /**
  2177. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2178. * @returns this converted to a new vector3
  2179. */
  2180. toVector3(): Vector3;
  2181. /**
  2182. * Returns a new Vector4 copied from the current one.
  2183. * @returns the new cloned vector
  2184. */
  2185. clone(): Vector4;
  2186. /**
  2187. * Updates the current Vector4 with the given one coordinates.
  2188. * @param source the source vector to copy from
  2189. * @returns the updated Vector4.
  2190. */
  2191. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2192. /**
  2193. * Updates the current Vector4 coordinates with the given floats.
  2194. * @param x float to copy from
  2195. * @param y float to copy from
  2196. * @param z float to copy from
  2197. * @param w float to copy from
  2198. * @returns the updated Vector4.
  2199. */
  2200. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2201. /**
  2202. * Updates the current Vector4 coordinates with the given floats.
  2203. * @param x float to set from
  2204. * @param y float to set from
  2205. * @param z float to set from
  2206. * @param w float to set from
  2207. * @returns the updated Vector4.
  2208. */
  2209. set(x: number, y: number, z: number, w: number): Vector4;
  2210. /**
  2211. * Copies the given float to the current Vector3 coordinates
  2212. * @param v defines the x, y, z and w coordinates of the operand
  2213. * @returns the current updated Vector3
  2214. */
  2215. setAll(v: number): Vector4;
  2216. /**
  2217. * Returns a new Vector4 set from the starting index of the given array.
  2218. * @param array the array to pull values from
  2219. * @param offset the offset into the array to start at
  2220. * @returns the new vector
  2221. */
  2222. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2223. /**
  2224. * Updates the given vector "result" from the starting index of the given array.
  2225. * @param array the array to pull values from
  2226. * @param offset the offset into the array to start at
  2227. * @param result the vector to store the result in
  2228. */
  2229. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2230. /**
  2231. * Updates the given vector "result" from the starting index of the given Float32Array.
  2232. * @param array the array to pull values from
  2233. * @param offset the offset into the array to start at
  2234. * @param result the vector to store the result in
  2235. */
  2236. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2237. /**
  2238. * Updates the given vector "result" coordinates from the given floats.
  2239. * @param x float to set from
  2240. * @param y float to set from
  2241. * @param z float to set from
  2242. * @param w float to set from
  2243. * @param result the vector to the floats in
  2244. */
  2245. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2246. /**
  2247. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2248. * @returns the new vector
  2249. */
  2250. static Zero(): Vector4;
  2251. /**
  2252. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2253. * @returns the new vector
  2254. */
  2255. static One(): Vector4;
  2256. /**
  2257. * Returns a new normalized Vector4 from the given one.
  2258. * @param vector the vector to normalize
  2259. * @returns the vector
  2260. */
  2261. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2262. /**
  2263. * Updates the given vector "result" from the normalization of the given one.
  2264. * @param vector the vector to normalize
  2265. * @param result the vector to store the result in
  2266. */
  2267. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2268. /**
  2269. * Returns a vector with the minimum values from the left and right vectors
  2270. * @param left left vector to minimize
  2271. * @param right right vector to minimize
  2272. * @returns a new vector with the minimum of the left and right vector values
  2273. */
  2274. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2275. /**
  2276. * Returns a vector with the maximum values from the left and right vectors
  2277. * @param left left vector to maximize
  2278. * @param right right vector to maximize
  2279. * @returns a new vector with the maximum of the left and right vector values
  2280. */
  2281. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2282. /**
  2283. * Returns the distance (float) between the vectors "value1" and "value2".
  2284. * @param value1 value to calulate the distance between
  2285. * @param value2 value to calulate the distance between
  2286. * @return the distance between the two vectors
  2287. */
  2288. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2289. /**
  2290. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2291. * @param value1 value to calulate the distance between
  2292. * @param value2 value to calulate the distance between
  2293. * @return the distance between the two vectors squared
  2294. */
  2295. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2296. /**
  2297. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2298. * @param value1 value to calulate the center between
  2299. * @param value2 value to calulate the center between
  2300. * @return the center between the two vectors
  2301. */
  2302. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2303. /**
  2304. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2305. * This methods computes transformed normalized direction vectors only.
  2306. * @param vector the vector to transform
  2307. * @param transformation the transformation matrix to apply
  2308. * @returns the new vector
  2309. */
  2310. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2311. /**
  2312. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2313. * This methods computes transformed normalized direction vectors only.
  2314. * @param vector the vector to transform
  2315. * @param transformation the transformation matrix to apply
  2316. * @param result the vector to store the result in
  2317. */
  2318. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2319. /**
  2320. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2321. * This methods computes transformed normalized direction vectors only.
  2322. * @param x value to transform
  2323. * @param y value to transform
  2324. * @param z value to transform
  2325. * @param w value to transform
  2326. * @param transformation the transformation matrix to apply
  2327. * @param result the vector to store the results in
  2328. */
  2329. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2330. /**
  2331. * Creates a new Vector4 from a Vector3
  2332. * @param source defines the source data
  2333. * @param w defines the 4th component (default is 0)
  2334. * @returns a new Vector4
  2335. */
  2336. static FromVector3(source: Vector3, w?: number): Vector4;
  2337. }
  2338. /**
  2339. * Interface for the size containing width and height
  2340. */
  2341. export interface ISize {
  2342. /**
  2343. * Width
  2344. */
  2345. width: number;
  2346. /**
  2347. * Heighht
  2348. */
  2349. height: number;
  2350. }
  2351. /**
  2352. * Size containing widht and height
  2353. */
  2354. export class Size implements ISize {
  2355. /**
  2356. * Width
  2357. */
  2358. width: number;
  2359. /**
  2360. * Height
  2361. */
  2362. height: number;
  2363. /**
  2364. * Creates a Size object from the given width and height (floats).
  2365. * @param width width of the new size
  2366. * @param height height of the new size
  2367. */
  2368. constructor(width: number, height: number);
  2369. /**
  2370. * Returns a string with the Size width and height
  2371. * @returns a string with the Size width and height
  2372. */
  2373. toString(): string;
  2374. /**
  2375. * "Size"
  2376. * @returns the string "Size"
  2377. */
  2378. getClassName(): string;
  2379. /**
  2380. * Returns the Size hash code.
  2381. * @returns a hash code for a unique width and height
  2382. */
  2383. getHashCode(): number;
  2384. /**
  2385. * Updates the current size from the given one.
  2386. * @param src the given size
  2387. */
  2388. copyFrom(src: Size): void;
  2389. /**
  2390. * Updates in place the current Size from the given floats.
  2391. * @param width width of the new size
  2392. * @param height height of the new size
  2393. * @returns the updated Size.
  2394. */
  2395. copyFromFloats(width: number, height: number): Size;
  2396. /**
  2397. * Updates in place the current Size from the given floats.
  2398. * @param width width to set
  2399. * @param height height to set
  2400. * @returns the updated Size.
  2401. */
  2402. set(width: number, height: number): Size;
  2403. /**
  2404. * Multiplies the width and height by numbers
  2405. * @param w factor to multiple the width by
  2406. * @param h factor to multiple the height by
  2407. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2408. */
  2409. multiplyByFloats(w: number, h: number): Size;
  2410. /**
  2411. * Clones the size
  2412. * @returns a new Size copied from the given one.
  2413. */
  2414. clone(): Size;
  2415. /**
  2416. * True if the current Size and the given one width and height are strictly equal.
  2417. * @param other the other size to compare against
  2418. * @returns True if the current Size and the given one width and height are strictly equal.
  2419. */
  2420. equals(other: Size): boolean;
  2421. /**
  2422. * The surface of the Size : width * height (float).
  2423. */
  2424. readonly surface: number;
  2425. /**
  2426. * Create a new size of zero
  2427. * @returns a new Size set to (0.0, 0.0)
  2428. */
  2429. static Zero(): Size;
  2430. /**
  2431. * Sums the width and height of two sizes
  2432. * @param otherSize size to add to this size
  2433. * @returns a new Size set as the addition result of the current Size and the given one.
  2434. */
  2435. add(otherSize: Size): Size;
  2436. /**
  2437. * Subtracts the width and height of two
  2438. * @param otherSize size to subtract to this size
  2439. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2440. */
  2441. subtract(otherSize: Size): Size;
  2442. /**
  2443. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2444. * @param start starting size to lerp between
  2445. * @param end end size to lerp between
  2446. * @param amount amount to lerp between the start and end values
  2447. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2448. */
  2449. static Lerp(start: Size, end: Size, amount: number): Size;
  2450. }
  2451. /**
  2452. * Class used to store quaternion data
  2453. * @see https://en.wikipedia.org/wiki/Quaternion
  2454. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2455. */
  2456. export class Quaternion {
  2457. /** defines the first component (0 by default) */
  2458. x: number;
  2459. /** defines the second component (0 by default) */
  2460. y: number;
  2461. /** defines the third component (0 by default) */
  2462. z: number;
  2463. /** defines the fourth component (1.0 by default) */
  2464. w: number;
  2465. /**
  2466. * Creates a new Quaternion from the given floats
  2467. * @param x defines the first component (0 by default)
  2468. * @param y defines the second component (0 by default)
  2469. * @param z defines the third component (0 by default)
  2470. * @param w defines the fourth component (1.0 by default)
  2471. */
  2472. constructor(
  2473. /** defines the first component (0 by default) */
  2474. x?: number,
  2475. /** defines the second component (0 by default) */
  2476. y?: number,
  2477. /** defines the third component (0 by default) */
  2478. z?: number,
  2479. /** defines the fourth component (1.0 by default) */
  2480. w?: number);
  2481. /**
  2482. * Gets a string representation for the current quaternion
  2483. * @returns a string with the Quaternion coordinates
  2484. */
  2485. toString(): string;
  2486. /**
  2487. * Gets the class name of the quaternion
  2488. * @returns the string "Quaternion"
  2489. */
  2490. getClassName(): string;
  2491. /**
  2492. * Gets a hash code for this quaternion
  2493. * @returns the quaternion hash code
  2494. */
  2495. getHashCode(): number;
  2496. /**
  2497. * Copy the quaternion to an array
  2498. * @returns a new array populated with 4 elements from the quaternion coordinates
  2499. */
  2500. asArray(): number[];
  2501. /**
  2502. * Check if two quaternions are equals
  2503. * @param otherQuaternion defines the second operand
  2504. * @return true if the current quaternion and the given one coordinates are strictly equals
  2505. */
  2506. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2507. /**
  2508. * Clone the current quaternion
  2509. * @returns a new quaternion copied from the current one
  2510. */
  2511. clone(): Quaternion;
  2512. /**
  2513. * Copy a quaternion to the current one
  2514. * @param other defines the other quaternion
  2515. * @returns the updated current quaternion
  2516. */
  2517. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2518. /**
  2519. * Updates the current quaternion with the given float coordinates
  2520. * @param x defines the x coordinate
  2521. * @param y defines the y coordinate
  2522. * @param z defines the z coordinate
  2523. * @param w defines the w coordinate
  2524. * @returns the updated current quaternion
  2525. */
  2526. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2527. /**
  2528. * Updates the current quaternion from the given float coordinates
  2529. * @param x defines the x coordinate
  2530. * @param y defines the y coordinate
  2531. * @param z defines the z coordinate
  2532. * @param w defines the w coordinate
  2533. * @returns the updated current quaternion
  2534. */
  2535. set(x: number, y: number, z: number, w: number): Quaternion;
  2536. /**
  2537. * Adds two quaternions
  2538. * @param other defines the second operand
  2539. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2540. */
  2541. add(other: DeepImmutable<Quaternion>): Quaternion;
  2542. /**
  2543. * Add a quaternion to the current one
  2544. * @param other defines the quaternion to add
  2545. * @returns the current quaternion
  2546. */
  2547. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2548. /**
  2549. * Subtract two quaternions
  2550. * @param other defines the second operand
  2551. * @returns a new quaternion as the subtraction result of the given one from the current one
  2552. */
  2553. subtract(other: Quaternion): Quaternion;
  2554. /**
  2555. * Multiplies the current quaternion by a scale factor
  2556. * @param value defines the scale factor
  2557. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2558. */
  2559. scale(value: number): Quaternion;
  2560. /**
  2561. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2562. * @param scale defines the scale factor
  2563. * @param result defines the Quaternion object where to store the result
  2564. * @returns the unmodified current quaternion
  2565. */
  2566. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2567. /**
  2568. * Multiplies in place the current quaternion by a scale factor
  2569. * @param value defines the scale factor
  2570. * @returns the current modified quaternion
  2571. */
  2572. scaleInPlace(value: number): Quaternion;
  2573. /**
  2574. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2575. * @param scale defines the scale factor
  2576. * @param result defines the Quaternion object where to store the result
  2577. * @returns the unmodified current quaternion
  2578. */
  2579. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2580. /**
  2581. * Multiplies two quaternions
  2582. * @param q1 defines the second operand
  2583. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2584. */
  2585. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2586. /**
  2587. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2588. * @param q1 defines the second operand
  2589. * @param result defines the target quaternion
  2590. * @returns the current quaternion
  2591. */
  2592. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2593. /**
  2594. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2595. * @param q1 defines the second operand
  2596. * @returns the currentupdated quaternion
  2597. */
  2598. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2599. /**
  2600. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2601. * @param ref defines the target quaternion
  2602. * @returns the current quaternion
  2603. */
  2604. conjugateToRef(ref: Quaternion): Quaternion;
  2605. /**
  2606. * Conjugates in place (1-q) the current quaternion
  2607. * @returns the current updated quaternion
  2608. */
  2609. conjugateInPlace(): Quaternion;
  2610. /**
  2611. * Conjugates in place (1-q) the current quaternion
  2612. * @returns a new quaternion
  2613. */
  2614. conjugate(): Quaternion;
  2615. /**
  2616. * Gets length of current quaternion
  2617. * @returns the quaternion length (float)
  2618. */
  2619. length(): number;
  2620. /**
  2621. * Normalize in place the current quaternion
  2622. * @returns the current updated quaternion
  2623. */
  2624. normalize(): Quaternion;
  2625. /**
  2626. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2627. * @param order is a reserved parameter and is ignore for now
  2628. * @returns a new Vector3 containing the Euler angles
  2629. */
  2630. toEulerAngles(order?: string): Vector3;
  2631. /**
  2632. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2633. * @param result defines the vector which will be filled with the Euler angles
  2634. * @param order is a reserved parameter and is ignore for now
  2635. * @returns the current unchanged quaternion
  2636. */
  2637. toEulerAnglesToRef(result: Vector3): Quaternion;
  2638. /**
  2639. * Updates the given rotation matrix with the current quaternion values
  2640. * @param result defines the target matrix
  2641. * @returns the current unchanged quaternion
  2642. */
  2643. toRotationMatrix(result: Matrix): Quaternion;
  2644. /**
  2645. * Updates the current quaternion from the given rotation matrix values
  2646. * @param matrix defines the source matrix
  2647. * @returns the current updated quaternion
  2648. */
  2649. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2650. /**
  2651. * Creates a new quaternion from a rotation matrix
  2652. * @param matrix defines the source matrix
  2653. * @returns a new quaternion created from the given rotation matrix values
  2654. */
  2655. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2656. /**
  2657. * Updates the given quaternion with the given rotation matrix values
  2658. * @param matrix defines the source matrix
  2659. * @param result defines the target quaternion
  2660. */
  2661. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2662. /**
  2663. * Returns the dot product (float) between the quaternions "left" and "right"
  2664. * @param left defines the left operand
  2665. * @param right defines the right operand
  2666. * @returns the dot product
  2667. */
  2668. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2669. /**
  2670. * Checks if the two quaternions are close to each other
  2671. * @param quat0 defines the first quaternion to check
  2672. * @param quat1 defines the second quaternion to check
  2673. * @returns true if the two quaternions are close to each other
  2674. */
  2675. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2676. /**
  2677. * Creates an empty quaternion
  2678. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2679. */
  2680. static Zero(): Quaternion;
  2681. /**
  2682. * Inverse a given quaternion
  2683. * @param q defines the source quaternion
  2684. * @returns a new quaternion as the inverted current quaternion
  2685. */
  2686. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2687. /**
  2688. * Inverse a given quaternion
  2689. * @param q defines the source quaternion
  2690. * @param result the quaternion the result will be stored in
  2691. * @returns the result quaternion
  2692. */
  2693. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2694. /**
  2695. * Creates an identity quaternion
  2696. * @returns the identity quaternion
  2697. */
  2698. static Identity(): Quaternion;
  2699. /**
  2700. * Gets a boolean indicating if the given quaternion is identity
  2701. * @param quaternion defines the quaternion to check
  2702. * @returns true if the quaternion is identity
  2703. */
  2704. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2705. /**
  2706. * Creates a quaternion from a rotation around an axis
  2707. * @param axis defines the axis to use
  2708. * @param angle defines the angle to use
  2709. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2710. */
  2711. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2712. /**
  2713. * Creates a rotation around an axis and stores it into the given quaternion
  2714. * @param axis defines the axis to use
  2715. * @param angle defines the angle to use
  2716. * @param result defines the target quaternion
  2717. * @returns the target quaternion
  2718. */
  2719. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2720. /**
  2721. * Creates a new quaternion from data stored into an array
  2722. * @param array defines the data source
  2723. * @param offset defines the offset in the source array where the data starts
  2724. * @returns a new quaternion
  2725. */
  2726. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2727. /**
  2728. * Create a quaternion from Euler rotation angles
  2729. * @param x Pitch
  2730. * @param y Yaw
  2731. * @param z Roll
  2732. * @returns the new Quaternion
  2733. */
  2734. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2735. /**
  2736. * Updates a quaternion from Euler rotation angles
  2737. * @param x Pitch
  2738. * @param y Yaw
  2739. * @param z Roll
  2740. * @param result the quaternion to store the result
  2741. * @returns the updated quaternion
  2742. */
  2743. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2744. /**
  2745. * Create a quaternion from Euler rotation vector
  2746. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2747. * @returns the new Quaternion
  2748. */
  2749. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2750. /**
  2751. * Updates a quaternion from Euler rotation vector
  2752. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2753. * @param result the quaternion to store the result
  2754. * @returns the updated quaternion
  2755. */
  2756. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2757. /**
  2758. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2759. * @param yaw defines the rotation around Y axis
  2760. * @param pitch defines the rotation around X axis
  2761. * @param roll defines the rotation around Z axis
  2762. * @returns the new quaternion
  2763. */
  2764. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2765. /**
  2766. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2767. * @param yaw defines the rotation around Y axis
  2768. * @param pitch defines the rotation around X axis
  2769. * @param roll defines the rotation around Z axis
  2770. * @param result defines the target quaternion
  2771. */
  2772. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2773. /**
  2774. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2775. * @param alpha defines the rotation around first axis
  2776. * @param beta defines the rotation around second axis
  2777. * @param gamma defines the rotation around third axis
  2778. * @returns the new quaternion
  2779. */
  2780. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2781. /**
  2782. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2783. * @param alpha defines the rotation around first axis
  2784. * @param beta defines the rotation around second axis
  2785. * @param gamma defines the rotation around third axis
  2786. * @param result defines the target quaternion
  2787. */
  2788. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2789. /**
  2790. * 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)
  2791. * @param axis1 defines the first axis
  2792. * @param axis2 defines the second axis
  2793. * @param axis3 defines the third axis
  2794. * @returns the new quaternion
  2795. */
  2796. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2797. /**
  2798. * 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
  2799. * @param axis1 defines the first axis
  2800. * @param axis2 defines the second axis
  2801. * @param axis3 defines the third axis
  2802. * @param ref defines the target quaternion
  2803. */
  2804. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2805. /**
  2806. * Interpolates between two quaternions
  2807. * @param left defines first quaternion
  2808. * @param right defines second quaternion
  2809. * @param amount defines the gradient to use
  2810. * @returns the new interpolated quaternion
  2811. */
  2812. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2813. /**
  2814. * Interpolates between two quaternions and stores it into a target quaternion
  2815. * @param left defines first quaternion
  2816. * @param right defines second quaternion
  2817. * @param amount defines the gradient to use
  2818. * @param result defines the target quaternion
  2819. */
  2820. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2821. /**
  2822. * Interpolate between two quaternions using Hermite interpolation
  2823. * @param value1 defines first quaternion
  2824. * @param tangent1 defines the incoming tangent
  2825. * @param value2 defines second quaternion
  2826. * @param tangent2 defines the outgoing tangent
  2827. * @param amount defines the target quaternion
  2828. * @returns the new interpolated quaternion
  2829. */
  2830. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2831. }
  2832. /**
  2833. * Class used to store matrix data (4x4)
  2834. */
  2835. export class Matrix {
  2836. private static _updateFlagSeed;
  2837. private static _identityReadOnly;
  2838. private _isIdentity;
  2839. private _isIdentityDirty;
  2840. private _isIdentity3x2;
  2841. private _isIdentity3x2Dirty;
  2842. /**
  2843. * Gets the update flag of the matrix which is an unique number for the matrix.
  2844. * It will be incremented every time the matrix data change.
  2845. * You can use it to speed the comparison between two versions of the same matrix.
  2846. */
  2847. updateFlag: number;
  2848. private readonly _m;
  2849. /**
  2850. * Gets the internal data of the matrix
  2851. */
  2852. readonly m: DeepImmutable<Float32Array>;
  2853. /** @hidden */
  2854. _markAsUpdated(): void;
  2855. /** @hidden */
  2856. private _updateIdentityStatus;
  2857. /**
  2858. * Creates an empty matrix (filled with zeros)
  2859. */
  2860. constructor();
  2861. /**
  2862. * Check if the current matrix is identity
  2863. * @returns true is the matrix is the identity matrix
  2864. */
  2865. isIdentity(): boolean;
  2866. /**
  2867. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2868. * @returns true is the matrix is the identity matrix
  2869. */
  2870. isIdentityAs3x2(): boolean;
  2871. /**
  2872. * Gets the determinant of the matrix
  2873. * @returns the matrix determinant
  2874. */
  2875. determinant(): number;
  2876. /**
  2877. * Returns the matrix as a Float32Array
  2878. * @returns the matrix underlying array
  2879. */
  2880. toArray(): DeepImmutable<Float32Array>;
  2881. /**
  2882. * Returns the matrix as a Float32Array
  2883. * @returns the matrix underlying array.
  2884. */
  2885. asArray(): DeepImmutable<Float32Array>;
  2886. /**
  2887. * Inverts the current matrix in place
  2888. * @returns the current inverted matrix
  2889. */
  2890. invert(): Matrix;
  2891. /**
  2892. * Sets all the matrix elements to zero
  2893. * @returns the current matrix
  2894. */
  2895. reset(): Matrix;
  2896. /**
  2897. * Adds the current matrix with a second one
  2898. * @param other defines the matrix to add
  2899. * @returns a new matrix as the addition of the current matrix and the given one
  2900. */
  2901. add(other: DeepImmutable<Matrix>): Matrix;
  2902. /**
  2903. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2904. * @param other defines the matrix to add
  2905. * @param result defines the target matrix
  2906. * @returns the current matrix
  2907. */
  2908. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2909. /**
  2910. * Adds in place the given matrix to the current matrix
  2911. * @param other defines the second operand
  2912. * @returns the current updated matrix
  2913. */
  2914. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2915. /**
  2916. * Sets the given matrix to the current inverted Matrix
  2917. * @param other defines the target matrix
  2918. * @returns the unmodified current matrix
  2919. */
  2920. invertToRef(other: Matrix): Matrix;
  2921. /**
  2922. * add a value at the specified position in the current Matrix
  2923. * @param index the index of the value within the matrix. between 0 and 15.
  2924. * @param value the value to be added
  2925. * @returns the current updated matrix
  2926. */
  2927. addAtIndex(index: number, value: number): Matrix;
  2928. /**
  2929. * mutiply the specified position in the current Matrix by a value
  2930. * @param index the index of the value within the matrix. between 0 and 15.
  2931. * @param value the value to be added
  2932. * @returns the current updated matrix
  2933. */
  2934. multiplyAtIndex(index: number, value: number): Matrix;
  2935. /**
  2936. * Inserts the translation vector (using 3 floats) in the current matrix
  2937. * @param x defines the 1st component of the translation
  2938. * @param y defines the 2nd component of the translation
  2939. * @param z defines the 3rd component of the translation
  2940. * @returns the current updated matrix
  2941. */
  2942. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2943. /**
  2944. * Adds the translation vector (using 3 floats) in the current matrix
  2945. * @param x defines the 1st component of the translation
  2946. * @param y defines the 2nd component of the translation
  2947. * @param z defines the 3rd component of the translation
  2948. * @returns the current updated matrix
  2949. */
  2950. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2951. /**
  2952. * Inserts the translation vector in the current matrix
  2953. * @param vector3 defines the translation to insert
  2954. * @returns the current updated matrix
  2955. */
  2956. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2957. /**
  2958. * Gets the translation value of the current matrix
  2959. * @returns a new Vector3 as the extracted translation from the matrix
  2960. */
  2961. getTranslation(): Vector3;
  2962. /**
  2963. * Fill a Vector3 with the extracted translation from the matrix
  2964. * @param result defines the Vector3 where to store the translation
  2965. * @returns the current matrix
  2966. */
  2967. getTranslationToRef(result: Vector3): Matrix;
  2968. /**
  2969. * Remove rotation and scaling part from the matrix
  2970. * @returns the updated matrix
  2971. */
  2972. removeRotationAndScaling(): Matrix;
  2973. /**
  2974. * Multiply two matrices
  2975. * @param other defines the second operand
  2976. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2977. */
  2978. multiply(other: DeepImmutable<Matrix>): Matrix;
  2979. /**
  2980. * Copy the current matrix from the given one
  2981. * @param other defines the source matrix
  2982. * @returns the current updated matrix
  2983. */
  2984. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2985. /**
  2986. * Populates the given array from the starting index with the current matrix values
  2987. * @param array defines the target array
  2988. * @param offset defines the offset in the target array where to start storing values
  2989. * @returns the current matrix
  2990. */
  2991. copyToArray(array: Float32Array, offset?: number): Matrix;
  2992. /**
  2993. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2994. * @param other defines the second operand
  2995. * @param result defines the matrix where to store the multiplication
  2996. * @returns the current matrix
  2997. */
  2998. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2999. /**
  3000. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3001. * @param other defines the second operand
  3002. * @param result defines the array where to store the multiplication
  3003. * @param offset defines the offset in the target array where to start storing values
  3004. * @returns the current matrix
  3005. */
  3006. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3007. /**
  3008. * Check equality between this matrix and a second one
  3009. * @param value defines the second matrix to compare
  3010. * @returns true is the current matrix and the given one values are strictly equal
  3011. */
  3012. equals(value: DeepImmutable<Matrix>): boolean;
  3013. /**
  3014. * Clone the current matrix
  3015. * @returns a new matrix from the current matrix
  3016. */
  3017. clone(): Matrix;
  3018. /**
  3019. * Returns the name of the current matrix class
  3020. * @returns the string "Matrix"
  3021. */
  3022. getClassName(): string;
  3023. /**
  3024. * Gets the hash code of the current matrix
  3025. * @returns the hash code
  3026. */
  3027. getHashCode(): number;
  3028. /**
  3029. * Decomposes the current Matrix into a translation, rotation and scaling components
  3030. * @param scale defines the scale vector3 given as a reference to update
  3031. * @param rotation defines the rotation quaternion given as a reference to update
  3032. * @param translation defines the translation vector3 given as a reference to update
  3033. * @returns true if operation was successful
  3034. */
  3035. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3036. /**
  3037. * Gets specific row of the matrix
  3038. * @param index defines the number of the row to get
  3039. * @returns the index-th row of the current matrix as a new Vector4
  3040. */
  3041. getRow(index: number): Nullable<Vector4>;
  3042. /**
  3043. * Sets the index-th row of the current matrix to the vector4 values
  3044. * @param index defines the number of the row to set
  3045. * @param row defines the target vector4
  3046. * @returns the updated current matrix
  3047. */
  3048. setRow(index: number, row: Vector4): Matrix;
  3049. /**
  3050. * Compute the transpose of the matrix
  3051. * @returns the new transposed matrix
  3052. */
  3053. transpose(): Matrix;
  3054. /**
  3055. * Compute the transpose of the matrix and store it in a given matrix
  3056. * @param result defines the target matrix
  3057. * @returns the current matrix
  3058. */
  3059. transposeToRef(result: Matrix): Matrix;
  3060. /**
  3061. * Sets the index-th row of the current matrix with the given 4 x float values
  3062. * @param index defines the row index
  3063. * @param x defines the x component to set
  3064. * @param y defines the y component to set
  3065. * @param z defines the z component to set
  3066. * @param w defines the w component to set
  3067. * @returns the updated current matrix
  3068. */
  3069. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3070. /**
  3071. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3072. * @param scale defines the scale factor
  3073. * @returns a new matrix
  3074. */
  3075. scale(scale: number): Matrix;
  3076. /**
  3077. * Scale the current matrix values by a factor to a given result matrix
  3078. * @param scale defines the scale factor
  3079. * @param result defines the matrix to store the result
  3080. * @returns the current matrix
  3081. */
  3082. scaleToRef(scale: number, result: Matrix): Matrix;
  3083. /**
  3084. * Scale the current matrix values by a factor and add the result to a given matrix
  3085. * @param scale defines the scale factor
  3086. * @param result defines the Matrix to store the result
  3087. * @returns the current matrix
  3088. */
  3089. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3090. /**
  3091. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3092. * @param ref matrix to store the result
  3093. */
  3094. toNormalMatrix(ref: Matrix): void;
  3095. /**
  3096. * Gets only rotation part of the current matrix
  3097. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3098. */
  3099. getRotationMatrix(): Matrix;
  3100. /**
  3101. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3102. * @param result defines the target matrix to store data to
  3103. * @returns the current matrix
  3104. */
  3105. getRotationMatrixToRef(result: Matrix): Matrix;
  3106. /**
  3107. * Toggles model matrix from being right handed to left handed in place and vice versa
  3108. */
  3109. toggleModelMatrixHandInPlace(): void;
  3110. /**
  3111. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3112. */
  3113. toggleProjectionMatrixHandInPlace(): void;
  3114. /**
  3115. * Creates a matrix from an array
  3116. * @param array defines the source array
  3117. * @param offset defines an offset in the source array
  3118. * @returns a new Matrix set from the starting index of the given array
  3119. */
  3120. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3121. /**
  3122. * Copy the content of an array into a given matrix
  3123. * @param array defines the source array
  3124. * @param offset defines an offset in the source array
  3125. * @param result defines the target matrix
  3126. */
  3127. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3128. /**
  3129. * Stores an array into a matrix after having multiplied each component by a given factor
  3130. * @param array defines the source array
  3131. * @param offset defines the offset in the source array
  3132. * @param scale defines the scaling factor
  3133. * @param result defines the target matrix
  3134. */
  3135. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3136. /**
  3137. * Gets an identity matrix that must not be updated
  3138. */
  3139. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3140. /**
  3141. * Stores a list of values (16) inside a given matrix
  3142. * @param initialM11 defines 1st value of 1st row
  3143. * @param initialM12 defines 2nd value of 1st row
  3144. * @param initialM13 defines 3rd value of 1st row
  3145. * @param initialM14 defines 4th value of 1st row
  3146. * @param initialM21 defines 1st value of 2nd row
  3147. * @param initialM22 defines 2nd value of 2nd row
  3148. * @param initialM23 defines 3rd value of 2nd row
  3149. * @param initialM24 defines 4th value of 2nd row
  3150. * @param initialM31 defines 1st value of 3rd row
  3151. * @param initialM32 defines 2nd value of 3rd row
  3152. * @param initialM33 defines 3rd value of 3rd row
  3153. * @param initialM34 defines 4th value of 3rd row
  3154. * @param initialM41 defines 1st value of 4th row
  3155. * @param initialM42 defines 2nd value of 4th row
  3156. * @param initialM43 defines 3rd value of 4th row
  3157. * @param initialM44 defines 4th value of 4th row
  3158. * @param result defines the target matrix
  3159. */
  3160. 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;
  3161. /**
  3162. * Creates new matrix from a list of values (16)
  3163. * @param initialM11 defines 1st value of 1st row
  3164. * @param initialM12 defines 2nd value of 1st row
  3165. * @param initialM13 defines 3rd value of 1st row
  3166. * @param initialM14 defines 4th value of 1st row
  3167. * @param initialM21 defines 1st value of 2nd row
  3168. * @param initialM22 defines 2nd value of 2nd row
  3169. * @param initialM23 defines 3rd value of 2nd row
  3170. * @param initialM24 defines 4th value of 2nd row
  3171. * @param initialM31 defines 1st value of 3rd row
  3172. * @param initialM32 defines 2nd value of 3rd row
  3173. * @param initialM33 defines 3rd value of 3rd row
  3174. * @param initialM34 defines 4th value of 3rd row
  3175. * @param initialM41 defines 1st value of 4th row
  3176. * @param initialM42 defines 2nd value of 4th row
  3177. * @param initialM43 defines 3rd value of 4th row
  3178. * @param initialM44 defines 4th value of 4th row
  3179. * @returns the new matrix
  3180. */
  3181. 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;
  3182. /**
  3183. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3184. * @param scale defines the scale vector3
  3185. * @param rotation defines the rotation quaternion
  3186. * @param translation defines the translation vector3
  3187. * @returns a new matrix
  3188. */
  3189. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3190. /**
  3191. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3192. * @param scale defines the scale vector3
  3193. * @param rotation defines the rotation quaternion
  3194. * @param translation defines the translation vector3
  3195. * @param result defines the target matrix
  3196. */
  3197. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3198. /**
  3199. * Creates a new identity matrix
  3200. * @returns a new identity matrix
  3201. */
  3202. static Identity(): Matrix;
  3203. /**
  3204. * Creates a new identity matrix and stores the result in a given matrix
  3205. * @param result defines the target matrix
  3206. */
  3207. static IdentityToRef(result: Matrix): void;
  3208. /**
  3209. * Creates a new zero matrix
  3210. * @returns a new zero matrix
  3211. */
  3212. static Zero(): Matrix;
  3213. /**
  3214. * Creates a new rotation matrix for "angle" radians around the X axis
  3215. * @param angle defines the angle (in radians) to use
  3216. * @return the new matrix
  3217. */
  3218. static RotationX(angle: number): Matrix;
  3219. /**
  3220. * Creates a new matrix as the invert of a given matrix
  3221. * @param source defines the source matrix
  3222. * @returns the new matrix
  3223. */
  3224. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3225. /**
  3226. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3227. * @param angle defines the angle (in radians) to use
  3228. * @param result defines the target matrix
  3229. */
  3230. static RotationXToRef(angle: number, result: Matrix): void;
  3231. /**
  3232. * Creates a new rotation matrix for "angle" radians around the Y axis
  3233. * @param angle defines the angle (in radians) to use
  3234. * @return the new matrix
  3235. */
  3236. static RotationY(angle: number): Matrix;
  3237. /**
  3238. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3239. * @param angle defines the angle (in radians) to use
  3240. * @param result defines the target matrix
  3241. */
  3242. static RotationYToRef(angle: number, result: Matrix): void;
  3243. /**
  3244. * Creates a new rotation matrix for "angle" radians around the Z axis
  3245. * @param angle defines the angle (in radians) to use
  3246. * @return the new matrix
  3247. */
  3248. static RotationZ(angle: number): Matrix;
  3249. /**
  3250. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3251. * @param angle defines the angle (in radians) to use
  3252. * @param result defines the target matrix
  3253. */
  3254. static RotationZToRef(angle: number, result: Matrix): void;
  3255. /**
  3256. * Creates a new rotation matrix for "angle" radians around the given axis
  3257. * @param axis defines the axis to use
  3258. * @param angle defines the angle (in radians) to use
  3259. * @return the new matrix
  3260. */
  3261. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3262. /**
  3263. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3264. * @param axis defines the axis to use
  3265. * @param angle defines the angle (in radians) to use
  3266. * @param result defines the target matrix
  3267. */
  3268. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3269. /**
  3270. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3271. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3272. * @param from defines the vector to align
  3273. * @param to defines the vector to align to
  3274. * @param result defines the target matrix
  3275. */
  3276. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3277. /**
  3278. * Creates a rotation matrix
  3279. * @param yaw defines the yaw angle in radians (Y axis)
  3280. * @param pitch defines the pitch angle in radians (X axis)
  3281. * @param roll defines the roll angle in radians (X axis)
  3282. * @returns the new rotation matrix
  3283. */
  3284. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3285. /**
  3286. * Creates a rotation matrix and stores it in a given matrix
  3287. * @param yaw defines the yaw angle in radians (Y axis)
  3288. * @param pitch defines the pitch angle in radians (X axis)
  3289. * @param roll defines the roll angle in radians (X axis)
  3290. * @param result defines the target matrix
  3291. */
  3292. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3293. /**
  3294. * Creates a scaling matrix
  3295. * @param x defines the scale factor on X axis
  3296. * @param y defines the scale factor on Y axis
  3297. * @param z defines the scale factor on Z axis
  3298. * @returns the new matrix
  3299. */
  3300. static Scaling(x: number, y: number, z: number): Matrix;
  3301. /**
  3302. * Creates a scaling matrix and stores it in a given matrix
  3303. * @param x defines the scale factor on X axis
  3304. * @param y defines the scale factor on Y axis
  3305. * @param z defines the scale factor on Z axis
  3306. * @param result defines the target matrix
  3307. */
  3308. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3309. /**
  3310. * Creates a translation matrix
  3311. * @param x defines the translation on X axis
  3312. * @param y defines the translation on Y axis
  3313. * @param z defines the translationon Z axis
  3314. * @returns the new matrix
  3315. */
  3316. static Translation(x: number, y: number, z: number): Matrix;
  3317. /**
  3318. * Creates a translation matrix and stores it in a given matrix
  3319. * @param x defines the translation on X axis
  3320. * @param y defines the translation on Y axis
  3321. * @param z defines the translationon Z axis
  3322. * @param result defines the target matrix
  3323. */
  3324. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3325. /**
  3326. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3327. * @param startValue defines the start value
  3328. * @param endValue defines the end value
  3329. * @param gradient defines the gradient factor
  3330. * @returns the new matrix
  3331. */
  3332. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3333. /**
  3334. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3335. * @param startValue defines the start value
  3336. * @param endValue defines the end value
  3337. * @param gradient defines the gradient factor
  3338. * @param result defines the Matrix object where to store data
  3339. */
  3340. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3341. /**
  3342. * Builds a new matrix whose values are computed by:
  3343. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3344. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3345. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3346. * @param startValue defines the first matrix
  3347. * @param endValue defines the second matrix
  3348. * @param gradient defines the gradient between the two matrices
  3349. * @returns the new matrix
  3350. */
  3351. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3352. /**
  3353. * Update a matrix to values which are computed by:
  3354. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3355. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3356. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3357. * @param startValue defines the first matrix
  3358. * @param endValue defines the second matrix
  3359. * @param gradient defines the gradient between the two matrices
  3360. * @param result defines the target matrix
  3361. */
  3362. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3363. /**
  3364. * 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"
  3365. * This function works in left handed mode
  3366. * @param eye defines the final position of the entity
  3367. * @param target defines where the entity should look at
  3368. * @param up defines the up vector for the entity
  3369. * @returns the new matrix
  3370. */
  3371. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3372. /**
  3373. * 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".
  3374. * This function works in left handed mode
  3375. * @param eye defines the final position of the entity
  3376. * @param target defines where the entity should look at
  3377. * @param up defines the up vector for the entity
  3378. * @param result defines the target matrix
  3379. */
  3380. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3381. /**
  3382. * 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"
  3383. * This function works in right handed mode
  3384. * @param eye defines the final position of the entity
  3385. * @param target defines where the entity should look at
  3386. * @param up defines the up vector for the entity
  3387. * @returns the new matrix
  3388. */
  3389. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3390. /**
  3391. * 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".
  3392. * This function works in right handed mode
  3393. * @param eye defines the final position of the entity
  3394. * @param target defines where the entity should look at
  3395. * @param up defines the up vector for the entity
  3396. * @param result defines the target matrix
  3397. */
  3398. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3399. /**
  3400. * Create a left-handed orthographic projection matrix
  3401. * @param width defines the viewport width
  3402. * @param height defines the viewport height
  3403. * @param znear defines the near clip plane
  3404. * @param zfar defines the far clip plane
  3405. * @returns a new matrix as a left-handed orthographic projection matrix
  3406. */
  3407. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3408. /**
  3409. * Store a left-handed orthographic projection to a given matrix
  3410. * @param width defines the viewport width
  3411. * @param height defines the viewport height
  3412. * @param znear defines the near clip plane
  3413. * @param zfar defines the far clip plane
  3414. * @param result defines the target matrix
  3415. */
  3416. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3417. /**
  3418. * Create a left-handed orthographic projection matrix
  3419. * @param left defines the viewport left coordinate
  3420. * @param right defines the viewport right coordinate
  3421. * @param bottom defines the viewport bottom coordinate
  3422. * @param top defines the viewport top coordinate
  3423. * @param znear defines the near clip plane
  3424. * @param zfar defines the far clip plane
  3425. * @returns a new matrix as a left-handed orthographic projection matrix
  3426. */
  3427. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3428. /**
  3429. * Stores a left-handed orthographic projection into a given matrix
  3430. * @param left defines the viewport left coordinate
  3431. * @param right defines the viewport right coordinate
  3432. * @param bottom defines the viewport bottom coordinate
  3433. * @param top defines the viewport top coordinate
  3434. * @param znear defines the near clip plane
  3435. * @param zfar defines the far clip plane
  3436. * @param result defines the target matrix
  3437. */
  3438. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3439. /**
  3440. * Creates a right-handed orthographic projection matrix
  3441. * @param left defines the viewport left coordinate
  3442. * @param right defines the viewport right coordinate
  3443. * @param bottom defines the viewport bottom coordinate
  3444. * @param top defines the viewport top coordinate
  3445. * @param znear defines the near clip plane
  3446. * @param zfar defines the far clip plane
  3447. * @returns a new matrix as a right-handed orthographic projection matrix
  3448. */
  3449. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3450. /**
  3451. * Stores a right-handed orthographic projection into a given matrix
  3452. * @param left defines the viewport left coordinate
  3453. * @param right defines the viewport right coordinate
  3454. * @param bottom defines the viewport bottom coordinate
  3455. * @param top defines the viewport top coordinate
  3456. * @param znear defines the near clip plane
  3457. * @param zfar defines the far clip plane
  3458. * @param result defines the target matrix
  3459. */
  3460. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3461. /**
  3462. * Creates a left-handed perspective projection matrix
  3463. * @param width defines the viewport width
  3464. * @param height defines the viewport height
  3465. * @param znear defines the near clip plane
  3466. * @param zfar defines the far clip plane
  3467. * @returns a new matrix as a left-handed perspective projection matrix
  3468. */
  3469. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3470. /**
  3471. * Creates a left-handed perspective projection matrix
  3472. * @param fov defines the horizontal field of view
  3473. * @param aspect defines the aspect ratio
  3474. * @param znear defines the near clip plane
  3475. * @param zfar defines the far clip plane
  3476. * @returns a new matrix as a left-handed perspective projection matrix
  3477. */
  3478. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3479. /**
  3480. * Stores a left-handed perspective projection into a given matrix
  3481. * @param fov defines the horizontal field of view
  3482. * @param aspect defines the aspect ratio
  3483. * @param znear defines the near clip plane
  3484. * @param zfar defines the far clip plane
  3485. * @param result defines the target matrix
  3486. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3487. */
  3488. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3489. /**
  3490. * Creates a right-handed perspective projection matrix
  3491. * @param fov defines the horizontal field of view
  3492. * @param aspect defines the aspect ratio
  3493. * @param znear defines the near clip plane
  3494. * @param zfar defines the far clip plane
  3495. * @returns a new matrix as a right-handed perspective projection matrix
  3496. */
  3497. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3498. /**
  3499. * Stores a right-handed perspective projection into a given matrix
  3500. * @param fov defines the horizontal field of view
  3501. * @param aspect defines the aspect ratio
  3502. * @param znear defines the near clip plane
  3503. * @param zfar defines the far clip plane
  3504. * @param result defines the target matrix
  3505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3506. */
  3507. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3508. /**
  3509. * Stores a perspective projection for WebVR info a given matrix
  3510. * @param fov defines the field of view
  3511. * @param znear defines the near clip plane
  3512. * @param zfar defines the far clip plane
  3513. * @param result defines the target matrix
  3514. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3515. */
  3516. static PerspectiveFovWebVRToRef(fov: {
  3517. upDegrees: number;
  3518. downDegrees: number;
  3519. leftDegrees: number;
  3520. rightDegrees: number;
  3521. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3522. /**
  3523. * Computes a complete transformation matrix
  3524. * @param viewport defines the viewport to use
  3525. * @param world defines the world matrix
  3526. * @param view defines the view matrix
  3527. * @param projection defines the projection matrix
  3528. * @param zmin defines the near clip plane
  3529. * @param zmax defines the far clip plane
  3530. * @returns the transformation matrix
  3531. */
  3532. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3533. /**
  3534. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3535. * @param matrix defines the matrix to use
  3536. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3537. */
  3538. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3539. /**
  3540. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3541. * @param matrix defines the matrix to use
  3542. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3543. */
  3544. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3545. /**
  3546. * Compute the transpose of a given matrix
  3547. * @param matrix defines the matrix to transpose
  3548. * @returns the new matrix
  3549. */
  3550. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3551. /**
  3552. * Compute the transpose of a matrix and store it in a target matrix
  3553. * @param matrix defines the matrix to transpose
  3554. * @param result defines the target matrix
  3555. */
  3556. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3557. /**
  3558. * Computes a reflection matrix from a plane
  3559. * @param plane defines the reflection plane
  3560. * @returns a new matrix
  3561. */
  3562. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3563. /**
  3564. * Computes a reflection matrix from a plane
  3565. * @param plane defines the reflection plane
  3566. * @param result defines the target matrix
  3567. */
  3568. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3569. /**
  3570. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3571. * @param xaxis defines the value of the 1st axis
  3572. * @param yaxis defines the value of the 2nd axis
  3573. * @param zaxis defines the value of the 3rd axis
  3574. * @param result defines the target matrix
  3575. */
  3576. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3577. /**
  3578. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3579. * @param quat defines the quaternion to use
  3580. * @param result defines the target matrix
  3581. */
  3582. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3583. }
  3584. /**
  3585. * Represens a plane by the equation ax + by + cz + d = 0
  3586. */
  3587. export class Plane {
  3588. /**
  3589. * Normal of the plane (a,b,c)
  3590. */
  3591. normal: Vector3;
  3592. /**
  3593. * d component of the plane
  3594. */
  3595. d: number;
  3596. /**
  3597. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3598. * @param a a component of the plane
  3599. * @param b b component of the plane
  3600. * @param c c component of the plane
  3601. * @param d d component of the plane
  3602. */
  3603. constructor(a: number, b: number, c: number, d: number);
  3604. /**
  3605. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3606. */
  3607. asArray(): number[];
  3608. /**
  3609. * @returns a new plane copied from the current Plane.
  3610. */
  3611. clone(): Plane;
  3612. /**
  3613. * @returns the string "Plane".
  3614. */
  3615. getClassName(): string;
  3616. /**
  3617. * @returns the Plane hash code.
  3618. */
  3619. getHashCode(): number;
  3620. /**
  3621. * Normalize the current Plane in place.
  3622. * @returns the updated Plane.
  3623. */
  3624. normalize(): Plane;
  3625. /**
  3626. * Applies a transformation the plane and returns the result
  3627. * @param transformation the transformation matrix to be applied to the plane
  3628. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3629. */
  3630. transform(transformation: DeepImmutable<Matrix>): Plane;
  3631. /**
  3632. * Calcualtte the dot product between the point and the plane normal
  3633. * @param point point to calculate the dot product with
  3634. * @returns the dot product (float) of the point coordinates and the plane normal.
  3635. */
  3636. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3637. /**
  3638. * Updates the current Plane from the plane defined by the three given points.
  3639. * @param point1 one of the points used to contruct the plane
  3640. * @param point2 one of the points used to contruct the plane
  3641. * @param point3 one of the points used to contruct the plane
  3642. * @returns the updated Plane.
  3643. */
  3644. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3645. /**
  3646. * Checks if the plane is facing a given direction
  3647. * @param direction the direction to check if the plane is facing
  3648. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3649. * @returns True is the vector "direction" is the same side than the plane normal.
  3650. */
  3651. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3652. /**
  3653. * Calculates the distance to a point
  3654. * @param point point to calculate distance to
  3655. * @returns the signed distance (float) from the given point to the Plane.
  3656. */
  3657. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3658. /**
  3659. * Creates a plane from an array
  3660. * @param array the array to create a plane from
  3661. * @returns a new Plane from the given array.
  3662. */
  3663. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3664. /**
  3665. * Creates a plane from three points
  3666. * @param point1 point used to create the plane
  3667. * @param point2 point used to create the plane
  3668. * @param point3 point used to create the plane
  3669. * @returns a new Plane defined by the three given points.
  3670. */
  3671. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3672. /**
  3673. * Creates a plane from an origin point and a normal
  3674. * @param origin origin of the plane to be constructed
  3675. * @param normal normal of the plane to be constructed
  3676. * @returns a new Plane the normal vector to this plane at the given origin point.
  3677. * Note : the vector "normal" is updated because normalized.
  3678. */
  3679. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3680. /**
  3681. * Calculates the distance from a plane and a point
  3682. * @param origin origin of the plane to be constructed
  3683. * @param normal normal of the plane to be constructed
  3684. * @param point point to calculate distance to
  3685. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3686. */
  3687. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3688. }
  3689. /**
  3690. * Class used to represent a viewport on screen
  3691. */
  3692. export class Viewport {
  3693. /** viewport left coordinate */
  3694. x: number;
  3695. /** viewport top coordinate */
  3696. y: number;
  3697. /**viewport width */
  3698. width: number;
  3699. /** viewport height */
  3700. height: number;
  3701. /**
  3702. * Creates a Viewport object located at (x, y) and sized (width, height)
  3703. * @param x defines viewport left coordinate
  3704. * @param y defines viewport top coordinate
  3705. * @param width defines the viewport width
  3706. * @param height defines the viewport height
  3707. */
  3708. constructor(
  3709. /** viewport left coordinate */
  3710. x: number,
  3711. /** viewport top coordinate */
  3712. y: number,
  3713. /**viewport width */
  3714. width: number,
  3715. /** viewport height */
  3716. height: number);
  3717. /**
  3718. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3719. * @param renderWidth defines the rendering width
  3720. * @param renderHeight defines the rendering height
  3721. * @returns a new Viewport
  3722. */
  3723. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3724. /**
  3725. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3726. * @param renderWidth defines the rendering width
  3727. * @param renderHeight defines the rendering height
  3728. * @param ref defines the target viewport
  3729. * @returns the current viewport
  3730. */
  3731. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3732. /**
  3733. * Returns a new Viewport copied from the current one
  3734. * @returns a new Viewport
  3735. */
  3736. clone(): Viewport;
  3737. }
  3738. /**
  3739. * Reprasents a camera frustum
  3740. */
  3741. export class Frustum {
  3742. /**
  3743. * Gets the planes representing the frustum
  3744. * @param transform matrix to be applied to the returned planes
  3745. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3746. */
  3747. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3748. /**
  3749. * Gets the near frustum plane transformed by the transform matrix
  3750. * @param transform transformation matrix to be applied to the resulting frustum plane
  3751. * @param frustumPlane the resuling frustum plane
  3752. */
  3753. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3754. /**
  3755. * Gets the far frustum plane transformed by the transform matrix
  3756. * @param transform transformation matrix to be applied to the resulting frustum plane
  3757. * @param frustumPlane the resuling frustum plane
  3758. */
  3759. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3760. /**
  3761. * Gets the left frustum plane transformed by the transform matrix
  3762. * @param transform transformation matrix to be applied to the resulting frustum plane
  3763. * @param frustumPlane the resuling frustum plane
  3764. */
  3765. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3766. /**
  3767. * Gets the right frustum plane transformed by the transform matrix
  3768. * @param transform transformation matrix to be applied to the resulting frustum plane
  3769. * @param frustumPlane the resuling frustum plane
  3770. */
  3771. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3772. /**
  3773. * Gets the top frustum plane transformed by the transform matrix
  3774. * @param transform transformation matrix to be applied to the resulting frustum plane
  3775. * @param frustumPlane the resuling frustum plane
  3776. */
  3777. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3778. /**
  3779. * Gets the bottom frustum plane transformed by the transform matrix
  3780. * @param transform transformation matrix to be applied to the resulting frustum plane
  3781. * @param frustumPlane the resuling frustum plane
  3782. */
  3783. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3784. /**
  3785. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3786. * @param transform transformation matrix to be applied to the resulting frustum planes
  3787. * @param frustumPlanes the resuling frustum planes
  3788. */
  3789. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3790. }
  3791. /** Defines supported spaces */
  3792. export enum Space {
  3793. /** Local (object) space */
  3794. LOCAL = 0,
  3795. /** World space */
  3796. WORLD = 1,
  3797. /** Bone space */
  3798. BONE = 2
  3799. }
  3800. /** Defines the 3 main axes */
  3801. export class Axis {
  3802. /** X axis */
  3803. static X: Vector3;
  3804. /** Y axis */
  3805. static Y: Vector3;
  3806. /** Z axis */
  3807. static Z: Vector3;
  3808. }
  3809. /** Class used to represent a Bezier curve */
  3810. export class BezierCurve {
  3811. /**
  3812. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3813. * @param t defines the time
  3814. * @param x1 defines the left coordinate on X axis
  3815. * @param y1 defines the left coordinate on Y axis
  3816. * @param x2 defines the right coordinate on X axis
  3817. * @param y2 defines the right coordinate on Y axis
  3818. * @returns the interpolated value
  3819. */
  3820. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3821. }
  3822. /**
  3823. * Defines potential orientation for back face culling
  3824. */
  3825. export enum Orientation {
  3826. /**
  3827. * Clockwise
  3828. */
  3829. CW = 0,
  3830. /** Counter clockwise */
  3831. CCW = 1
  3832. }
  3833. /**
  3834. * Defines angle representation
  3835. */
  3836. export class Angle {
  3837. private _radians;
  3838. /**
  3839. * Creates an Angle object of "radians" radians (float).
  3840. * @param radians the angle in radians
  3841. */
  3842. constructor(radians: number);
  3843. /**
  3844. * Get value in degrees
  3845. * @returns the Angle value in degrees (float)
  3846. */
  3847. degrees(): number;
  3848. /**
  3849. * Get value in radians
  3850. * @returns the Angle value in radians (float)
  3851. */
  3852. radians(): number;
  3853. /**
  3854. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3855. * @param a defines first vector
  3856. * @param b defines second vector
  3857. * @returns a new Angle
  3858. */
  3859. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3860. /**
  3861. * Gets a new Angle object from the given float in radians
  3862. * @param radians defines the angle value in radians
  3863. * @returns a new Angle
  3864. */
  3865. static FromRadians(radians: number): Angle;
  3866. /**
  3867. * Gets a new Angle object from the given float in degrees
  3868. * @param degrees defines the angle value in degrees
  3869. * @returns a new Angle
  3870. */
  3871. static FromDegrees(degrees: number): Angle;
  3872. }
  3873. /**
  3874. * This represents an arc in a 2d space.
  3875. */
  3876. export class Arc2 {
  3877. /** Defines the start point of the arc */
  3878. startPoint: Vector2;
  3879. /** Defines the mid point of the arc */
  3880. midPoint: Vector2;
  3881. /** Defines the end point of the arc */
  3882. endPoint: Vector2;
  3883. /**
  3884. * Defines the center point of the arc.
  3885. */
  3886. centerPoint: Vector2;
  3887. /**
  3888. * Defines the radius of the arc.
  3889. */
  3890. radius: number;
  3891. /**
  3892. * Defines the angle of the arc (from mid point to end point).
  3893. */
  3894. angle: Angle;
  3895. /**
  3896. * Defines the start angle of the arc (from start point to middle point).
  3897. */
  3898. startAngle: Angle;
  3899. /**
  3900. * Defines the orientation of the arc (clock wise/counter clock wise).
  3901. */
  3902. orientation: Orientation;
  3903. /**
  3904. * Creates an Arc object from the three given points : start, middle and end.
  3905. * @param startPoint Defines the start point of the arc
  3906. * @param midPoint Defines the midlle point of the arc
  3907. * @param endPoint Defines the end point of the arc
  3908. */
  3909. constructor(
  3910. /** Defines the start point of the arc */
  3911. startPoint: Vector2,
  3912. /** Defines the mid point of the arc */
  3913. midPoint: Vector2,
  3914. /** Defines the end point of the arc */
  3915. endPoint: Vector2);
  3916. }
  3917. /**
  3918. * Represents a 2D path made up of multiple 2D points
  3919. */
  3920. export class Path2 {
  3921. private _points;
  3922. private _length;
  3923. /**
  3924. * If the path start and end point are the same
  3925. */
  3926. closed: boolean;
  3927. /**
  3928. * Creates a Path2 object from the starting 2D coordinates x and y.
  3929. * @param x the starting points x value
  3930. * @param y the starting points y value
  3931. */
  3932. constructor(x: number, y: number);
  3933. /**
  3934. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3935. * @param x the added points x value
  3936. * @param y the added points y value
  3937. * @returns the updated Path2.
  3938. */
  3939. addLineTo(x: number, y: number): Path2;
  3940. /**
  3941. * 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.
  3942. * @param midX middle point x value
  3943. * @param midY middle point y value
  3944. * @param endX end point x value
  3945. * @param endY end point y value
  3946. * @param numberOfSegments (default: 36)
  3947. * @returns the updated Path2.
  3948. */
  3949. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3950. /**
  3951. * Closes the Path2.
  3952. * @returns the Path2.
  3953. */
  3954. close(): Path2;
  3955. /**
  3956. * Gets the sum of the distance between each sequential point in the path
  3957. * @returns the Path2 total length (float).
  3958. */
  3959. length(): number;
  3960. /**
  3961. * Gets the points which construct the path
  3962. * @returns the Path2 internal array of points.
  3963. */
  3964. getPoints(): Vector2[];
  3965. /**
  3966. * Retreives the point at the distance aways from the starting point
  3967. * @param normalizedLengthPosition the length along the path to retreive the point from
  3968. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3969. */
  3970. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3971. /**
  3972. * Creates a new path starting from an x and y position
  3973. * @param x starting x value
  3974. * @param y starting y value
  3975. * @returns a new Path2 starting at the coordinates (x, y).
  3976. */
  3977. static StartingAt(x: number, y: number): Path2;
  3978. }
  3979. /**
  3980. * Represents a 3D path made up of multiple 3D points
  3981. */
  3982. export class Path3D {
  3983. /**
  3984. * an array of Vector3, the curve axis of the Path3D
  3985. */
  3986. path: Vector3[];
  3987. private _curve;
  3988. private _distances;
  3989. private _tangents;
  3990. private _normals;
  3991. private _binormals;
  3992. private _raw;
  3993. /**
  3994. * new Path3D(path, normal, raw)
  3995. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3996. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3997. * @param path an array of Vector3, the curve axis of the Path3D
  3998. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3999. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4000. */
  4001. constructor(
  4002. /**
  4003. * an array of Vector3, the curve axis of the Path3D
  4004. */
  4005. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4006. /**
  4007. * Returns the Path3D array of successive Vector3 designing its curve.
  4008. * @returns the Path3D array of successive Vector3 designing its curve.
  4009. */
  4010. getCurve(): Vector3[];
  4011. /**
  4012. * Returns an array populated with tangent vectors on each Path3D curve point.
  4013. * @returns an array populated with tangent vectors on each Path3D curve point.
  4014. */
  4015. getTangents(): Vector3[];
  4016. /**
  4017. * Returns an array populated with normal vectors on each Path3D curve point.
  4018. * @returns an array populated with normal vectors on each Path3D curve point.
  4019. */
  4020. getNormals(): Vector3[];
  4021. /**
  4022. * Returns an array populated with binormal vectors on each Path3D curve point.
  4023. * @returns an array populated with binormal vectors on each Path3D curve point.
  4024. */
  4025. getBinormals(): Vector3[];
  4026. /**
  4027. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4028. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4029. */
  4030. getDistances(): number[];
  4031. /**
  4032. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4033. * @param path path which all values are copied into the curves points
  4034. * @param firstNormal which should be projected onto the curve
  4035. * @returns the same object updated.
  4036. */
  4037. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4038. private _compute;
  4039. private _getFirstNonNullVector;
  4040. private _getLastNonNullVector;
  4041. private _normalVector;
  4042. }
  4043. /**
  4044. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4045. * A Curve3 is designed from a series of successive Vector3.
  4046. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4047. */
  4048. export class Curve3 {
  4049. private _points;
  4050. private _length;
  4051. /**
  4052. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4053. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4054. * @param v1 (Vector3) the control point
  4055. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4056. * @param nbPoints (integer) the wanted number of points in the curve
  4057. * @returns the created Curve3
  4058. */
  4059. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4060. /**
  4061. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4062. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4063. * @param v1 (Vector3) the first control point
  4064. * @param v2 (Vector3) the second control point
  4065. * @param v3 (Vector3) the end point of the Cubic Bezier
  4066. * @param nbPoints (integer) the wanted number of points in the curve
  4067. * @returns the created Curve3
  4068. */
  4069. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4070. /**
  4071. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4072. * @param p1 (Vector3) the origin point of the Hermite Spline
  4073. * @param t1 (Vector3) the tangent vector at the origin point
  4074. * @param p2 (Vector3) the end point of the Hermite Spline
  4075. * @param t2 (Vector3) the tangent vector at the end point
  4076. * @param nbPoints (integer) the wanted number of points in the curve
  4077. * @returns the created Curve3
  4078. */
  4079. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4080. /**
  4081. * Returns a Curve3 object along a CatmullRom Spline curve :
  4082. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4083. * @param nbPoints (integer) the wanted number of points between each curve control points
  4084. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4085. * @returns the created Curve3
  4086. */
  4087. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4088. /**
  4089. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4090. * A Curve3 is designed from a series of successive Vector3.
  4091. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4092. * @param points points which make up the curve
  4093. */
  4094. constructor(points: Vector3[]);
  4095. /**
  4096. * @returns the Curve3 stored array of successive Vector3
  4097. */
  4098. getPoints(): Vector3[];
  4099. /**
  4100. * @returns the computed length (float) of the curve.
  4101. */
  4102. length(): number;
  4103. /**
  4104. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4105. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4106. * curveA and curveB keep unchanged.
  4107. * @param curve the curve to continue from this curve
  4108. * @returns the newly constructed curve
  4109. */
  4110. continue(curve: DeepImmutable<Curve3>): Curve3;
  4111. private _computeLength;
  4112. }
  4113. /**
  4114. * Contains position and normal vectors for a vertex
  4115. */
  4116. export class PositionNormalVertex {
  4117. /** the position of the vertex (defaut: 0,0,0) */
  4118. position: Vector3;
  4119. /** the normal of the vertex (defaut: 0,1,0) */
  4120. normal: Vector3;
  4121. /**
  4122. * Creates a PositionNormalVertex
  4123. * @param position the position of the vertex (defaut: 0,0,0)
  4124. * @param normal the normal of the vertex (defaut: 0,1,0)
  4125. */
  4126. constructor(
  4127. /** the position of the vertex (defaut: 0,0,0) */
  4128. position?: Vector3,
  4129. /** the normal of the vertex (defaut: 0,1,0) */
  4130. normal?: Vector3);
  4131. /**
  4132. * Clones the PositionNormalVertex
  4133. * @returns the cloned PositionNormalVertex
  4134. */
  4135. clone(): PositionNormalVertex;
  4136. }
  4137. /**
  4138. * Contains position, normal and uv vectors for a vertex
  4139. */
  4140. export class PositionNormalTextureVertex {
  4141. /** the position of the vertex (defaut: 0,0,0) */
  4142. position: Vector3;
  4143. /** the normal of the vertex (defaut: 0,1,0) */
  4144. normal: Vector3;
  4145. /** the uv of the vertex (default: 0,0) */
  4146. uv: Vector2;
  4147. /**
  4148. * Creates a PositionNormalTextureVertex
  4149. * @param position the position of the vertex (defaut: 0,0,0)
  4150. * @param normal the normal of the vertex (defaut: 0,1,0)
  4151. * @param uv the uv of the vertex (default: 0,0)
  4152. */
  4153. constructor(
  4154. /** the position of the vertex (defaut: 0,0,0) */
  4155. position?: Vector3,
  4156. /** the normal of the vertex (defaut: 0,1,0) */
  4157. normal?: Vector3,
  4158. /** the uv of the vertex (default: 0,0) */
  4159. uv?: Vector2);
  4160. /**
  4161. * Clones the PositionNormalTextureVertex
  4162. * @returns the cloned PositionNormalTextureVertex
  4163. */
  4164. clone(): PositionNormalTextureVertex;
  4165. }
  4166. /**
  4167. * @hidden
  4168. */
  4169. export class Tmp {
  4170. static Color3: Color3[];
  4171. static Color4: Color4[];
  4172. static Vector2: Vector2[];
  4173. static Vector3: Vector3[];
  4174. static Vector4: Vector4[];
  4175. static Quaternion: Quaternion[];
  4176. static Matrix: Matrix[];
  4177. }
  4178. }
  4179. declare module "babylonjs/Offline/IOfflineProvider" {
  4180. /**
  4181. * Class used to enable access to offline support
  4182. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4183. */
  4184. export interface IOfflineProvider {
  4185. /**
  4186. * Gets a boolean indicating if scene must be saved in the database
  4187. */
  4188. enableSceneOffline: boolean;
  4189. /**
  4190. * Gets a boolean indicating if textures must be saved in the database
  4191. */
  4192. enableTexturesOffline: boolean;
  4193. /**
  4194. * Open the offline support and make it available
  4195. * @param successCallback defines the callback to call on success
  4196. * @param errorCallback defines the callback to call on error
  4197. */
  4198. open(successCallback: () => void, errorCallback: () => void): void;
  4199. /**
  4200. * Loads an image from the offline support
  4201. * @param url defines the url to load from
  4202. * @param image defines the target DOM image
  4203. */
  4204. loadImage(url: string, image: HTMLImageElement): void;
  4205. /**
  4206. * Loads a file from offline support
  4207. * @param url defines the URL to load from
  4208. * @param sceneLoaded defines a callback to call on success
  4209. * @param progressCallBack defines a callback to call when progress changed
  4210. * @param errorCallback defines a callback to call on error
  4211. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4212. */
  4213. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4214. }
  4215. }
  4216. declare module "babylonjs/Misc/observable" {
  4217. import { Nullable } from "babylonjs/types";
  4218. /**
  4219. * A class serves as a medium between the observable and its observers
  4220. */
  4221. export class EventState {
  4222. /**
  4223. * Create a new EventState
  4224. * @param mask defines the mask associated with this state
  4225. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4226. * @param target defines the original target of the state
  4227. * @param currentTarget defines the current target of the state
  4228. */
  4229. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4230. /**
  4231. * Initialize the current event state
  4232. * @param mask defines the mask associated with this state
  4233. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4234. * @param target defines the original target of the state
  4235. * @param currentTarget defines the current target of the state
  4236. * @returns the current event state
  4237. */
  4238. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4239. /**
  4240. * An Observer can set this property to true to prevent subsequent observers of being notified
  4241. */
  4242. skipNextObservers: boolean;
  4243. /**
  4244. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4245. */
  4246. mask: number;
  4247. /**
  4248. * The object that originally notified the event
  4249. */
  4250. target?: any;
  4251. /**
  4252. * The current object in the bubbling phase
  4253. */
  4254. currentTarget?: any;
  4255. /**
  4256. * This will be populated with the return value of the last function that was executed.
  4257. * If it is the first function in the callback chain it will be the event data.
  4258. */
  4259. lastReturnValue?: any;
  4260. }
  4261. /**
  4262. * Represent an Observer registered to a given Observable object.
  4263. */
  4264. export class Observer<T> {
  4265. /**
  4266. * Defines the callback to call when the observer is notified
  4267. */
  4268. callback: (eventData: T, eventState: EventState) => void;
  4269. /**
  4270. * Defines the mask of the observer (used to filter notifications)
  4271. */
  4272. mask: number;
  4273. /**
  4274. * Defines the current scope used to restore the JS context
  4275. */
  4276. scope: any;
  4277. /** @hidden */
  4278. _willBeUnregistered: boolean;
  4279. /**
  4280. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4281. */
  4282. unregisterOnNextCall: boolean;
  4283. /**
  4284. * Creates a new observer
  4285. * @param callback defines the callback to call when the observer is notified
  4286. * @param mask defines the mask of the observer (used to filter notifications)
  4287. * @param scope defines the current scope used to restore the JS context
  4288. */
  4289. constructor(
  4290. /**
  4291. * Defines the callback to call when the observer is notified
  4292. */
  4293. callback: (eventData: T, eventState: EventState) => void,
  4294. /**
  4295. * Defines the mask of the observer (used to filter notifications)
  4296. */
  4297. mask: number,
  4298. /**
  4299. * Defines the current scope used to restore the JS context
  4300. */
  4301. scope?: any);
  4302. }
  4303. /**
  4304. * Represent a list of observers registered to multiple Observables object.
  4305. */
  4306. export class MultiObserver<T> {
  4307. private _observers;
  4308. private _observables;
  4309. /**
  4310. * Release associated resources
  4311. */
  4312. dispose(): void;
  4313. /**
  4314. * Raise a callback when one of the observable will notify
  4315. * @param observables defines a list of observables to watch
  4316. * @param callback defines the callback to call on notification
  4317. * @param mask defines the mask used to filter notifications
  4318. * @param scope defines the current scope used to restore the JS context
  4319. * @returns the new MultiObserver
  4320. */
  4321. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4322. }
  4323. /**
  4324. * The Observable class is a simple implementation of the Observable pattern.
  4325. *
  4326. * 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.
  4327. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4328. * 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).
  4329. * 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.
  4330. */
  4331. export class Observable<T> {
  4332. private _observers;
  4333. private _eventState;
  4334. private _onObserverAdded;
  4335. /**
  4336. * Creates a new observable
  4337. * @param onObserverAdded defines a callback to call when a new observer is added
  4338. */
  4339. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4340. /**
  4341. * Create a new Observer with the specified callback
  4342. * @param callback the callback that will be executed for that Observer
  4343. * @param mask the mask used to filter observers
  4344. * @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.
  4345. * @param scope optional scope for the callback to be called from
  4346. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4347. * @returns the new observer created for the callback
  4348. */
  4349. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4350. /**
  4351. * Create a new Observer with the specified callback and unregisters after the next notification
  4352. * @param callback the callback that will be executed for that Observer
  4353. * @returns the new observer created for the callback
  4354. */
  4355. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4356. /**
  4357. * Remove an Observer from the Observable object
  4358. * @param observer the instance of the Observer to remove
  4359. * @returns false if it doesn't belong to this Observable
  4360. */
  4361. remove(observer: Nullable<Observer<T>>): boolean;
  4362. /**
  4363. * Remove a callback from the Observable object
  4364. * @param callback the callback to remove
  4365. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4366. * @returns false if it doesn't belong to this Observable
  4367. */
  4368. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4369. private _deferUnregister;
  4370. private _remove;
  4371. /**
  4372. * Moves the observable to the top of the observer list making it get called first when notified
  4373. * @param observer the observer to move
  4374. */
  4375. makeObserverTopPriority(observer: Observer<T>): void;
  4376. /**
  4377. * Moves the observable to the bottom of the observer list making it get called last when notified
  4378. * @param observer the observer to move
  4379. */
  4380. makeObserverBottomPriority(observer: Observer<T>): void;
  4381. /**
  4382. * Notify all Observers by calling their respective callback with the given data
  4383. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4384. * @param eventData defines the data to send to all observers
  4385. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4386. * @param target defines the original target of the state
  4387. * @param currentTarget defines the current target of the state
  4388. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4389. */
  4390. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4391. /**
  4392. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4393. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4394. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4395. * and it is crucial that all callbacks will be executed.
  4396. * The order of the callbacks is kept, callbacks are not executed parallel.
  4397. *
  4398. * @param eventData The data to be sent to each callback
  4399. * @param mask is used to filter observers defaults to -1
  4400. * @param target defines the callback target (see EventState)
  4401. * @param currentTarget defines he current object in the bubbling phase
  4402. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4403. */
  4404. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4405. /**
  4406. * Notify a specific observer
  4407. * @param observer defines the observer to notify
  4408. * @param eventData defines the data to be sent to each callback
  4409. * @param mask is used to filter observers defaults to -1
  4410. */
  4411. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4412. /**
  4413. * Gets a boolean indicating if the observable has at least one observer
  4414. * @returns true is the Observable has at least one Observer registered
  4415. */
  4416. hasObservers(): boolean;
  4417. /**
  4418. * Clear the list of observers
  4419. */
  4420. clear(): void;
  4421. /**
  4422. * Clone the current observable
  4423. * @returns a new observable
  4424. */
  4425. clone(): Observable<T>;
  4426. /**
  4427. * Does this observable handles observer registered with a given mask
  4428. * @param mask defines the mask to be tested
  4429. * @return whether or not one observer registered with the given mask is handeled
  4430. **/
  4431. hasSpecificMask(mask?: number): boolean;
  4432. }
  4433. }
  4434. declare module "babylonjs/Misc/filesInputStore" {
  4435. /**
  4436. * Class used to help managing file picking and drag'n'drop
  4437. * File Storage
  4438. */
  4439. export class FilesInputStore {
  4440. /**
  4441. * List of files ready to be loaded
  4442. */
  4443. static FilesToLoad: {
  4444. [key: string]: File;
  4445. };
  4446. }
  4447. }
  4448. declare module "babylonjs/Engines/constants" {
  4449. /** Defines the cross module used constants to avoid circular dependncies */
  4450. export class Constants {
  4451. /** Defines that alpha blending is disabled */
  4452. static readonly ALPHA_DISABLE: number;
  4453. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4454. static readonly ALPHA_ADD: number;
  4455. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4456. static readonly ALPHA_COMBINE: number;
  4457. /** Defines that alpha blending to DEST - SRC * DEST */
  4458. static readonly ALPHA_SUBTRACT: number;
  4459. /** Defines that alpha blending to SRC * DEST */
  4460. static readonly ALPHA_MULTIPLY: number;
  4461. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4462. static readonly ALPHA_MAXIMIZED: number;
  4463. /** Defines that alpha blending to SRC + DEST */
  4464. static readonly ALPHA_ONEONE: number;
  4465. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4466. static readonly ALPHA_PREMULTIPLIED: number;
  4467. /**
  4468. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4469. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4470. */
  4471. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4472. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4473. static readonly ALPHA_INTERPOLATE: number;
  4474. /**
  4475. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4476. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4477. */
  4478. static readonly ALPHA_SCREENMODE: number;
  4479. /** Defines that the ressource is not delayed*/
  4480. static readonly DELAYLOADSTATE_NONE: number;
  4481. /** Defines that the ressource was successfully delay loaded */
  4482. static readonly DELAYLOADSTATE_LOADED: number;
  4483. /** Defines that the ressource is currently delay loading */
  4484. static readonly DELAYLOADSTATE_LOADING: number;
  4485. /** Defines that the ressource is delayed and has not started loading */
  4486. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4487. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4488. static readonly NEVER: number;
  4489. /** 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 */
  4490. static readonly ALWAYS: number;
  4491. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4492. static readonly LESS: number;
  4493. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4494. static readonly EQUAL: number;
  4495. /** 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 */
  4496. static readonly LEQUAL: number;
  4497. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4498. static readonly GREATER: number;
  4499. /** 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 */
  4500. static readonly GEQUAL: number;
  4501. /** 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 */
  4502. static readonly NOTEQUAL: number;
  4503. /** Passed to stencilOperation to specify that stencil value must be kept */
  4504. static readonly KEEP: number;
  4505. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4506. static readonly REPLACE: number;
  4507. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4508. static readonly INCR: number;
  4509. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4510. static readonly DECR: number;
  4511. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4512. static readonly INVERT: number;
  4513. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4514. static readonly INCR_WRAP: number;
  4515. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4516. static readonly DECR_WRAP: number;
  4517. /** Texture is not repeating outside of 0..1 UVs */
  4518. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4519. /** Texture is repeating outside of 0..1 UVs */
  4520. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4521. /** Texture is repeating and mirrored */
  4522. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4523. /** ALPHA */
  4524. static readonly TEXTUREFORMAT_ALPHA: number;
  4525. /** LUMINANCE */
  4526. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4527. /** LUMINANCE_ALPHA */
  4528. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4529. /** RGB */
  4530. static readonly TEXTUREFORMAT_RGB: number;
  4531. /** RGBA */
  4532. static readonly TEXTUREFORMAT_RGBA: number;
  4533. /** RED */
  4534. static readonly TEXTUREFORMAT_RED: number;
  4535. /** RED (2nd reference) */
  4536. static readonly TEXTUREFORMAT_R: number;
  4537. /** RG */
  4538. static readonly TEXTUREFORMAT_RG: number;
  4539. /** RED_INTEGER */
  4540. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4541. /** RED_INTEGER (2nd reference) */
  4542. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4543. /** RG_INTEGER */
  4544. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4545. /** RGB_INTEGER */
  4546. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4547. /** RGBA_INTEGER */
  4548. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4549. /** UNSIGNED_BYTE */
  4550. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4551. /** UNSIGNED_BYTE (2nd reference) */
  4552. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4553. /** FLOAT */
  4554. static readonly TEXTURETYPE_FLOAT: number;
  4555. /** HALF_FLOAT */
  4556. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4557. /** BYTE */
  4558. static readonly TEXTURETYPE_BYTE: number;
  4559. /** SHORT */
  4560. static readonly TEXTURETYPE_SHORT: number;
  4561. /** UNSIGNED_SHORT */
  4562. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4563. /** INT */
  4564. static readonly TEXTURETYPE_INT: number;
  4565. /** UNSIGNED_INT */
  4566. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4567. /** UNSIGNED_SHORT_4_4_4_4 */
  4568. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4569. /** UNSIGNED_SHORT_5_5_5_1 */
  4570. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4571. /** UNSIGNED_SHORT_5_6_5 */
  4572. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4573. /** UNSIGNED_INT_2_10_10_10_REV */
  4574. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4575. /** UNSIGNED_INT_24_8 */
  4576. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4577. /** UNSIGNED_INT_10F_11F_11F_REV */
  4578. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4579. /** UNSIGNED_INT_5_9_9_9_REV */
  4580. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4581. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4582. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4583. /** nearest is mag = nearest and min = nearest and mip = linear */
  4584. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4585. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4586. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4587. /** Trilinear is mag = linear and min = linear and mip = linear */
  4588. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4589. /** nearest is mag = nearest and min = nearest and mip = linear */
  4590. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4591. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4592. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4593. /** Trilinear is mag = linear and min = linear and mip = linear */
  4594. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4595. /** mag = nearest and min = nearest and mip = nearest */
  4596. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4597. /** mag = nearest and min = linear and mip = nearest */
  4598. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4599. /** mag = nearest and min = linear and mip = linear */
  4600. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4601. /** mag = nearest and min = linear and mip = none */
  4602. static readonly TEXTURE_NEAREST_LINEAR: number;
  4603. /** mag = nearest and min = nearest and mip = none */
  4604. static readonly TEXTURE_NEAREST_NEAREST: number;
  4605. /** mag = linear and min = nearest and mip = nearest */
  4606. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4607. /** mag = linear and min = nearest and mip = linear */
  4608. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4609. /** mag = linear and min = linear and mip = none */
  4610. static readonly TEXTURE_LINEAR_LINEAR: number;
  4611. /** mag = linear and min = nearest and mip = none */
  4612. static readonly TEXTURE_LINEAR_NEAREST: number;
  4613. /** Explicit coordinates mode */
  4614. static readonly TEXTURE_EXPLICIT_MODE: number;
  4615. /** Spherical coordinates mode */
  4616. static readonly TEXTURE_SPHERICAL_MODE: number;
  4617. /** Planar coordinates mode */
  4618. static readonly TEXTURE_PLANAR_MODE: number;
  4619. /** Cubic coordinates mode */
  4620. static readonly TEXTURE_CUBIC_MODE: number;
  4621. /** Projection coordinates mode */
  4622. static readonly TEXTURE_PROJECTION_MODE: number;
  4623. /** Skybox coordinates mode */
  4624. static readonly TEXTURE_SKYBOX_MODE: number;
  4625. /** Inverse Cubic coordinates mode */
  4626. static readonly TEXTURE_INVCUBIC_MODE: number;
  4627. /** Equirectangular coordinates mode */
  4628. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4629. /** Equirectangular Fixed coordinates mode */
  4630. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4631. /** Equirectangular Fixed Mirrored coordinates mode */
  4632. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4633. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4634. static readonly SCALEMODE_FLOOR: number;
  4635. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4636. static readonly SCALEMODE_NEAREST: number;
  4637. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4638. static readonly SCALEMODE_CEILING: number;
  4639. /**
  4640. * The dirty texture flag value
  4641. */
  4642. static readonly MATERIAL_TextureDirtyFlag: number;
  4643. /**
  4644. * The dirty light flag value
  4645. */
  4646. static readonly MATERIAL_LightDirtyFlag: number;
  4647. /**
  4648. * The dirty fresnel flag value
  4649. */
  4650. static readonly MATERIAL_FresnelDirtyFlag: number;
  4651. /**
  4652. * The dirty attribute flag value
  4653. */
  4654. static readonly MATERIAL_AttributesDirtyFlag: number;
  4655. /**
  4656. * The dirty misc flag value
  4657. */
  4658. static readonly MATERIAL_MiscDirtyFlag: number;
  4659. /**
  4660. * The all dirty flag value
  4661. */
  4662. static readonly MATERIAL_AllDirtyFlag: number;
  4663. /**
  4664. * Returns the triangle fill mode
  4665. */
  4666. static readonly MATERIAL_TriangleFillMode: number;
  4667. /**
  4668. * Returns the wireframe mode
  4669. */
  4670. static readonly MATERIAL_WireFrameFillMode: number;
  4671. /**
  4672. * Returns the point fill mode
  4673. */
  4674. static readonly MATERIAL_PointFillMode: number;
  4675. /**
  4676. * Returns the point list draw mode
  4677. */
  4678. static readonly MATERIAL_PointListDrawMode: number;
  4679. /**
  4680. * Returns the line list draw mode
  4681. */
  4682. static readonly MATERIAL_LineListDrawMode: number;
  4683. /**
  4684. * Returns the line loop draw mode
  4685. */
  4686. static readonly MATERIAL_LineLoopDrawMode: number;
  4687. /**
  4688. * Returns the line strip draw mode
  4689. */
  4690. static readonly MATERIAL_LineStripDrawMode: number;
  4691. /**
  4692. * Returns the triangle strip draw mode
  4693. */
  4694. static readonly MATERIAL_TriangleStripDrawMode: number;
  4695. /**
  4696. * Returns the triangle fan draw mode
  4697. */
  4698. static readonly MATERIAL_TriangleFanDrawMode: number;
  4699. /**
  4700. * Stores the clock-wise side orientation
  4701. */
  4702. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4703. /**
  4704. * Stores the counter clock-wise side orientation
  4705. */
  4706. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4707. /**
  4708. * Nothing
  4709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4710. */
  4711. static readonly ACTION_NothingTrigger: number;
  4712. /**
  4713. * On pick
  4714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4715. */
  4716. static readonly ACTION_OnPickTrigger: number;
  4717. /**
  4718. * On left pick
  4719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4720. */
  4721. static readonly ACTION_OnLeftPickTrigger: number;
  4722. /**
  4723. * On right pick
  4724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4725. */
  4726. static readonly ACTION_OnRightPickTrigger: number;
  4727. /**
  4728. * On center pick
  4729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4730. */
  4731. static readonly ACTION_OnCenterPickTrigger: number;
  4732. /**
  4733. * On pick down
  4734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4735. */
  4736. static readonly ACTION_OnPickDownTrigger: number;
  4737. /**
  4738. * On double pick
  4739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4740. */
  4741. static readonly ACTION_OnDoublePickTrigger: number;
  4742. /**
  4743. * On pick up
  4744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4745. */
  4746. static readonly ACTION_OnPickUpTrigger: number;
  4747. /**
  4748. * On pick out.
  4749. * This trigger will only be raised if you also declared a OnPickDown
  4750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4751. */
  4752. static readonly ACTION_OnPickOutTrigger: number;
  4753. /**
  4754. * On long press
  4755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4756. */
  4757. static readonly ACTION_OnLongPressTrigger: number;
  4758. /**
  4759. * On pointer over
  4760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4761. */
  4762. static readonly ACTION_OnPointerOverTrigger: number;
  4763. /**
  4764. * On pointer out
  4765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4766. */
  4767. static readonly ACTION_OnPointerOutTrigger: number;
  4768. /**
  4769. * On every frame
  4770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4771. */
  4772. static readonly ACTION_OnEveryFrameTrigger: number;
  4773. /**
  4774. * On intersection enter
  4775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4776. */
  4777. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4778. /**
  4779. * On intersection exit
  4780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4781. */
  4782. static readonly ACTION_OnIntersectionExitTrigger: number;
  4783. /**
  4784. * On key down
  4785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4786. */
  4787. static readonly ACTION_OnKeyDownTrigger: number;
  4788. /**
  4789. * On key up
  4790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4791. */
  4792. static readonly ACTION_OnKeyUpTrigger: number;
  4793. /**
  4794. * Billboard mode will only apply to Y axis
  4795. */
  4796. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4797. /**
  4798. * Billboard mode will apply to all axes
  4799. */
  4800. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4801. /**
  4802. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4803. */
  4804. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4805. /**
  4806. * Gets or sets base Assets URL
  4807. */
  4808. static readonly PARTICLES_BaseAssetsUrl: string;
  4809. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4810. * Test order :
  4811. * Is the bounding sphere outside the frustum ?
  4812. * If not, are the bounding box vertices outside the frustum ?
  4813. * It not, then the cullable object is in the frustum.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4816. /** Culling strategy : Bounding Sphere Only.
  4817. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4818. * It's also less accurate than the standard because some not visible objects can still be selected.
  4819. * Test : is the bounding sphere outside the frustum ?
  4820. * If not, then the cullable object is in the frustum.
  4821. */
  4822. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4823. /** Culling strategy : Optimistic Inclusion.
  4824. * This in an inclusion test first, then the standard exclusion test.
  4825. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4826. * 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.
  4827. * Anyway, it's as accurate as the standard strategy.
  4828. * Test :
  4829. * Is the cullable object bounding sphere center in the frustum ?
  4830. * If not, apply the default culling strategy.
  4831. */
  4832. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4833. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4834. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4835. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4836. * 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.
  4837. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4838. * Test :
  4839. * Is the cullable object bounding sphere center in the frustum ?
  4840. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4841. */
  4842. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4843. /**
  4844. * No logging while loading
  4845. */
  4846. static readonly SCENELOADER_NO_LOGGING: number;
  4847. /**
  4848. * Minimal logging while loading
  4849. */
  4850. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4851. /**
  4852. * Summary logging while loading
  4853. */
  4854. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4855. /**
  4856. * Detailled logging while loading
  4857. */
  4858. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4859. }
  4860. }
  4861. declare module "babylonjs/Misc/domManagement" {
  4862. /**
  4863. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4864. * Babylon.js
  4865. */
  4866. export class DomManagement {
  4867. /**
  4868. * Checks if the window object exists
  4869. * @returns true if the window object exists
  4870. */
  4871. static IsWindowObjectExist(): boolean;
  4872. /**
  4873. * Extracts text content from a DOM element hierarchy
  4874. * @param element defines the root element
  4875. * @returns a string
  4876. */
  4877. static GetDOMTextContent(element: HTMLElement): string;
  4878. }
  4879. }
  4880. declare module "babylonjs/Misc/logger" {
  4881. /**
  4882. * Logger used througouht the application to allow configuration of
  4883. * the log level required for the messages.
  4884. */
  4885. export class Logger {
  4886. /**
  4887. * No log
  4888. */
  4889. static readonly NoneLogLevel: number;
  4890. /**
  4891. * Only message logs
  4892. */
  4893. static readonly MessageLogLevel: number;
  4894. /**
  4895. * Only warning logs
  4896. */
  4897. static readonly WarningLogLevel: number;
  4898. /**
  4899. * Only error logs
  4900. */
  4901. static readonly ErrorLogLevel: number;
  4902. /**
  4903. * All logs
  4904. */
  4905. static readonly AllLogLevel: number;
  4906. private static _LogCache;
  4907. /**
  4908. * Gets a value indicating the number of loading errors
  4909. * @ignorenaming
  4910. */
  4911. static errorsCount: number;
  4912. /**
  4913. * Callback called when a new log is added
  4914. */
  4915. static OnNewCacheEntry: (entry: string) => void;
  4916. private static _AddLogEntry;
  4917. private static _FormatMessage;
  4918. private static _LogDisabled;
  4919. private static _LogEnabled;
  4920. private static _WarnDisabled;
  4921. private static _WarnEnabled;
  4922. private static _ErrorDisabled;
  4923. private static _ErrorEnabled;
  4924. /**
  4925. * Log a message to the console
  4926. */
  4927. static Log: (message: string) => void;
  4928. /**
  4929. * Write a warning message to the console
  4930. */
  4931. static Warn: (message: string) => void;
  4932. /**
  4933. * Write an error message to the console
  4934. */
  4935. static Error: (message: string) => void;
  4936. /**
  4937. * Gets current log cache (list of logs)
  4938. */
  4939. static readonly LogCache: string;
  4940. /**
  4941. * Clears the log cache
  4942. */
  4943. static ClearLogCache(): void;
  4944. /**
  4945. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4946. */
  4947. static LogLevels: number;
  4948. }
  4949. }
  4950. declare module "babylonjs/Misc/typeStore" {
  4951. /** @hidden */
  4952. export class _TypeStore {
  4953. /** @hidden */
  4954. static RegisteredTypes: {
  4955. [key: string]: Object;
  4956. };
  4957. /** @hidden */
  4958. static GetClass(fqdn: string): any;
  4959. }
  4960. }
  4961. declare module "babylonjs/Misc/deepCopier" {
  4962. /**
  4963. * Class containing a set of static utilities functions for deep copy.
  4964. */
  4965. export class DeepCopier {
  4966. /**
  4967. * Tries to copy an object by duplicating every property
  4968. * @param source defines the source object
  4969. * @param destination defines the target object
  4970. * @param doNotCopyList defines a list of properties to avoid
  4971. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4972. */
  4973. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4974. }
  4975. }
  4976. declare module "babylonjs/Misc/precisionDate" {
  4977. /**
  4978. * Class containing a set of static utilities functions for precision date
  4979. */
  4980. export class PrecisionDate {
  4981. /**
  4982. * Gets either window.performance.now() if supported or Date.now() else
  4983. */
  4984. static readonly Now: number;
  4985. }
  4986. }
  4987. declare module "babylonjs/Misc/devTools" {
  4988. /** @hidden */
  4989. export class _DevTools {
  4990. static WarnImport(name: string): string;
  4991. }
  4992. }
  4993. declare module "babylonjs/Misc/webRequest" {
  4994. /**
  4995. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4996. */
  4997. export class WebRequest {
  4998. private _xhr;
  4999. /**
  5000. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5001. * i.e. when loading files, where the server/service expects an Authorization header
  5002. */
  5003. static CustomRequestHeaders: {
  5004. [key: string]: string;
  5005. };
  5006. /**
  5007. * Add callback functions in this array to update all the requests before they get sent to the network
  5008. */
  5009. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5010. private _injectCustomRequestHeaders;
  5011. /**
  5012. * Gets or sets a function to be called when loading progress changes
  5013. */
  5014. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5015. /**
  5016. * Returns client's state
  5017. */
  5018. readonly readyState: number;
  5019. /**
  5020. * Returns client's status
  5021. */
  5022. readonly status: number;
  5023. /**
  5024. * Returns client's status as a text
  5025. */
  5026. readonly statusText: string;
  5027. /**
  5028. * Returns client's response
  5029. */
  5030. readonly response: any;
  5031. /**
  5032. * Returns client's response url
  5033. */
  5034. readonly responseURL: string;
  5035. /**
  5036. * Returns client's response as text
  5037. */
  5038. readonly responseText: string;
  5039. /**
  5040. * Gets or sets the expected response type
  5041. */
  5042. responseType: XMLHttpRequestResponseType;
  5043. /** @hidden */
  5044. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5045. /** @hidden */
  5046. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5047. /**
  5048. * Cancels any network activity
  5049. */
  5050. abort(): void;
  5051. /**
  5052. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5053. * @param body defines an optional request body
  5054. */
  5055. send(body?: Document | BodyInit | null): void;
  5056. /**
  5057. * Sets the request method, request URL
  5058. * @param method defines the method to use (GET, POST, etc..)
  5059. * @param url defines the url to connect with
  5060. */
  5061. open(method: string, url: string): void;
  5062. }
  5063. }
  5064. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5065. /**
  5066. * Class used to evalaute queries containing `and` and `or` operators
  5067. */
  5068. export class AndOrNotEvaluator {
  5069. /**
  5070. * Evaluate a query
  5071. * @param query defines the query to evaluate
  5072. * @param evaluateCallback defines the callback used to filter result
  5073. * @returns true if the query matches
  5074. */
  5075. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5076. private static _HandleParenthesisContent;
  5077. private static _SimplifyNegation;
  5078. }
  5079. }
  5080. declare module "babylonjs/Misc/tags" {
  5081. /**
  5082. * Class used to store custom tags
  5083. */
  5084. export class Tags {
  5085. /**
  5086. * Adds support for tags on the given object
  5087. * @param obj defines the object to use
  5088. */
  5089. static EnableFor(obj: any): void;
  5090. /**
  5091. * Removes tags support
  5092. * @param obj defines the object to use
  5093. */
  5094. static DisableFor(obj: any): void;
  5095. /**
  5096. * Gets a boolean indicating if the given object has tags
  5097. * @param obj defines the object to use
  5098. * @returns a boolean
  5099. */
  5100. static HasTags(obj: any): boolean;
  5101. /**
  5102. * Gets the tags available on a given object
  5103. * @param obj defines the object to use
  5104. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5105. * @returns the tags
  5106. */
  5107. static GetTags(obj: any, asString?: boolean): any;
  5108. /**
  5109. * Adds tags to an object
  5110. * @param obj defines the object to use
  5111. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5112. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5113. */
  5114. static AddTagsTo(obj: any, tagsString: string): void;
  5115. /**
  5116. * @hidden
  5117. */
  5118. static _AddTagTo(obj: any, tag: string): void;
  5119. /**
  5120. * Removes specific tags from a specific object
  5121. * @param obj defines the object to use
  5122. * @param tagsString defines the tags to remove
  5123. */
  5124. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5125. /**
  5126. * @hidden
  5127. */
  5128. static _RemoveTagFrom(obj: any, tag: string): void;
  5129. /**
  5130. * Defines if tags hosted on an object match a given query
  5131. * @param obj defines the object to use
  5132. * @param tagsQuery defines the tag query
  5133. * @returns a boolean
  5134. */
  5135. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5136. }
  5137. }
  5138. declare module "babylonjs/Materials/materialDefines" {
  5139. /**
  5140. * Manages the defines for the Material
  5141. */
  5142. export class MaterialDefines {
  5143. private _keys;
  5144. private _isDirty;
  5145. /** @hidden */
  5146. _renderId: number;
  5147. /** @hidden */
  5148. _areLightsDirty: boolean;
  5149. /** @hidden */
  5150. _areAttributesDirty: boolean;
  5151. /** @hidden */
  5152. _areTexturesDirty: boolean;
  5153. /** @hidden */
  5154. _areFresnelDirty: boolean;
  5155. /** @hidden */
  5156. _areMiscDirty: boolean;
  5157. /** @hidden */
  5158. _areImageProcessingDirty: boolean;
  5159. /** @hidden */
  5160. _normals: boolean;
  5161. /** @hidden */
  5162. _uvs: boolean;
  5163. /** @hidden */
  5164. _needNormals: boolean;
  5165. /** @hidden */
  5166. _needUVs: boolean;
  5167. /**
  5168. * Specifies if the material needs to be re-calculated
  5169. */
  5170. readonly isDirty: boolean;
  5171. /**
  5172. * Marks the material to indicate that it has been re-calculated
  5173. */
  5174. markAsProcessed(): void;
  5175. /**
  5176. * Marks the material to indicate that it needs to be re-calculated
  5177. */
  5178. markAsUnprocessed(): void;
  5179. /**
  5180. * Marks the material to indicate all of its defines need to be re-calculated
  5181. */
  5182. markAllAsDirty(): void;
  5183. /**
  5184. * Marks the material to indicate that image processing needs to be re-calculated
  5185. */
  5186. markAsImageProcessingDirty(): void;
  5187. /**
  5188. * Marks the material to indicate the lights need to be re-calculated
  5189. */
  5190. markAsLightDirty(): void;
  5191. /**
  5192. * Marks the attribute state as changed
  5193. */
  5194. markAsAttributesDirty(): void;
  5195. /**
  5196. * Marks the texture state as changed
  5197. */
  5198. markAsTexturesDirty(): void;
  5199. /**
  5200. * Marks the fresnel state as changed
  5201. */
  5202. markAsFresnelDirty(): void;
  5203. /**
  5204. * Marks the misc state as changed
  5205. */
  5206. markAsMiscDirty(): void;
  5207. /**
  5208. * Rebuilds the material defines
  5209. */
  5210. rebuild(): void;
  5211. /**
  5212. * Specifies if two material defines are equal
  5213. * @param other - A material define instance to compare to
  5214. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5215. */
  5216. isEqual(other: MaterialDefines): boolean;
  5217. /**
  5218. * Clones this instance's defines to another instance
  5219. * @param other - material defines to clone values to
  5220. */
  5221. cloneTo(other: MaterialDefines): void;
  5222. /**
  5223. * Resets the material define values
  5224. */
  5225. reset(): void;
  5226. /**
  5227. * Converts the material define values to a string
  5228. * @returns - String of material define information
  5229. */
  5230. toString(): string;
  5231. }
  5232. }
  5233. declare module "babylonjs/Engines/IPipelineContext" {
  5234. /**
  5235. * Class used to store and describe the pipeline context associated with an effect
  5236. */
  5237. export interface IPipelineContext {
  5238. /**
  5239. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5240. */
  5241. isAsync: boolean;
  5242. /**
  5243. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5244. */
  5245. isReady: boolean;
  5246. }
  5247. }
  5248. declare module "babylonjs/Meshes/dataBuffer" {
  5249. /**
  5250. * Class used to store gfx data (like WebGLBuffer)
  5251. */
  5252. export class DataBuffer {
  5253. /**
  5254. * Gets or sets the number of objects referencing this buffer
  5255. */
  5256. references: number;
  5257. /** Gets or sets the size of the underlying buffer */
  5258. capacity: number;
  5259. /**
  5260. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5261. */
  5262. is32Bits: boolean;
  5263. /**
  5264. * Gets the underlying buffer
  5265. */
  5266. readonly underlyingResource: any;
  5267. }
  5268. }
  5269. declare module "babylonjs/Misc/performanceMonitor" {
  5270. /**
  5271. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5272. */
  5273. export class PerformanceMonitor {
  5274. private _enabled;
  5275. private _rollingFrameTime;
  5276. private _lastFrameTimeMs;
  5277. /**
  5278. * constructor
  5279. * @param frameSampleSize The number of samples required to saturate the sliding window
  5280. */
  5281. constructor(frameSampleSize?: number);
  5282. /**
  5283. * Samples current frame
  5284. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5285. */
  5286. sampleFrame(timeMs?: number): void;
  5287. /**
  5288. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5289. */
  5290. readonly averageFrameTime: number;
  5291. /**
  5292. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5293. */
  5294. readonly averageFrameTimeVariance: number;
  5295. /**
  5296. * Returns the frame time of the most recent frame
  5297. */
  5298. readonly instantaneousFrameTime: number;
  5299. /**
  5300. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5301. */
  5302. readonly averageFPS: number;
  5303. /**
  5304. * Returns the average framerate in frames per second using the most recent frame time
  5305. */
  5306. readonly instantaneousFPS: number;
  5307. /**
  5308. * Returns true if enough samples have been taken to completely fill the sliding window
  5309. */
  5310. readonly isSaturated: boolean;
  5311. /**
  5312. * Enables contributions to the sliding window sample set
  5313. */
  5314. enable(): void;
  5315. /**
  5316. * Disables contributions to the sliding window sample set
  5317. * Samples will not be interpolated over the disabled period
  5318. */
  5319. disable(): void;
  5320. /**
  5321. * Returns true if sampling is enabled
  5322. */
  5323. readonly isEnabled: boolean;
  5324. /**
  5325. * Resets performance monitor
  5326. */
  5327. reset(): void;
  5328. }
  5329. /**
  5330. * RollingAverage
  5331. *
  5332. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5333. */
  5334. export class RollingAverage {
  5335. /**
  5336. * Current average
  5337. */
  5338. average: number;
  5339. /**
  5340. * Current variance
  5341. */
  5342. variance: number;
  5343. protected _samples: Array<number>;
  5344. protected _sampleCount: number;
  5345. protected _pos: number;
  5346. protected _m2: number;
  5347. /**
  5348. * constructor
  5349. * @param length The number of samples required to saturate the sliding window
  5350. */
  5351. constructor(length: number);
  5352. /**
  5353. * Adds a sample to the sample set
  5354. * @param v The sample value
  5355. */
  5356. add(v: number): void;
  5357. /**
  5358. * Returns previously added values or null if outside of history or outside the sliding window domain
  5359. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5360. * @return Value previously recorded with add() or null if outside of range
  5361. */
  5362. history(i: number): number;
  5363. /**
  5364. * Returns true if enough samples have been taken to completely fill the sliding window
  5365. * @return true if sample-set saturated
  5366. */
  5367. isSaturated(): boolean;
  5368. /**
  5369. * Resets the rolling average (equivalent to 0 samples taken so far)
  5370. */
  5371. reset(): void;
  5372. /**
  5373. * Wraps a value around the sample range boundaries
  5374. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5375. * @return Wrapped position in sample range
  5376. */
  5377. protected _wrapPosition(i: number): number;
  5378. }
  5379. }
  5380. declare module "babylonjs/Misc/stringDictionary" {
  5381. import { Nullable } from "babylonjs/types";
  5382. /**
  5383. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5384. * The underlying implementation relies on an associative array to ensure the best performances.
  5385. * The value can be anything including 'null' but except 'undefined'
  5386. */
  5387. export class StringDictionary<T> {
  5388. /**
  5389. * This will clear this dictionary and copy the content from the 'source' one.
  5390. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5391. * @param source the dictionary to take the content from and copy to this dictionary
  5392. */
  5393. copyFrom(source: StringDictionary<T>): void;
  5394. /**
  5395. * Get a value based from its key
  5396. * @param key the given key to get the matching value from
  5397. * @return the value if found, otherwise undefined is returned
  5398. */
  5399. get(key: string): T | undefined;
  5400. /**
  5401. * Get a value from its key or add it if it doesn't exist.
  5402. * This method will ensure you that a given key/data will be present in the dictionary.
  5403. * @param key the given key to get the matching value from
  5404. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5405. * The factory will only be invoked if there's no data for the given key.
  5406. * @return the value corresponding to the key.
  5407. */
  5408. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5409. /**
  5410. * Get a value from its key if present in the dictionary otherwise add it
  5411. * @param key the key to get the value from
  5412. * @param val if there's no such key/value pair in the dictionary add it with this value
  5413. * @return the value corresponding to the key
  5414. */
  5415. getOrAdd(key: string, val: T): T;
  5416. /**
  5417. * Check if there's a given key in the dictionary
  5418. * @param key the key to check for
  5419. * @return true if the key is present, false otherwise
  5420. */
  5421. contains(key: string): boolean;
  5422. /**
  5423. * Add a new key and its corresponding value
  5424. * @param key the key to add
  5425. * @param value the value corresponding to the key
  5426. * @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
  5427. */
  5428. add(key: string, value: T): boolean;
  5429. /**
  5430. * Update a specific value associated to a key
  5431. * @param key defines the key to use
  5432. * @param value defines the value to store
  5433. * @returns true if the value was updated (or false if the key was not found)
  5434. */
  5435. set(key: string, value: T): boolean;
  5436. /**
  5437. * Get the element of the given key and remove it from the dictionary
  5438. * @param key defines the key to search
  5439. * @returns the value associated with the key or null if not found
  5440. */
  5441. getAndRemove(key: string): Nullable<T>;
  5442. /**
  5443. * Remove a key/value from the dictionary.
  5444. * @param key the key to remove
  5445. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5446. */
  5447. remove(key: string): boolean;
  5448. /**
  5449. * Clear the whole content of the dictionary
  5450. */
  5451. clear(): void;
  5452. /**
  5453. * Gets the current count
  5454. */
  5455. readonly count: number;
  5456. /**
  5457. * Execute a callback on each key/val of the dictionary.
  5458. * Note that you can remove any element in this dictionary in the callback implementation
  5459. * @param callback the callback to execute on a given key/value pair
  5460. */
  5461. forEach(callback: (key: string, val: T) => void): void;
  5462. /**
  5463. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5464. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5465. * Note that you can remove any element in this dictionary in the callback implementation
  5466. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5467. * @returns the first item
  5468. */
  5469. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5470. private _count;
  5471. private _data;
  5472. }
  5473. }
  5474. declare module "babylonjs/Misc/promise" {
  5475. /**
  5476. * Helper class that provides a small promise polyfill
  5477. */
  5478. export class PromisePolyfill {
  5479. /**
  5480. * Static function used to check if the polyfill is required
  5481. * If this is the case then the function will inject the polyfill to window.Promise
  5482. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5483. */
  5484. static Apply(force?: boolean): void;
  5485. }
  5486. }
  5487. declare module "babylonjs/Meshes/buffer" {
  5488. import { Nullable, DataArray } from "babylonjs/types";
  5489. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  5490. /**
  5491. * Class used to store data that will be store in GPU memory
  5492. */
  5493. export class Buffer {
  5494. private _engine;
  5495. private _buffer;
  5496. /** @hidden */
  5497. _data: Nullable<DataArray>;
  5498. private _updatable;
  5499. private _instanced;
  5500. /**
  5501. * Gets the byte stride.
  5502. */
  5503. readonly byteStride: number;
  5504. /**
  5505. * Constructor
  5506. * @param engine the engine
  5507. * @param data the data to use for this buffer
  5508. * @param updatable whether the data is updatable
  5509. * @param stride the stride (optional)
  5510. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5511. * @param instanced whether the buffer is instanced (optional)
  5512. * @param useBytes set to true if the stride in in bytes (optional)
  5513. */
  5514. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5515. /**
  5516. * Create a new VertexBuffer based on the current buffer
  5517. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5518. * @param offset defines offset in the buffer (0 by default)
  5519. * @param size defines the size in floats of attributes (position is 3 for instance)
  5520. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5521. * @param instanced defines if the vertex buffer contains indexed data
  5522. * @param useBytes defines if the offset and stride are in bytes
  5523. * @returns the new vertex buffer
  5524. */
  5525. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5526. /**
  5527. * Gets a boolean indicating if the Buffer is updatable?
  5528. * @returns true if the buffer is updatable
  5529. */
  5530. isUpdatable(): boolean;
  5531. /**
  5532. * Gets current buffer's data
  5533. * @returns a DataArray or null
  5534. */
  5535. getData(): Nullable<DataArray>;
  5536. /**
  5537. * Gets underlying native buffer
  5538. * @returns underlying native buffer
  5539. */
  5540. getBuffer(): Nullable<DataBuffer>;
  5541. /**
  5542. * Gets the stride in float32 units (i.e. byte stride / 4).
  5543. * May not be an integer if the byte stride is not divisible by 4.
  5544. * DEPRECATED. Use byteStride instead.
  5545. * @returns the stride in float32 units
  5546. */
  5547. getStrideSize(): number;
  5548. /**
  5549. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5550. * @param data defines the data to store
  5551. */
  5552. create(data?: Nullable<DataArray>): void;
  5553. /** @hidden */
  5554. _rebuild(): void;
  5555. /**
  5556. * Update current buffer data
  5557. * @param data defines the data to store
  5558. */
  5559. update(data: DataArray): void;
  5560. /**
  5561. * Updates the data directly.
  5562. * @param data the new data
  5563. * @param offset the new offset
  5564. * @param vertexCount the vertex count (optional)
  5565. * @param useBytes set to true if the offset is in bytes
  5566. */
  5567. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5568. /**
  5569. * Release all resources
  5570. */
  5571. dispose(): void;
  5572. }
  5573. /**
  5574. * Specialized buffer used to store vertex data
  5575. */
  5576. export class VertexBuffer {
  5577. /** @hidden */
  5578. _buffer: Buffer;
  5579. private _kind;
  5580. private _size;
  5581. private _ownsBuffer;
  5582. private _instanced;
  5583. private _instanceDivisor;
  5584. /**
  5585. * The byte type.
  5586. */
  5587. static readonly BYTE: number;
  5588. /**
  5589. * The unsigned byte type.
  5590. */
  5591. static readonly UNSIGNED_BYTE: number;
  5592. /**
  5593. * The short type.
  5594. */
  5595. static readonly SHORT: number;
  5596. /**
  5597. * The unsigned short type.
  5598. */
  5599. static readonly UNSIGNED_SHORT: number;
  5600. /**
  5601. * The integer type.
  5602. */
  5603. static readonly INT: number;
  5604. /**
  5605. * The unsigned integer type.
  5606. */
  5607. static readonly UNSIGNED_INT: number;
  5608. /**
  5609. * The float type.
  5610. */
  5611. static readonly FLOAT: number;
  5612. /**
  5613. * Gets or sets the instance divisor when in instanced mode
  5614. */
  5615. instanceDivisor: number;
  5616. /**
  5617. * Gets the byte stride.
  5618. */
  5619. readonly byteStride: number;
  5620. /**
  5621. * Gets the byte offset.
  5622. */
  5623. readonly byteOffset: number;
  5624. /**
  5625. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5626. */
  5627. readonly normalized: boolean;
  5628. /**
  5629. * Gets the data type of each component in the array.
  5630. */
  5631. readonly type: number;
  5632. /**
  5633. * Constructor
  5634. * @param engine the engine
  5635. * @param data the data to use for this vertex buffer
  5636. * @param kind the vertex buffer kind
  5637. * @param updatable whether the data is updatable
  5638. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5639. * @param stride the stride (optional)
  5640. * @param instanced whether the buffer is instanced (optional)
  5641. * @param offset the offset of the data (optional)
  5642. * @param size the number of components (optional)
  5643. * @param type the type of the component (optional)
  5644. * @param normalized whether the data contains normalized data (optional)
  5645. * @param useBytes set to true if stride and offset are in bytes (optional)
  5646. */
  5647. 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);
  5648. /** @hidden */
  5649. _rebuild(): void;
  5650. /**
  5651. * Returns the kind of the VertexBuffer (string)
  5652. * @returns a string
  5653. */
  5654. getKind(): string;
  5655. /**
  5656. * Gets a boolean indicating if the VertexBuffer is updatable?
  5657. * @returns true if the buffer is updatable
  5658. */
  5659. isUpdatable(): boolean;
  5660. /**
  5661. * Gets current buffer's data
  5662. * @returns a DataArray or null
  5663. */
  5664. getData(): Nullable<DataArray>;
  5665. /**
  5666. * Gets underlying native buffer
  5667. * @returns underlying native buffer
  5668. */
  5669. getBuffer(): Nullable<DataBuffer>;
  5670. /**
  5671. * Gets the stride in float32 units (i.e. byte stride / 4).
  5672. * May not be an integer if the byte stride is not divisible by 4.
  5673. * DEPRECATED. Use byteStride instead.
  5674. * @returns the stride in float32 units
  5675. */
  5676. getStrideSize(): number;
  5677. /**
  5678. * Returns the offset as a multiple of the type byte length.
  5679. * DEPRECATED. Use byteOffset instead.
  5680. * @returns the offset in bytes
  5681. */
  5682. getOffset(): number;
  5683. /**
  5684. * Returns the number of components per vertex attribute (integer)
  5685. * @returns the size in float
  5686. */
  5687. getSize(): number;
  5688. /**
  5689. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5690. * @returns true if this buffer is instanced
  5691. */
  5692. getIsInstanced(): boolean;
  5693. /**
  5694. * Returns the instancing divisor, zero for non-instanced (integer).
  5695. * @returns a number
  5696. */
  5697. getInstanceDivisor(): number;
  5698. /**
  5699. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5700. * @param data defines the data to store
  5701. */
  5702. create(data?: DataArray): void;
  5703. /**
  5704. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5705. * This function will create a new buffer if the current one is not updatable
  5706. * @param data defines the data to store
  5707. */
  5708. update(data: DataArray): void;
  5709. /**
  5710. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5711. * Returns the directly updated WebGLBuffer.
  5712. * @param data the new data
  5713. * @param offset the new offset
  5714. * @param useBytes set to true if the offset is in bytes
  5715. */
  5716. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5717. /**
  5718. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5719. */
  5720. dispose(): void;
  5721. /**
  5722. * Enumerates each value of this vertex buffer as numbers.
  5723. * @param count the number of values to enumerate
  5724. * @param callback the callback function called for each value
  5725. */
  5726. forEach(count: number, callback: (value: number, index: number) => void): void;
  5727. /**
  5728. * Positions
  5729. */
  5730. static readonly PositionKind: string;
  5731. /**
  5732. * Normals
  5733. */
  5734. static readonly NormalKind: string;
  5735. /**
  5736. * Tangents
  5737. */
  5738. static readonly TangentKind: string;
  5739. /**
  5740. * Texture coordinates
  5741. */
  5742. static readonly UVKind: string;
  5743. /**
  5744. * Texture coordinates 2
  5745. */
  5746. static readonly UV2Kind: string;
  5747. /**
  5748. * Texture coordinates 3
  5749. */
  5750. static readonly UV3Kind: string;
  5751. /**
  5752. * Texture coordinates 4
  5753. */
  5754. static readonly UV4Kind: string;
  5755. /**
  5756. * Texture coordinates 5
  5757. */
  5758. static readonly UV5Kind: string;
  5759. /**
  5760. * Texture coordinates 6
  5761. */
  5762. static readonly UV6Kind: string;
  5763. /**
  5764. * Colors
  5765. */
  5766. static readonly ColorKind: string;
  5767. /**
  5768. * Matrix indices (for bones)
  5769. */
  5770. static readonly MatricesIndicesKind: string;
  5771. /**
  5772. * Matrix weights (for bones)
  5773. */
  5774. static readonly MatricesWeightsKind: string;
  5775. /**
  5776. * Additional matrix indices (for bones)
  5777. */
  5778. static readonly MatricesIndicesExtraKind: string;
  5779. /**
  5780. * Additional matrix weights (for bones)
  5781. */
  5782. static readonly MatricesWeightsExtraKind: string;
  5783. /**
  5784. * Deduces the stride given a kind.
  5785. * @param kind The kind string to deduce
  5786. * @returns The deduced stride
  5787. */
  5788. static DeduceStride(kind: string): number;
  5789. /**
  5790. * Gets the byte length of the given type.
  5791. * @param type the type
  5792. * @returns the number of bytes
  5793. */
  5794. static GetTypeByteLength(type: number): number;
  5795. /**
  5796. * Enumerates each value of the given parameters as numbers.
  5797. * @param data the data to enumerate
  5798. * @param byteOffset the byte offset of the data
  5799. * @param byteStride the byte stride of the data
  5800. * @param componentCount the number of components per element
  5801. * @param componentType the type of the component
  5802. * @param count the total number of components
  5803. * @param normalized whether the data is normalized
  5804. * @param callback the callback function called for each value
  5805. */
  5806. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5807. private static _GetFloatValue;
  5808. }
  5809. }
  5810. declare module "babylonjs/Maths/sphericalPolynomial" {
  5811. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5812. /**
  5813. * Class representing spherical polynomial coefficients to the 3rd degree
  5814. */
  5815. export class SphericalPolynomial {
  5816. /**
  5817. * The x coefficients of the spherical polynomial
  5818. */
  5819. x: Vector3;
  5820. /**
  5821. * The y coefficients of the spherical polynomial
  5822. */
  5823. y: Vector3;
  5824. /**
  5825. * The z coefficients of the spherical polynomial
  5826. */
  5827. z: Vector3;
  5828. /**
  5829. * The xx coefficients of the spherical polynomial
  5830. */
  5831. xx: Vector3;
  5832. /**
  5833. * The yy coefficients of the spherical polynomial
  5834. */
  5835. yy: Vector3;
  5836. /**
  5837. * The zz coefficients of the spherical polynomial
  5838. */
  5839. zz: Vector3;
  5840. /**
  5841. * The xy coefficients of the spherical polynomial
  5842. */
  5843. xy: Vector3;
  5844. /**
  5845. * The yz coefficients of the spherical polynomial
  5846. */
  5847. yz: Vector3;
  5848. /**
  5849. * The zx coefficients of the spherical polynomial
  5850. */
  5851. zx: Vector3;
  5852. /**
  5853. * Adds an ambient color to the spherical polynomial
  5854. * @param color the color to add
  5855. */
  5856. addAmbient(color: Color3): void;
  5857. /**
  5858. * Scales the spherical polynomial by the given amount
  5859. * @param scale the amount to scale
  5860. */
  5861. scale(scale: number): void;
  5862. /**
  5863. * Gets the spherical polynomial from harmonics
  5864. * @param harmonics the spherical harmonics
  5865. * @returns the spherical polynomial
  5866. */
  5867. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5868. /**
  5869. * Constructs a spherical polynomial from an array.
  5870. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5871. * @returns the spherical polynomial
  5872. */
  5873. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5874. }
  5875. /**
  5876. * Class representing spherical harmonics coefficients to the 3rd degree
  5877. */
  5878. export class SphericalHarmonics {
  5879. /**
  5880. * The l0,0 coefficients of the spherical harmonics
  5881. */
  5882. l00: Vector3;
  5883. /**
  5884. * The l1,-1 coefficients of the spherical harmonics
  5885. */
  5886. l1_1: Vector3;
  5887. /**
  5888. * The l1,0 coefficients of the spherical harmonics
  5889. */
  5890. l10: Vector3;
  5891. /**
  5892. * The l1,1 coefficients of the spherical harmonics
  5893. */
  5894. l11: Vector3;
  5895. /**
  5896. * The l2,-2 coefficients of the spherical harmonics
  5897. */
  5898. l2_2: Vector3;
  5899. /**
  5900. * The l2,-1 coefficients of the spherical harmonics
  5901. */
  5902. l2_1: Vector3;
  5903. /**
  5904. * The l2,0 coefficients of the spherical harmonics
  5905. */
  5906. l20: Vector3;
  5907. /**
  5908. * The l2,1 coefficients of the spherical harmonics
  5909. */
  5910. l21: Vector3;
  5911. /**
  5912. * The l2,2 coefficients of the spherical harmonics
  5913. */
  5914. lL22: Vector3;
  5915. /**
  5916. * Adds a light to the spherical harmonics
  5917. * @param direction the direction of the light
  5918. * @param color the color of the light
  5919. * @param deltaSolidAngle the delta solid angle of the light
  5920. */
  5921. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5922. /**
  5923. * Scales the spherical harmonics by the given amount
  5924. * @param scale the amount to scale
  5925. */
  5926. scale(scale: number): void;
  5927. /**
  5928. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5929. *
  5930. * ```
  5931. * E_lm = A_l * L_lm
  5932. * ```
  5933. *
  5934. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5935. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5936. * the scaling factors are given in equation 9.
  5937. */
  5938. convertIncidentRadianceToIrradiance(): void;
  5939. /**
  5940. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5941. *
  5942. * ```
  5943. * L = (1/pi) * E * rho
  5944. * ```
  5945. *
  5946. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5947. */
  5948. convertIrradianceToLambertianRadiance(): void;
  5949. /**
  5950. * Gets the spherical harmonics from polynomial
  5951. * @param polynomial the spherical polynomial
  5952. * @returns the spherical harmonics
  5953. */
  5954. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5955. /**
  5956. * Constructs a spherical harmonics from an array.
  5957. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5958. * @returns the spherical harmonics
  5959. */
  5960. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5961. }
  5962. }
  5963. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5964. import { Nullable } from "babylonjs/types";
  5965. /**
  5966. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5967. */
  5968. export interface CubeMapInfo {
  5969. /**
  5970. * The pixel array for the front face.
  5971. * This is stored in format, left to right, up to down format.
  5972. */
  5973. front: Nullable<ArrayBufferView>;
  5974. /**
  5975. * The pixel array for the back face.
  5976. * This is stored in format, left to right, up to down format.
  5977. */
  5978. back: Nullable<ArrayBufferView>;
  5979. /**
  5980. * The pixel array for the left face.
  5981. * This is stored in format, left to right, up to down format.
  5982. */
  5983. left: Nullable<ArrayBufferView>;
  5984. /**
  5985. * The pixel array for the right face.
  5986. * This is stored in format, left to right, up to down format.
  5987. */
  5988. right: Nullable<ArrayBufferView>;
  5989. /**
  5990. * The pixel array for the up face.
  5991. * This is stored in format, left to right, up to down format.
  5992. */
  5993. up: Nullable<ArrayBufferView>;
  5994. /**
  5995. * The pixel array for the down face.
  5996. * This is stored in format, left to right, up to down format.
  5997. */
  5998. down: Nullable<ArrayBufferView>;
  5999. /**
  6000. * The size of the cubemap stored.
  6001. *
  6002. * Each faces will be size * size pixels.
  6003. */
  6004. size: number;
  6005. /**
  6006. * The format of the texture.
  6007. *
  6008. * RGBA, RGB.
  6009. */
  6010. format: number;
  6011. /**
  6012. * The type of the texture data.
  6013. *
  6014. * UNSIGNED_INT, FLOAT.
  6015. */
  6016. type: number;
  6017. /**
  6018. * Specifies whether the texture is in gamma space.
  6019. */
  6020. gammaSpace: boolean;
  6021. }
  6022. /**
  6023. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6024. */
  6025. export class PanoramaToCubeMapTools {
  6026. private static FACE_FRONT;
  6027. private static FACE_BACK;
  6028. private static FACE_RIGHT;
  6029. private static FACE_LEFT;
  6030. private static FACE_DOWN;
  6031. private static FACE_UP;
  6032. /**
  6033. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6034. *
  6035. * @param float32Array The source data.
  6036. * @param inputWidth The width of the input panorama.
  6037. * @param inputHeight The height of the input panorama.
  6038. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6039. * @return The cubemap data
  6040. */
  6041. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6042. private static CreateCubemapTexture;
  6043. private static CalcProjectionSpherical;
  6044. }
  6045. }
  6046. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6047. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6048. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6049. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6050. /**
  6051. * Helper class dealing with the extraction of spherical polynomial dataArray
  6052. * from a cube map.
  6053. */
  6054. export class CubeMapToSphericalPolynomialTools {
  6055. private static FileFaces;
  6056. /**
  6057. * Converts a texture to the according Spherical Polynomial data.
  6058. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6059. *
  6060. * @param texture The texture to extract the information from.
  6061. * @return The Spherical Polynomial data.
  6062. */
  6063. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6064. /**
  6065. * Converts a cubemap to the according Spherical Polynomial data.
  6066. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6067. *
  6068. * @param cubeInfo The Cube map to extract the information from.
  6069. * @return The Spherical Polynomial data.
  6070. */
  6071. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6072. }
  6073. }
  6074. declare module "babylonjs/Engines/engineStore" {
  6075. import { Nullable } from "babylonjs/types";
  6076. import { Engine } from "babylonjs/Engines/engine";
  6077. import { Scene } from "babylonjs/scene";
  6078. /**
  6079. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6080. * during the life time of the application.
  6081. */
  6082. export class EngineStore {
  6083. /** Gets the list of created engines */
  6084. static Instances: import("babylonjs/Engines/engine").Engine[];
  6085. /**
  6086. * Gets the latest created engine
  6087. */
  6088. static readonly LastCreatedEngine: Nullable<Engine>;
  6089. /**
  6090. * Gets the latest created scene
  6091. */
  6092. static readonly LastCreatedScene: Nullable<Scene>;
  6093. }
  6094. }
  6095. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6096. /**
  6097. * Define options used to create a render target texture
  6098. */
  6099. export class RenderTargetCreationOptions {
  6100. /**
  6101. * Specifies is mipmaps must be generated
  6102. */
  6103. generateMipMaps?: boolean;
  6104. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6105. generateDepthBuffer?: boolean;
  6106. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6107. generateStencilBuffer?: boolean;
  6108. /** Defines texture type (int by default) */
  6109. type?: number;
  6110. /** Defines sampling mode (trilinear by default) */
  6111. samplingMode?: number;
  6112. /** Defines format (RGBA by default) */
  6113. format?: number;
  6114. }
  6115. }
  6116. declare module "babylonjs/States/alphaCullingState" {
  6117. /**
  6118. * @hidden
  6119. **/
  6120. export class _AlphaState {
  6121. private _isAlphaBlendDirty;
  6122. private _isBlendFunctionParametersDirty;
  6123. private _isBlendEquationParametersDirty;
  6124. private _isBlendConstantsDirty;
  6125. private _alphaBlend;
  6126. private _blendFunctionParameters;
  6127. private _blendEquationParameters;
  6128. private _blendConstants;
  6129. /**
  6130. * Initializes the state.
  6131. */
  6132. constructor();
  6133. readonly isDirty: boolean;
  6134. alphaBlend: boolean;
  6135. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6136. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6137. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6138. reset(): void;
  6139. apply(gl: WebGLRenderingContext): void;
  6140. }
  6141. }
  6142. declare module "babylonjs/States/depthCullingState" {
  6143. import { Nullable } from "babylonjs/types";
  6144. /**
  6145. * @hidden
  6146. **/
  6147. export class _DepthCullingState {
  6148. private _isDepthTestDirty;
  6149. private _isDepthMaskDirty;
  6150. private _isDepthFuncDirty;
  6151. private _isCullFaceDirty;
  6152. private _isCullDirty;
  6153. private _isZOffsetDirty;
  6154. private _isFrontFaceDirty;
  6155. private _depthTest;
  6156. private _depthMask;
  6157. private _depthFunc;
  6158. private _cull;
  6159. private _cullFace;
  6160. private _zOffset;
  6161. private _frontFace;
  6162. /**
  6163. * Initializes the state.
  6164. */
  6165. constructor();
  6166. readonly isDirty: boolean;
  6167. zOffset: number;
  6168. cullFace: Nullable<number>;
  6169. cull: Nullable<boolean>;
  6170. depthFunc: Nullable<number>;
  6171. depthMask: boolean;
  6172. depthTest: boolean;
  6173. frontFace: Nullable<number>;
  6174. reset(): void;
  6175. apply(gl: WebGLRenderingContext): void;
  6176. }
  6177. }
  6178. declare module "babylonjs/States/stencilState" {
  6179. /**
  6180. * @hidden
  6181. **/
  6182. export class _StencilState {
  6183. /** 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 */
  6184. static readonly ALWAYS: number;
  6185. /** Passed to stencilOperation to specify that stencil value must be kept */
  6186. static readonly KEEP: number;
  6187. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6188. static readonly REPLACE: number;
  6189. private _isStencilTestDirty;
  6190. private _isStencilMaskDirty;
  6191. private _isStencilFuncDirty;
  6192. private _isStencilOpDirty;
  6193. private _stencilTest;
  6194. private _stencilMask;
  6195. private _stencilFunc;
  6196. private _stencilFuncRef;
  6197. private _stencilFuncMask;
  6198. private _stencilOpStencilFail;
  6199. private _stencilOpDepthFail;
  6200. private _stencilOpStencilDepthPass;
  6201. readonly isDirty: boolean;
  6202. stencilFunc: number;
  6203. stencilFuncRef: number;
  6204. stencilFuncMask: number;
  6205. stencilOpStencilFail: number;
  6206. stencilOpDepthFail: number;
  6207. stencilOpStencilDepthPass: number;
  6208. stencilMask: number;
  6209. stencilTest: boolean;
  6210. constructor();
  6211. reset(): void;
  6212. apply(gl: WebGLRenderingContext): void;
  6213. }
  6214. }
  6215. declare module "babylonjs/States/index" {
  6216. export * from "babylonjs/States/alphaCullingState";
  6217. export * from "babylonjs/States/depthCullingState";
  6218. export * from "babylonjs/States/stencilState";
  6219. }
  6220. declare module "babylonjs/Instrumentation/timeToken" {
  6221. import { Nullable } from "babylonjs/types";
  6222. /**
  6223. * @hidden
  6224. **/
  6225. export class _TimeToken {
  6226. _startTimeQuery: Nullable<WebGLQuery>;
  6227. _endTimeQuery: Nullable<WebGLQuery>;
  6228. _timeElapsedQuery: Nullable<WebGLQuery>;
  6229. _timeElapsedQueryEnded: boolean;
  6230. }
  6231. }
  6232. declare module "babylonjs/Materials/Textures/internalTexture" {
  6233. import { Observable } from "babylonjs/Misc/observable";
  6234. import { Nullable, int } from "babylonjs/types";
  6235. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6236. import { Engine } from "babylonjs/Engines/engine";
  6237. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6238. /**
  6239. * Class used to store data associated with WebGL texture data for the engine
  6240. * This class should not be used directly
  6241. */
  6242. export class InternalTexture {
  6243. /** hidden */
  6244. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6245. /**
  6246. * The source of the texture data is unknown
  6247. */
  6248. static DATASOURCE_UNKNOWN: number;
  6249. /**
  6250. * Texture data comes from an URL
  6251. */
  6252. static DATASOURCE_URL: number;
  6253. /**
  6254. * Texture data is only used for temporary storage
  6255. */
  6256. static DATASOURCE_TEMP: number;
  6257. /**
  6258. * Texture data comes from raw data (ArrayBuffer)
  6259. */
  6260. static DATASOURCE_RAW: number;
  6261. /**
  6262. * Texture content is dynamic (video or dynamic texture)
  6263. */
  6264. static DATASOURCE_DYNAMIC: number;
  6265. /**
  6266. * Texture content is generated by rendering to it
  6267. */
  6268. static DATASOURCE_RENDERTARGET: number;
  6269. /**
  6270. * Texture content is part of a multi render target process
  6271. */
  6272. static DATASOURCE_MULTIRENDERTARGET: number;
  6273. /**
  6274. * Texture data comes from a cube data file
  6275. */
  6276. static DATASOURCE_CUBE: number;
  6277. /**
  6278. * Texture data comes from a raw cube data
  6279. */
  6280. static DATASOURCE_CUBERAW: number;
  6281. /**
  6282. * Texture data come from a prefiltered cube data file
  6283. */
  6284. static DATASOURCE_CUBEPREFILTERED: number;
  6285. /**
  6286. * Texture content is raw 3D data
  6287. */
  6288. static DATASOURCE_RAW3D: number;
  6289. /**
  6290. * Texture content is a depth texture
  6291. */
  6292. static DATASOURCE_DEPTHTEXTURE: number;
  6293. /**
  6294. * Texture data comes from a raw cube data encoded with RGBD
  6295. */
  6296. static DATASOURCE_CUBERAW_RGBD: number;
  6297. /**
  6298. * Defines if the texture is ready
  6299. */
  6300. isReady: boolean;
  6301. /**
  6302. * Defines if the texture is a cube texture
  6303. */
  6304. isCube: boolean;
  6305. /**
  6306. * Defines if the texture contains 3D data
  6307. */
  6308. is3D: boolean;
  6309. /**
  6310. * Defines if the texture contains multiview data
  6311. */
  6312. isMultiview: boolean;
  6313. /**
  6314. * Gets the URL used to load this texture
  6315. */
  6316. url: string;
  6317. /**
  6318. * Gets the sampling mode of the texture
  6319. */
  6320. samplingMode: number;
  6321. /**
  6322. * Gets a boolean indicating if the texture needs mipmaps generation
  6323. */
  6324. generateMipMaps: boolean;
  6325. /**
  6326. * Gets the number of samples used by the texture (WebGL2+ only)
  6327. */
  6328. samples: number;
  6329. /**
  6330. * Gets the type of the texture (int, float...)
  6331. */
  6332. type: number;
  6333. /**
  6334. * Gets the format of the texture (RGB, RGBA...)
  6335. */
  6336. format: number;
  6337. /**
  6338. * Observable called when the texture is loaded
  6339. */
  6340. onLoadedObservable: Observable<InternalTexture>;
  6341. /**
  6342. * Gets the width of the texture
  6343. */
  6344. width: number;
  6345. /**
  6346. * Gets the height of the texture
  6347. */
  6348. height: number;
  6349. /**
  6350. * Gets the depth of the texture
  6351. */
  6352. depth: number;
  6353. /**
  6354. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6355. */
  6356. baseWidth: number;
  6357. /**
  6358. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6359. */
  6360. baseHeight: number;
  6361. /**
  6362. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6363. */
  6364. baseDepth: number;
  6365. /**
  6366. * Gets a boolean indicating if the texture is inverted on Y axis
  6367. */
  6368. invertY: boolean;
  6369. /** @hidden */
  6370. _invertVScale: boolean;
  6371. /** @hidden */
  6372. _associatedChannel: number;
  6373. /** @hidden */
  6374. _dataSource: number;
  6375. /** @hidden */
  6376. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6377. /** @hidden */
  6378. _bufferView: Nullable<ArrayBufferView>;
  6379. /** @hidden */
  6380. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6381. /** @hidden */
  6382. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6383. /** @hidden */
  6384. _size: number;
  6385. /** @hidden */
  6386. _extension: string;
  6387. /** @hidden */
  6388. _files: Nullable<string[]>;
  6389. /** @hidden */
  6390. _workingCanvas: Nullable<HTMLCanvasElement>;
  6391. /** @hidden */
  6392. _workingContext: Nullable<CanvasRenderingContext2D>;
  6393. /** @hidden */
  6394. _framebuffer: Nullable<WebGLFramebuffer>;
  6395. /** @hidden */
  6396. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6397. /** @hidden */
  6398. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6399. /** @hidden */
  6400. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6401. /** @hidden */
  6402. _attachments: Nullable<number[]>;
  6403. /** @hidden */
  6404. _cachedCoordinatesMode: Nullable<number>;
  6405. /** @hidden */
  6406. _cachedWrapU: Nullable<number>;
  6407. /** @hidden */
  6408. _cachedWrapV: Nullable<number>;
  6409. /** @hidden */
  6410. _cachedWrapR: Nullable<number>;
  6411. /** @hidden */
  6412. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6413. /** @hidden */
  6414. _isDisabled: boolean;
  6415. /** @hidden */
  6416. _compression: Nullable<string>;
  6417. /** @hidden */
  6418. _generateStencilBuffer: boolean;
  6419. /** @hidden */
  6420. _generateDepthBuffer: boolean;
  6421. /** @hidden */
  6422. _comparisonFunction: number;
  6423. /** @hidden */
  6424. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6425. /** @hidden */
  6426. _lodGenerationScale: number;
  6427. /** @hidden */
  6428. _lodGenerationOffset: number;
  6429. /** @hidden */
  6430. _colorTextureArray: Nullable<WebGLTexture>;
  6431. /** @hidden */
  6432. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6433. /** @hidden */
  6434. _lodTextureHigh: Nullable<BaseTexture>;
  6435. /** @hidden */
  6436. _lodTextureMid: Nullable<BaseTexture>;
  6437. /** @hidden */
  6438. _lodTextureLow: Nullable<BaseTexture>;
  6439. /** @hidden */
  6440. _isRGBD: boolean;
  6441. /** @hidden */
  6442. _webGLTexture: Nullable<WebGLTexture>;
  6443. /** @hidden */
  6444. _references: number;
  6445. private _engine;
  6446. /**
  6447. * Gets the Engine the texture belongs to.
  6448. * @returns The babylon engine
  6449. */
  6450. getEngine(): Engine;
  6451. /**
  6452. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6453. */
  6454. readonly dataSource: number;
  6455. /**
  6456. * Creates a new InternalTexture
  6457. * @param engine defines the engine to use
  6458. * @param dataSource defines the type of data that will be used
  6459. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6460. */
  6461. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6462. /**
  6463. * Increments the number of references (ie. the number of Texture that point to it)
  6464. */
  6465. incrementReferences(): void;
  6466. /**
  6467. * Change the size of the texture (not the size of the content)
  6468. * @param width defines the new width
  6469. * @param height defines the new height
  6470. * @param depth defines the new depth (1 by default)
  6471. */
  6472. updateSize(width: int, height: int, depth?: int): void;
  6473. /** @hidden */
  6474. _rebuild(): void;
  6475. /** @hidden */
  6476. _swapAndDie(target: InternalTexture): void;
  6477. /**
  6478. * Dispose the current allocated resources
  6479. */
  6480. dispose(): void;
  6481. }
  6482. }
  6483. declare module "babylonjs/Animations/easing" {
  6484. /**
  6485. * This represents the main contract an easing function should follow.
  6486. * Easing functions are used throughout the animation system.
  6487. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6488. */
  6489. export interface IEasingFunction {
  6490. /**
  6491. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6492. * of the easing function.
  6493. * The link below provides some of the most common examples of easing functions.
  6494. * @see https://easings.net/
  6495. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6496. * @returns the corresponding value on the curve defined by the easing function
  6497. */
  6498. ease(gradient: number): number;
  6499. }
  6500. /**
  6501. * Base class used for every default easing function.
  6502. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6503. */
  6504. export class EasingFunction implements IEasingFunction {
  6505. /**
  6506. * Interpolation follows the mathematical formula associated with the easing function.
  6507. */
  6508. static readonly EASINGMODE_EASEIN: number;
  6509. /**
  6510. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6511. */
  6512. static readonly EASINGMODE_EASEOUT: number;
  6513. /**
  6514. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6515. */
  6516. static readonly EASINGMODE_EASEINOUT: number;
  6517. private _easingMode;
  6518. /**
  6519. * Sets the easing mode of the current function.
  6520. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6521. */
  6522. setEasingMode(easingMode: number): void;
  6523. /**
  6524. * Gets the current easing mode.
  6525. * @returns the easing mode
  6526. */
  6527. getEasingMode(): number;
  6528. /**
  6529. * @hidden
  6530. */
  6531. easeInCore(gradient: number): number;
  6532. /**
  6533. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6534. * of the easing function.
  6535. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6536. * @returns the corresponding value on the curve defined by the easing function
  6537. */
  6538. ease(gradient: number): number;
  6539. }
  6540. /**
  6541. * Easing function with a circle shape (see link below).
  6542. * @see https://easings.net/#easeInCirc
  6543. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6544. */
  6545. export class CircleEase extends EasingFunction implements IEasingFunction {
  6546. /** @hidden */
  6547. easeInCore(gradient: number): number;
  6548. }
  6549. /**
  6550. * Easing function with a ease back shape (see link below).
  6551. * @see https://easings.net/#easeInBack
  6552. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6553. */
  6554. export class BackEase extends EasingFunction implements IEasingFunction {
  6555. /** Defines the amplitude of the function */
  6556. amplitude: number;
  6557. /**
  6558. * Instantiates a back ease easing
  6559. * @see https://easings.net/#easeInBack
  6560. * @param amplitude Defines the amplitude of the function
  6561. */
  6562. constructor(
  6563. /** Defines the amplitude of the function */
  6564. amplitude?: number);
  6565. /** @hidden */
  6566. easeInCore(gradient: number): number;
  6567. }
  6568. /**
  6569. * Easing function with a bouncing shape (see link below).
  6570. * @see https://easings.net/#easeInBounce
  6571. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6572. */
  6573. export class BounceEase extends EasingFunction implements IEasingFunction {
  6574. /** Defines the number of bounces */
  6575. bounces: number;
  6576. /** Defines the amplitude of the bounce */
  6577. bounciness: number;
  6578. /**
  6579. * Instantiates a bounce easing
  6580. * @see https://easings.net/#easeInBounce
  6581. * @param bounces Defines the number of bounces
  6582. * @param bounciness Defines the amplitude of the bounce
  6583. */
  6584. constructor(
  6585. /** Defines the number of bounces */
  6586. bounces?: number,
  6587. /** Defines the amplitude of the bounce */
  6588. bounciness?: number);
  6589. /** @hidden */
  6590. easeInCore(gradient: number): number;
  6591. }
  6592. /**
  6593. * Easing function with a power of 3 shape (see link below).
  6594. * @see https://easings.net/#easeInCubic
  6595. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6596. */
  6597. export class CubicEase extends EasingFunction implements IEasingFunction {
  6598. /** @hidden */
  6599. easeInCore(gradient: number): number;
  6600. }
  6601. /**
  6602. * Easing function with an elastic shape (see link below).
  6603. * @see https://easings.net/#easeInElastic
  6604. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6605. */
  6606. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6607. /** Defines the number of oscillations*/
  6608. oscillations: number;
  6609. /** Defines the amplitude of the oscillations*/
  6610. springiness: number;
  6611. /**
  6612. * Instantiates an elastic easing function
  6613. * @see https://easings.net/#easeInElastic
  6614. * @param oscillations Defines the number of oscillations
  6615. * @param springiness Defines the amplitude of the oscillations
  6616. */
  6617. constructor(
  6618. /** Defines the number of oscillations*/
  6619. oscillations?: number,
  6620. /** Defines the amplitude of the oscillations*/
  6621. springiness?: number);
  6622. /** @hidden */
  6623. easeInCore(gradient: number): number;
  6624. }
  6625. /**
  6626. * Easing function with an exponential shape (see link below).
  6627. * @see https://easings.net/#easeInExpo
  6628. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6629. */
  6630. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6631. /** Defines the exponent of the function */
  6632. exponent: number;
  6633. /**
  6634. * Instantiates an exponential easing function
  6635. * @see https://easings.net/#easeInExpo
  6636. * @param exponent Defines the exponent of the function
  6637. */
  6638. constructor(
  6639. /** Defines the exponent of the function */
  6640. exponent?: number);
  6641. /** @hidden */
  6642. easeInCore(gradient: number): number;
  6643. }
  6644. /**
  6645. * Easing function with a power shape (see link below).
  6646. * @see https://easings.net/#easeInQuad
  6647. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6648. */
  6649. export class PowerEase extends EasingFunction implements IEasingFunction {
  6650. /** Defines the power of the function */
  6651. power: number;
  6652. /**
  6653. * Instantiates an power base easing function
  6654. * @see https://easings.net/#easeInQuad
  6655. * @param power Defines the power of the function
  6656. */
  6657. constructor(
  6658. /** Defines the power of the function */
  6659. power?: number);
  6660. /** @hidden */
  6661. easeInCore(gradient: number): number;
  6662. }
  6663. /**
  6664. * Easing function with a power of 2 shape (see link below).
  6665. * @see https://easings.net/#easeInQuad
  6666. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6667. */
  6668. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6669. /** @hidden */
  6670. easeInCore(gradient: number): number;
  6671. }
  6672. /**
  6673. * Easing function with a power of 4 shape (see link below).
  6674. * @see https://easings.net/#easeInQuart
  6675. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6676. */
  6677. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6678. /** @hidden */
  6679. easeInCore(gradient: number): number;
  6680. }
  6681. /**
  6682. * Easing function with a power of 5 shape (see link below).
  6683. * @see https://easings.net/#easeInQuint
  6684. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6685. */
  6686. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6687. /** @hidden */
  6688. easeInCore(gradient: number): number;
  6689. }
  6690. /**
  6691. * Easing function with a sin shape (see link below).
  6692. * @see https://easings.net/#easeInSine
  6693. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6694. */
  6695. export class SineEase extends EasingFunction implements IEasingFunction {
  6696. /** @hidden */
  6697. easeInCore(gradient: number): number;
  6698. }
  6699. /**
  6700. * Easing function with a bezier shape (see link below).
  6701. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6702. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6703. */
  6704. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6705. /** Defines the x component of the start tangent in the bezier curve */
  6706. x1: number;
  6707. /** Defines the y component of the start tangent in the bezier curve */
  6708. y1: number;
  6709. /** Defines the x component of the end tangent in the bezier curve */
  6710. x2: number;
  6711. /** Defines the y component of the end tangent in the bezier curve */
  6712. y2: number;
  6713. /**
  6714. * Instantiates a bezier function
  6715. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6716. * @param x1 Defines the x component of the start tangent in the bezier curve
  6717. * @param y1 Defines the y component of the start tangent in the bezier curve
  6718. * @param x2 Defines the x component of the end tangent in the bezier curve
  6719. * @param y2 Defines the y component of the end tangent in the bezier curve
  6720. */
  6721. constructor(
  6722. /** Defines the x component of the start tangent in the bezier curve */
  6723. x1?: number,
  6724. /** Defines the y component of the start tangent in the bezier curve */
  6725. y1?: number,
  6726. /** Defines the x component of the end tangent in the bezier curve */
  6727. x2?: number,
  6728. /** Defines the y component of the end tangent in the bezier curve */
  6729. y2?: number);
  6730. /** @hidden */
  6731. easeInCore(gradient: number): number;
  6732. }
  6733. }
  6734. declare module "babylonjs/Animations/animationKey" {
  6735. /**
  6736. * Defines an interface which represents an animation key frame
  6737. */
  6738. export interface IAnimationKey {
  6739. /**
  6740. * Frame of the key frame
  6741. */
  6742. frame: number;
  6743. /**
  6744. * Value at the specifies key frame
  6745. */
  6746. value: any;
  6747. /**
  6748. * The input tangent for the cubic hermite spline
  6749. */
  6750. inTangent?: any;
  6751. /**
  6752. * The output tangent for the cubic hermite spline
  6753. */
  6754. outTangent?: any;
  6755. /**
  6756. * The animation interpolation type
  6757. */
  6758. interpolation?: AnimationKeyInterpolation;
  6759. }
  6760. /**
  6761. * Enum for the animation key frame interpolation type
  6762. */
  6763. export enum AnimationKeyInterpolation {
  6764. /**
  6765. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6766. */
  6767. STEP = 1
  6768. }
  6769. }
  6770. declare module "babylonjs/Animations/animationRange" {
  6771. /**
  6772. * Represents the range of an animation
  6773. */
  6774. export class AnimationRange {
  6775. /**The name of the animation range**/
  6776. name: string;
  6777. /**The starting frame of the animation */
  6778. from: number;
  6779. /**The ending frame of the animation*/
  6780. to: number;
  6781. /**
  6782. * Initializes the range of an animation
  6783. * @param name The name of the animation range
  6784. * @param from The starting frame of the animation
  6785. * @param to The ending frame of the animation
  6786. */
  6787. constructor(
  6788. /**The name of the animation range**/
  6789. name: string,
  6790. /**The starting frame of the animation */
  6791. from: number,
  6792. /**The ending frame of the animation*/
  6793. to: number);
  6794. /**
  6795. * Makes a copy of the animation range
  6796. * @returns A copy of the animation range
  6797. */
  6798. clone(): AnimationRange;
  6799. }
  6800. }
  6801. declare module "babylonjs/Animations/animationEvent" {
  6802. /**
  6803. * Composed of a frame, and an action function
  6804. */
  6805. export class AnimationEvent {
  6806. /** The frame for which the event is triggered **/
  6807. frame: number;
  6808. /** The event to perform when triggered **/
  6809. action: (currentFrame: number) => void;
  6810. /** Specifies if the event should be triggered only once**/
  6811. onlyOnce?: boolean | undefined;
  6812. /**
  6813. * Specifies if the animation event is done
  6814. */
  6815. isDone: boolean;
  6816. /**
  6817. * Initializes the animation event
  6818. * @param frame The frame for which the event is triggered
  6819. * @param action The event to perform when triggered
  6820. * @param onlyOnce Specifies if the event should be triggered only once
  6821. */
  6822. constructor(
  6823. /** The frame for which the event is triggered **/
  6824. frame: number,
  6825. /** The event to perform when triggered **/
  6826. action: (currentFrame: number) => void,
  6827. /** Specifies if the event should be triggered only once**/
  6828. onlyOnce?: boolean | undefined);
  6829. /** @hidden */
  6830. _clone(): AnimationEvent;
  6831. }
  6832. }
  6833. declare module "babylonjs/Behaviors/behavior" {
  6834. import { Nullable } from "babylonjs/types";
  6835. /**
  6836. * Interface used to define a behavior
  6837. */
  6838. export interface Behavior<T> {
  6839. /** gets or sets behavior's name */
  6840. name: string;
  6841. /**
  6842. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6843. */
  6844. init(): void;
  6845. /**
  6846. * Called when the behavior is attached to a target
  6847. * @param target defines the target where the behavior is attached to
  6848. */
  6849. attach(target: T): void;
  6850. /**
  6851. * Called when the behavior is detached from its target
  6852. */
  6853. detach(): void;
  6854. }
  6855. /**
  6856. * Interface implemented by classes supporting behaviors
  6857. */
  6858. export interface IBehaviorAware<T> {
  6859. /**
  6860. * Attach a behavior
  6861. * @param behavior defines the behavior to attach
  6862. * @returns the current host
  6863. */
  6864. addBehavior(behavior: Behavior<T>): T;
  6865. /**
  6866. * Remove a behavior from the current object
  6867. * @param behavior defines the behavior to detach
  6868. * @returns the current host
  6869. */
  6870. removeBehavior(behavior: Behavior<T>): T;
  6871. /**
  6872. * Gets a behavior using its name to search
  6873. * @param name defines the name to search
  6874. * @returns the behavior or null if not found
  6875. */
  6876. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6877. }
  6878. }
  6879. declare module "babylonjs/Collisions/intersectionInfo" {
  6880. import { Nullable } from "babylonjs/types";
  6881. /**
  6882. * @hidden
  6883. */
  6884. export class IntersectionInfo {
  6885. bu: Nullable<number>;
  6886. bv: Nullable<number>;
  6887. distance: number;
  6888. faceId: number;
  6889. subMeshId: number;
  6890. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6891. }
  6892. }
  6893. declare module "babylonjs/Culling/boundingSphere" {
  6894. import { DeepImmutable } from "babylonjs/types";
  6895. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6896. /**
  6897. * Class used to store bounding sphere information
  6898. */
  6899. export class BoundingSphere {
  6900. /**
  6901. * Gets the center of the bounding sphere in local space
  6902. */
  6903. readonly center: Vector3;
  6904. /**
  6905. * Radius of the bounding sphere in local space
  6906. */
  6907. radius: number;
  6908. /**
  6909. * Gets the center of the bounding sphere in world space
  6910. */
  6911. readonly centerWorld: Vector3;
  6912. /**
  6913. * Radius of the bounding sphere in world space
  6914. */
  6915. radiusWorld: number;
  6916. /**
  6917. * Gets the minimum vector in local space
  6918. */
  6919. readonly minimum: Vector3;
  6920. /**
  6921. * Gets the maximum vector in local space
  6922. */
  6923. readonly maximum: Vector3;
  6924. private _worldMatrix;
  6925. private static readonly TmpVector3;
  6926. /**
  6927. * Creates a new bounding sphere
  6928. * @param min defines the minimum vector (in local space)
  6929. * @param max defines the maximum vector (in local space)
  6930. * @param worldMatrix defines the new world matrix
  6931. */
  6932. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6933. /**
  6934. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6935. * @param min defines the new minimum vector (in local space)
  6936. * @param max defines the new maximum vector (in local space)
  6937. * @param worldMatrix defines the new world matrix
  6938. */
  6939. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6940. /**
  6941. * Scale the current bounding sphere by applying a scale factor
  6942. * @param factor defines the scale factor to apply
  6943. * @returns the current bounding box
  6944. */
  6945. scale(factor: number): BoundingSphere;
  6946. /**
  6947. * Gets the world matrix of the bounding box
  6948. * @returns a matrix
  6949. */
  6950. getWorldMatrix(): DeepImmutable<Matrix>;
  6951. /** @hidden */
  6952. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6953. /**
  6954. * Tests if the bounding sphere is intersecting the frustum planes
  6955. * @param frustumPlanes defines the frustum planes to test
  6956. * @returns true if there is an intersection
  6957. */
  6958. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6959. /**
  6960. * Tests if the bounding sphere center is in between the frustum planes.
  6961. * Used for optimistic fast inclusion.
  6962. * @param frustumPlanes defines the frustum planes to test
  6963. * @returns true if the sphere center is in between the frustum planes
  6964. */
  6965. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6966. /**
  6967. * Tests if a point is inside the bounding sphere
  6968. * @param point defines the point to test
  6969. * @returns true if the point is inside the bounding sphere
  6970. */
  6971. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6972. /**
  6973. * Checks if two sphere intersct
  6974. * @param sphere0 sphere 0
  6975. * @param sphere1 sphere 1
  6976. * @returns true if the speres intersect
  6977. */
  6978. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6979. }
  6980. }
  6981. declare module "babylonjs/Culling/boundingBox" {
  6982. import { DeepImmutable } from "babylonjs/types";
  6983. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6984. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6985. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6986. /**
  6987. * Class used to store bounding box information
  6988. */
  6989. export class BoundingBox implements ICullable {
  6990. /**
  6991. * Gets the 8 vectors representing the bounding box in local space
  6992. */
  6993. readonly vectors: Vector3[];
  6994. /**
  6995. * Gets the center of the bounding box in local space
  6996. */
  6997. readonly center: Vector3;
  6998. /**
  6999. * Gets the center of the bounding box in world space
  7000. */
  7001. readonly centerWorld: Vector3;
  7002. /**
  7003. * Gets the extend size in local space
  7004. */
  7005. readonly extendSize: Vector3;
  7006. /**
  7007. * Gets the extend size in world space
  7008. */
  7009. readonly extendSizeWorld: Vector3;
  7010. /**
  7011. * Gets the OBB (object bounding box) directions
  7012. */
  7013. readonly directions: Vector3[];
  7014. /**
  7015. * Gets the 8 vectors representing the bounding box in world space
  7016. */
  7017. readonly vectorsWorld: Vector3[];
  7018. /**
  7019. * Gets the minimum vector in world space
  7020. */
  7021. readonly minimumWorld: Vector3;
  7022. /**
  7023. * Gets the maximum vector in world space
  7024. */
  7025. readonly maximumWorld: Vector3;
  7026. /**
  7027. * Gets the minimum vector in local space
  7028. */
  7029. readonly minimum: Vector3;
  7030. /**
  7031. * Gets the maximum vector in local space
  7032. */
  7033. readonly maximum: Vector3;
  7034. private _worldMatrix;
  7035. private static readonly TmpVector3;
  7036. /**
  7037. * @hidden
  7038. */
  7039. _tag: number;
  7040. /**
  7041. * Creates a new bounding box
  7042. * @param min defines the minimum vector (in local space)
  7043. * @param max defines the maximum vector (in local space)
  7044. * @param worldMatrix defines the new world matrix
  7045. */
  7046. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7047. /**
  7048. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7049. * @param min defines the new minimum vector (in local space)
  7050. * @param max defines the new maximum vector (in local space)
  7051. * @param worldMatrix defines the new world matrix
  7052. */
  7053. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7054. /**
  7055. * Scale the current bounding box by applying a scale factor
  7056. * @param factor defines the scale factor to apply
  7057. * @returns the current bounding box
  7058. */
  7059. scale(factor: number): BoundingBox;
  7060. /**
  7061. * Gets the world matrix of the bounding box
  7062. * @returns a matrix
  7063. */
  7064. getWorldMatrix(): DeepImmutable<Matrix>;
  7065. /** @hidden */
  7066. _update(world: DeepImmutable<Matrix>): void;
  7067. /**
  7068. * Tests if the bounding box is intersecting the frustum planes
  7069. * @param frustumPlanes defines the frustum planes to test
  7070. * @returns true if there is an intersection
  7071. */
  7072. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7073. /**
  7074. * Tests if the bounding box is entirely inside the frustum planes
  7075. * @param frustumPlanes defines the frustum planes to test
  7076. * @returns true if there is an inclusion
  7077. */
  7078. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7079. /**
  7080. * Tests if a point is inside the bounding box
  7081. * @param point defines the point to test
  7082. * @returns true if the point is inside the bounding box
  7083. */
  7084. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7085. /**
  7086. * Tests if the bounding box intersects with a bounding sphere
  7087. * @param sphere defines the sphere to test
  7088. * @returns true if there is an intersection
  7089. */
  7090. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7091. /**
  7092. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7093. * @param min defines the min vector to use
  7094. * @param max defines the max vector to use
  7095. * @returns true if there is an intersection
  7096. */
  7097. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7098. /**
  7099. * Tests if two bounding boxes are intersections
  7100. * @param box0 defines the first box to test
  7101. * @param box1 defines the second box to test
  7102. * @returns true if there is an intersection
  7103. */
  7104. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7105. /**
  7106. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7107. * @param minPoint defines the minimum vector of the bounding box
  7108. * @param maxPoint defines the maximum vector of the bounding box
  7109. * @param sphereCenter defines the sphere center
  7110. * @param sphereRadius defines the sphere radius
  7111. * @returns true if there is an intersection
  7112. */
  7113. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7114. /**
  7115. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7116. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7117. * @param frustumPlanes defines the frustum planes to test
  7118. * @return true if there is an inclusion
  7119. */
  7120. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7121. /**
  7122. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7123. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7124. * @param frustumPlanes defines the frustum planes to test
  7125. * @return true if there is an intersection
  7126. */
  7127. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7128. }
  7129. }
  7130. declare module "babylonjs/Collisions/collider" {
  7131. import { Nullable, IndicesArray } from "babylonjs/types";
  7132. import { Vector3, Plane } from "babylonjs/Maths/math";
  7133. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7134. /** @hidden */
  7135. export class Collider {
  7136. /** Define if a collision was found */
  7137. collisionFound: boolean;
  7138. /**
  7139. * Define last intersection point in local space
  7140. */
  7141. intersectionPoint: Vector3;
  7142. /**
  7143. * Define last collided mesh
  7144. */
  7145. collidedMesh: Nullable<AbstractMesh>;
  7146. private _collisionPoint;
  7147. private _planeIntersectionPoint;
  7148. private _tempVector;
  7149. private _tempVector2;
  7150. private _tempVector3;
  7151. private _tempVector4;
  7152. private _edge;
  7153. private _baseToVertex;
  7154. private _destinationPoint;
  7155. private _slidePlaneNormal;
  7156. private _displacementVector;
  7157. /** @hidden */
  7158. _radius: Vector3;
  7159. /** @hidden */
  7160. _retry: number;
  7161. private _velocity;
  7162. private _basePoint;
  7163. private _epsilon;
  7164. /** @hidden */
  7165. _velocityWorldLength: number;
  7166. /** @hidden */
  7167. _basePointWorld: Vector3;
  7168. private _velocityWorld;
  7169. private _normalizedVelocity;
  7170. /** @hidden */
  7171. _initialVelocity: Vector3;
  7172. /** @hidden */
  7173. _initialPosition: Vector3;
  7174. private _nearestDistance;
  7175. private _collisionMask;
  7176. collisionMask: number;
  7177. /**
  7178. * Gets the plane normal used to compute the sliding response (in local space)
  7179. */
  7180. readonly slidePlaneNormal: Vector3;
  7181. /** @hidden */
  7182. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7183. /** @hidden */
  7184. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7185. /** @hidden */
  7186. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7187. /** @hidden */
  7188. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7189. /** @hidden */
  7190. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7191. /** @hidden */
  7192. _getResponse(pos: Vector3, vel: Vector3): void;
  7193. }
  7194. }
  7195. declare module "babylonjs/Culling/boundingInfo" {
  7196. import { DeepImmutable } from "babylonjs/types";
  7197. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7198. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7199. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7200. import { Collider } from "babylonjs/Collisions/collider";
  7201. /**
  7202. * Interface for cullable objects
  7203. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7204. */
  7205. export interface ICullable {
  7206. /**
  7207. * Checks if the object or part of the object is in the frustum
  7208. * @param frustumPlanes Camera near/planes
  7209. * @returns true if the object is in frustum otherwise false
  7210. */
  7211. isInFrustum(frustumPlanes: Plane[]): boolean;
  7212. /**
  7213. * Checks if a cullable object (mesh...) is in the camera frustum
  7214. * Unlike isInFrustum this cheks the full bounding box
  7215. * @param frustumPlanes Camera near/planes
  7216. * @returns true if the object is in frustum otherwise false
  7217. */
  7218. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7219. }
  7220. /**
  7221. * Info for a bounding data of a mesh
  7222. */
  7223. export class BoundingInfo implements ICullable {
  7224. /**
  7225. * Bounding box for the mesh
  7226. */
  7227. readonly boundingBox: BoundingBox;
  7228. /**
  7229. * Bounding sphere for the mesh
  7230. */
  7231. readonly boundingSphere: BoundingSphere;
  7232. private _isLocked;
  7233. private static readonly TmpVector3;
  7234. /**
  7235. * Constructs bounding info
  7236. * @param minimum min vector of the bounding box/sphere
  7237. * @param maximum max vector of the bounding box/sphere
  7238. * @param worldMatrix defines the new world matrix
  7239. */
  7240. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7241. /**
  7242. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7243. * @param min defines the new minimum vector (in local space)
  7244. * @param max defines the new maximum vector (in local space)
  7245. * @param worldMatrix defines the new world matrix
  7246. */
  7247. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7248. /**
  7249. * min vector of the bounding box/sphere
  7250. */
  7251. readonly minimum: Vector3;
  7252. /**
  7253. * max vector of the bounding box/sphere
  7254. */
  7255. readonly maximum: Vector3;
  7256. /**
  7257. * If the info is locked and won't be updated to avoid perf overhead
  7258. */
  7259. isLocked: boolean;
  7260. /**
  7261. * Updates the bounding sphere and box
  7262. * @param world world matrix to be used to update
  7263. */
  7264. update(world: DeepImmutable<Matrix>): void;
  7265. /**
  7266. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7267. * @param center New center of the bounding info
  7268. * @param extend New extend of the bounding info
  7269. * @returns the current bounding info
  7270. */
  7271. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7272. /**
  7273. * Scale the current bounding info by applying a scale factor
  7274. * @param factor defines the scale factor to apply
  7275. * @returns the current bounding info
  7276. */
  7277. scale(factor: number): BoundingInfo;
  7278. /**
  7279. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7280. * @param frustumPlanes defines the frustum to test
  7281. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7282. * @returns true if the bounding info is in the frustum planes
  7283. */
  7284. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7285. /**
  7286. * Gets the world distance between the min and max points of the bounding box
  7287. */
  7288. readonly diagonalLength: number;
  7289. /**
  7290. * Checks if a cullable object (mesh...) is in the camera frustum
  7291. * Unlike isInFrustum this cheks the full bounding box
  7292. * @param frustumPlanes Camera near/planes
  7293. * @returns true if the object is in frustum otherwise false
  7294. */
  7295. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7296. /** @hidden */
  7297. _checkCollision(collider: Collider): boolean;
  7298. /**
  7299. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7300. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7301. * @param point the point to check intersection with
  7302. * @returns if the point intersects
  7303. */
  7304. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7305. /**
  7306. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7307. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7308. * @param boundingInfo the bounding info to check intersection with
  7309. * @param precise if the intersection should be done using OBB
  7310. * @returns if the bounding info intersects
  7311. */
  7312. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7313. }
  7314. }
  7315. declare module "babylonjs/Misc/smartArray" {
  7316. /**
  7317. * Defines an array and its length.
  7318. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7319. */
  7320. export interface ISmartArrayLike<T> {
  7321. /**
  7322. * The data of the array.
  7323. */
  7324. data: Array<T>;
  7325. /**
  7326. * The active length of the array.
  7327. */
  7328. length: number;
  7329. }
  7330. /**
  7331. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7332. */
  7333. export class SmartArray<T> implements ISmartArrayLike<T> {
  7334. /**
  7335. * The full set of data from the array.
  7336. */
  7337. data: Array<T>;
  7338. /**
  7339. * The active length of the array.
  7340. */
  7341. length: number;
  7342. protected _id: number;
  7343. /**
  7344. * Instantiates a Smart Array.
  7345. * @param capacity defines the default capacity of the array.
  7346. */
  7347. constructor(capacity: number);
  7348. /**
  7349. * Pushes a value at the end of the active data.
  7350. * @param value defines the object to push in the array.
  7351. */
  7352. push(value: T): void;
  7353. /**
  7354. * Iterates over the active data and apply the lambda to them.
  7355. * @param func defines the action to apply on each value.
  7356. */
  7357. forEach(func: (content: T) => void): void;
  7358. /**
  7359. * Sorts the full sets of data.
  7360. * @param compareFn defines the comparison function to apply.
  7361. */
  7362. sort(compareFn: (a: T, b: T) => number): void;
  7363. /**
  7364. * Resets the active data to an empty array.
  7365. */
  7366. reset(): void;
  7367. /**
  7368. * Releases all the data from the array as well as the array.
  7369. */
  7370. dispose(): void;
  7371. /**
  7372. * Concats the active data with a given array.
  7373. * @param array defines the data to concatenate with.
  7374. */
  7375. concat(array: any): void;
  7376. /**
  7377. * Returns the position of a value in the active data.
  7378. * @param value defines the value to find the index for
  7379. * @returns the index if found in the active data otherwise -1
  7380. */
  7381. indexOf(value: T): number;
  7382. /**
  7383. * Returns whether an element is part of the active data.
  7384. * @param value defines the value to look for
  7385. * @returns true if found in the active data otherwise false
  7386. */
  7387. contains(value: T): boolean;
  7388. private static _GlobalId;
  7389. }
  7390. /**
  7391. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7392. * The data in this array can only be present once
  7393. */
  7394. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7395. private _duplicateId;
  7396. /**
  7397. * Pushes a value at the end of the active data.
  7398. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7399. * @param value defines the object to push in the array.
  7400. */
  7401. push(value: T): void;
  7402. /**
  7403. * Pushes a value at the end of the active data.
  7404. * If the data is already present, it won t be added again
  7405. * @param value defines the object to push in the array.
  7406. * @returns true if added false if it was already present
  7407. */
  7408. pushNoDuplicate(value: T): boolean;
  7409. /**
  7410. * Resets the active data to an empty array.
  7411. */
  7412. reset(): void;
  7413. /**
  7414. * Concats the active data with a given array.
  7415. * This ensures no dupplicate will be present in the result.
  7416. * @param array defines the data to concatenate with.
  7417. */
  7418. concatWithNoDuplicate(array: any): void;
  7419. }
  7420. }
  7421. declare module "babylonjs/Materials/multiMaterial" {
  7422. import { Nullable } from "babylonjs/types";
  7423. import { Scene } from "babylonjs/scene";
  7424. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7425. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7426. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7427. import { Material } from "babylonjs/Materials/material";
  7428. /**
  7429. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7430. * separate meshes. This can be use to improve performances.
  7431. * @see http://doc.babylonjs.com/how_to/multi_materials
  7432. */
  7433. export class MultiMaterial extends Material {
  7434. private _subMaterials;
  7435. /**
  7436. * Gets or Sets the list of Materials used within the multi material.
  7437. * They need to be ordered according to the submeshes order in the associated mesh
  7438. */
  7439. subMaterials: Nullable<Material>[];
  7440. /**
  7441. * Function used to align with Node.getChildren()
  7442. * @returns the list of Materials used within the multi material
  7443. */
  7444. getChildren(): Nullable<Material>[];
  7445. /**
  7446. * Instantiates a new Multi Material
  7447. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7448. * separate meshes. This can be use to improve performances.
  7449. * @see http://doc.babylonjs.com/how_to/multi_materials
  7450. * @param name Define the name in the scene
  7451. * @param scene Define the scene the material belongs to
  7452. */
  7453. constructor(name: string, scene: Scene);
  7454. private _hookArray;
  7455. /**
  7456. * Get one of the submaterial by its index in the submaterials array
  7457. * @param index The index to look the sub material at
  7458. * @returns The Material if the index has been defined
  7459. */
  7460. getSubMaterial(index: number): Nullable<Material>;
  7461. /**
  7462. * Get the list of active textures for the whole sub materials list.
  7463. * @returns All the textures that will be used during the rendering
  7464. */
  7465. getActiveTextures(): BaseTexture[];
  7466. /**
  7467. * Gets the current class name of the material e.g. "MultiMaterial"
  7468. * Mainly use in serialization.
  7469. * @returns the class name
  7470. */
  7471. getClassName(): string;
  7472. /**
  7473. * Checks if the material is ready to render the requested sub mesh
  7474. * @param mesh Define the mesh the submesh belongs to
  7475. * @param subMesh Define the sub mesh to look readyness for
  7476. * @param useInstances Define whether or not the material is used with instances
  7477. * @returns true if ready, otherwise false
  7478. */
  7479. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7480. /**
  7481. * Clones the current material and its related sub materials
  7482. * @param name Define the name of the newly cloned material
  7483. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7484. * @returns the cloned material
  7485. */
  7486. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7487. /**
  7488. * Serializes the materials into a JSON representation.
  7489. * @returns the JSON representation
  7490. */
  7491. serialize(): any;
  7492. /**
  7493. * Dispose the material and release its associated resources
  7494. * @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)
  7495. * @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)
  7496. * @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)
  7497. */
  7498. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7499. /**
  7500. * Creates a MultiMaterial from parsed MultiMaterial data.
  7501. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7502. * @param scene defines the hosting scene
  7503. * @returns a new MultiMaterial
  7504. */
  7505. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7506. }
  7507. }
  7508. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7509. /**
  7510. * Class used to represent data loading progression
  7511. */
  7512. export class SceneLoaderFlags {
  7513. private static _ForceFullSceneLoadingForIncremental;
  7514. private static _ShowLoadingScreen;
  7515. private static _CleanBoneMatrixWeights;
  7516. private static _loggingLevel;
  7517. /**
  7518. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7519. */
  7520. static ForceFullSceneLoadingForIncremental: boolean;
  7521. /**
  7522. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7523. */
  7524. static ShowLoadingScreen: boolean;
  7525. /**
  7526. * Defines the current logging level (while loading the scene)
  7527. * @ignorenaming
  7528. */
  7529. static loggingLevel: number;
  7530. /**
  7531. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7532. */
  7533. static CleanBoneMatrixWeights: boolean;
  7534. }
  7535. }
  7536. declare module "babylonjs/Meshes/transformNode" {
  7537. import { DeepImmutable } from "babylonjs/types";
  7538. import { Observable } from "babylonjs/Misc/observable";
  7539. import { Nullable } from "babylonjs/types";
  7540. import { Camera } from "babylonjs/Cameras/camera";
  7541. import { Scene } from "babylonjs/scene";
  7542. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7543. import { Node } from "babylonjs/node";
  7544. import { Bone } from "babylonjs/Bones/bone";
  7545. /**
  7546. * 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.
  7547. * @see https://doc.babylonjs.com/how_to/transformnode
  7548. */
  7549. export class TransformNode extends Node {
  7550. /**
  7551. * Object will not rotate to face the camera
  7552. */
  7553. static BILLBOARDMODE_NONE: number;
  7554. /**
  7555. * Object will rotate to face the camera but only on the x axis
  7556. */
  7557. static BILLBOARDMODE_X: number;
  7558. /**
  7559. * Object will rotate to face the camera but only on the y axis
  7560. */
  7561. static BILLBOARDMODE_Y: number;
  7562. /**
  7563. * Object will rotate to face the camera but only on the z axis
  7564. */
  7565. static BILLBOARDMODE_Z: number;
  7566. /**
  7567. * Object will rotate to face the camera
  7568. */
  7569. static BILLBOARDMODE_ALL: number;
  7570. private _forward;
  7571. private _forwardInverted;
  7572. private _up;
  7573. private _right;
  7574. private _rightInverted;
  7575. private _position;
  7576. private _rotation;
  7577. private _rotationQuaternion;
  7578. protected _scaling: Vector3;
  7579. protected _isDirty: boolean;
  7580. private _transformToBoneReferal;
  7581. private _billboardMode;
  7582. /**
  7583. * Gets or sets the billboard mode. Default is 0.
  7584. *
  7585. * | Value | Type | Description |
  7586. * | --- | --- | --- |
  7587. * | 0 | BILLBOARDMODE_NONE | |
  7588. * | 1 | BILLBOARDMODE_X | |
  7589. * | 2 | BILLBOARDMODE_Y | |
  7590. * | 4 | BILLBOARDMODE_Z | |
  7591. * | 7 | BILLBOARDMODE_ALL | |
  7592. *
  7593. */
  7594. billboardMode: number;
  7595. private _preserveParentRotationForBillboard;
  7596. /**
  7597. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7598. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7599. */
  7600. preserveParentRotationForBillboard: boolean;
  7601. /**
  7602. * 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
  7603. */
  7604. scalingDeterminant: number;
  7605. private _infiniteDistance;
  7606. /**
  7607. * Gets or sets the distance of the object to max, often used by skybox
  7608. */
  7609. infiniteDistance: boolean;
  7610. /**
  7611. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7612. * By default the system will update normals to compensate
  7613. */
  7614. ignoreNonUniformScaling: boolean;
  7615. /**
  7616. * 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
  7617. */
  7618. reIntegrateRotationIntoRotationQuaternion: boolean;
  7619. /** @hidden */
  7620. _poseMatrix: Nullable<Matrix>;
  7621. /** @hidden */
  7622. _localMatrix: Matrix;
  7623. private _usePivotMatrix;
  7624. private _absolutePosition;
  7625. private _pivotMatrix;
  7626. private _pivotMatrixInverse;
  7627. protected _postMultiplyPivotMatrix: boolean;
  7628. protected _isWorldMatrixFrozen: boolean;
  7629. /** @hidden */
  7630. _indexInSceneTransformNodesArray: number;
  7631. /**
  7632. * An event triggered after the world matrix is updated
  7633. */
  7634. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7635. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7636. /**
  7637. * Gets a string identifying the name of the class
  7638. * @returns "TransformNode" string
  7639. */
  7640. getClassName(): string;
  7641. /**
  7642. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7643. */
  7644. position: Vector3;
  7645. /**
  7646. * 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)).
  7647. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7648. */
  7649. rotation: Vector3;
  7650. /**
  7651. * 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)).
  7652. */
  7653. scaling: Vector3;
  7654. /**
  7655. * 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).
  7656. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7657. */
  7658. rotationQuaternion: Nullable<Quaternion>;
  7659. /**
  7660. * The forward direction of that transform in world space.
  7661. */
  7662. readonly forward: Vector3;
  7663. /**
  7664. * The up direction of that transform in world space.
  7665. */
  7666. readonly up: Vector3;
  7667. /**
  7668. * The right direction of that transform in world space.
  7669. */
  7670. readonly right: Vector3;
  7671. /**
  7672. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7673. * @param matrix the matrix to copy the pose from
  7674. * @returns this TransformNode.
  7675. */
  7676. updatePoseMatrix(matrix: Matrix): TransformNode;
  7677. /**
  7678. * Returns the mesh Pose matrix.
  7679. * @returns the pose matrix
  7680. */
  7681. getPoseMatrix(): Matrix;
  7682. /** @hidden */
  7683. _isSynchronized(): boolean;
  7684. /** @hidden */
  7685. _initCache(): void;
  7686. /**
  7687. * Flag the transform node as dirty (Forcing it to update everything)
  7688. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7689. * @returns this transform node
  7690. */
  7691. markAsDirty(property: string): TransformNode;
  7692. /**
  7693. * Returns the current mesh absolute position.
  7694. * Returns a Vector3.
  7695. */
  7696. readonly absolutePosition: Vector3;
  7697. /**
  7698. * Sets a new matrix to apply before all other transformation
  7699. * @param matrix defines the transform matrix
  7700. * @returns the current TransformNode
  7701. */
  7702. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7703. /**
  7704. * Sets a new pivot matrix to the current node
  7705. * @param matrix defines the new pivot matrix to use
  7706. * @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
  7707. * @returns the current TransformNode
  7708. */
  7709. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7710. /**
  7711. * Returns the mesh pivot matrix.
  7712. * Default : Identity.
  7713. * @returns the matrix
  7714. */
  7715. getPivotMatrix(): Matrix;
  7716. /**
  7717. * Prevents the World matrix to be computed any longer.
  7718. * @returns the TransformNode.
  7719. */
  7720. freezeWorldMatrix(): TransformNode;
  7721. /**
  7722. * Allows back the World matrix computation.
  7723. * @returns the TransformNode.
  7724. */
  7725. unfreezeWorldMatrix(): this;
  7726. /**
  7727. * True if the World matrix has been frozen.
  7728. */
  7729. readonly isWorldMatrixFrozen: boolean;
  7730. /**
  7731. * Retuns the mesh absolute position in the World.
  7732. * @returns a Vector3.
  7733. */
  7734. getAbsolutePosition(): Vector3;
  7735. /**
  7736. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7737. * @param absolutePosition the absolute position to set
  7738. * @returns the TransformNode.
  7739. */
  7740. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7741. /**
  7742. * Sets the mesh position in its local space.
  7743. * @param vector3 the position to set in localspace
  7744. * @returns the TransformNode.
  7745. */
  7746. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7747. /**
  7748. * Returns the mesh position in the local space from the current World matrix values.
  7749. * @returns a new Vector3.
  7750. */
  7751. getPositionExpressedInLocalSpace(): Vector3;
  7752. /**
  7753. * Translates the mesh along the passed Vector3 in its local space.
  7754. * @param vector3 the distance to translate in localspace
  7755. * @returns the TransformNode.
  7756. */
  7757. locallyTranslate(vector3: Vector3): TransformNode;
  7758. private static _lookAtVectorCache;
  7759. /**
  7760. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7761. * @param targetPoint the position (must be in same space as current mesh) to look at
  7762. * @param yawCor optional yaw (y-axis) correction in radians
  7763. * @param pitchCor optional pitch (x-axis) correction in radians
  7764. * @param rollCor optional roll (z-axis) correction in radians
  7765. * @param space the choosen space of the target
  7766. * @returns the TransformNode.
  7767. */
  7768. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7769. /**
  7770. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7771. * This Vector3 is expressed in the World space.
  7772. * @param localAxis axis to rotate
  7773. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7774. */
  7775. getDirection(localAxis: Vector3): Vector3;
  7776. /**
  7777. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7778. * localAxis is expressed in the mesh local space.
  7779. * result is computed in the Wordl space from the mesh World matrix.
  7780. * @param localAxis axis to rotate
  7781. * @param result the resulting transformnode
  7782. * @returns this TransformNode.
  7783. */
  7784. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7785. /**
  7786. * Sets this transform node rotation to the given local axis.
  7787. * @param localAxis the axis in local space
  7788. * @param yawCor optional yaw (y-axis) correction in radians
  7789. * @param pitchCor optional pitch (x-axis) correction in radians
  7790. * @param rollCor optional roll (z-axis) correction in radians
  7791. * @returns this TransformNode
  7792. */
  7793. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7794. /**
  7795. * Sets a new pivot point to the current node
  7796. * @param point defines the new pivot point to use
  7797. * @param space defines if the point is in world or local space (local by default)
  7798. * @returns the current TransformNode
  7799. */
  7800. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7801. /**
  7802. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7803. * @returns the pivot point
  7804. */
  7805. getPivotPoint(): Vector3;
  7806. /**
  7807. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7808. * @param result the vector3 to store the result
  7809. * @returns this TransformNode.
  7810. */
  7811. getPivotPointToRef(result: Vector3): TransformNode;
  7812. /**
  7813. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7814. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7815. */
  7816. getAbsolutePivotPoint(): Vector3;
  7817. /**
  7818. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7819. * @param result vector3 to store the result
  7820. * @returns this TransformNode.
  7821. */
  7822. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7823. /**
  7824. * Defines the passed node as the parent of the current node.
  7825. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7826. * @see https://doc.babylonjs.com/how_to/parenting
  7827. * @param node the node ot set as the parent
  7828. * @returns this TransformNode.
  7829. */
  7830. setParent(node: Nullable<Node>): TransformNode;
  7831. private _nonUniformScaling;
  7832. /**
  7833. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7834. */
  7835. readonly nonUniformScaling: boolean;
  7836. /** @hidden */
  7837. _updateNonUniformScalingState(value: boolean): boolean;
  7838. /**
  7839. * Attach the current TransformNode to another TransformNode associated with a bone
  7840. * @param bone Bone affecting the TransformNode
  7841. * @param affectedTransformNode TransformNode associated with the bone
  7842. * @returns this object
  7843. */
  7844. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7845. /**
  7846. * Detach the transform node if its associated with a bone
  7847. * @returns this object
  7848. */
  7849. detachFromBone(): TransformNode;
  7850. private static _rotationAxisCache;
  7851. /**
  7852. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7853. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7854. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7855. * The passed axis is also normalized.
  7856. * @param axis the axis to rotate around
  7857. * @param amount the amount to rotate in radians
  7858. * @param space Space to rotate in (Default: local)
  7859. * @returns the TransformNode.
  7860. */
  7861. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7862. /**
  7863. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7864. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7865. * The passed axis is also normalized. .
  7866. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7867. * @param point the point to rotate around
  7868. * @param axis the axis to rotate around
  7869. * @param amount the amount to rotate in radians
  7870. * @returns the TransformNode
  7871. */
  7872. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7873. /**
  7874. * Translates the mesh along the axis vector for the passed distance in the given space.
  7875. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7876. * @param axis the axis to translate in
  7877. * @param distance the distance to translate
  7878. * @param space Space to rotate in (Default: local)
  7879. * @returns the TransformNode.
  7880. */
  7881. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7882. /**
  7883. * Adds a rotation step to the mesh current rotation.
  7884. * x, y, z are Euler angles expressed in radians.
  7885. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7886. * This means this rotation is made in the mesh local space only.
  7887. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7888. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7889. * ```javascript
  7890. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7891. * ```
  7892. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7893. * 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.
  7894. * @param x Rotation to add
  7895. * @param y Rotation to add
  7896. * @param z Rotation to add
  7897. * @returns the TransformNode.
  7898. */
  7899. addRotation(x: number, y: number, z: number): TransformNode;
  7900. /**
  7901. * @hidden
  7902. */
  7903. protected _getEffectiveParent(): Nullable<Node>;
  7904. /**
  7905. * Computes the world matrix of the node
  7906. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7907. * @returns the world matrix
  7908. */
  7909. computeWorldMatrix(force?: boolean): Matrix;
  7910. protected _afterComputeWorldMatrix(): void;
  7911. /**
  7912. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7913. * @param func callback function to add
  7914. *
  7915. * @returns the TransformNode.
  7916. */
  7917. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7918. /**
  7919. * Removes a registered callback function.
  7920. * @param func callback function to remove
  7921. * @returns the TransformNode.
  7922. */
  7923. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7924. /**
  7925. * Gets the position of the current mesh in camera space
  7926. * @param camera defines the camera to use
  7927. * @returns a position
  7928. */
  7929. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7930. /**
  7931. * Returns the distance from the mesh to the active camera
  7932. * @param camera defines the camera to use
  7933. * @returns the distance
  7934. */
  7935. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7936. /**
  7937. * Clone the current transform node
  7938. * @param name Name of the new clone
  7939. * @param newParent New parent for the clone
  7940. * @param doNotCloneChildren Do not clone children hierarchy
  7941. * @returns the new transform node
  7942. */
  7943. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7944. /**
  7945. * Serializes the objects information.
  7946. * @param currentSerializationObject defines the object to serialize in
  7947. * @returns the serialized object
  7948. */
  7949. serialize(currentSerializationObject?: any): any;
  7950. /**
  7951. * Returns a new TransformNode object parsed from the source provided.
  7952. * @param parsedTransformNode is the source.
  7953. * @param scene the scne the object belongs to
  7954. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7955. * @returns a new TransformNode object parsed from the source provided.
  7956. */
  7957. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7958. /**
  7959. * Get all child-transformNodes of this node
  7960. * @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
  7961. * @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
  7962. * @returns an array of TransformNode
  7963. */
  7964. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7965. /**
  7966. * Releases resources associated with this transform node.
  7967. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7968. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7969. */
  7970. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7971. }
  7972. }
  7973. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7974. /**
  7975. * Class used to override all child animations of a given target
  7976. */
  7977. export class AnimationPropertiesOverride {
  7978. /**
  7979. * Gets or sets a value indicating if animation blending must be used
  7980. */
  7981. enableBlending: boolean;
  7982. /**
  7983. * Gets or sets the blending speed to use when enableBlending is true
  7984. */
  7985. blendingSpeed: number;
  7986. /**
  7987. * Gets or sets the default loop mode to use
  7988. */
  7989. loopMode: number;
  7990. }
  7991. }
  7992. declare module "babylonjs/Bones/bone" {
  7993. import { Skeleton } from "babylonjs/Bones/skeleton";
  7994. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7995. import { Nullable } from "babylonjs/types";
  7996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7997. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7998. import { Node } from "babylonjs/node";
  7999. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8000. /**
  8001. * Class used to store bone information
  8002. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8003. */
  8004. export class Bone extends Node {
  8005. /**
  8006. * defines the bone name
  8007. */
  8008. name: string;
  8009. private static _tmpVecs;
  8010. private static _tmpQuat;
  8011. private static _tmpMats;
  8012. /**
  8013. * Gets the list of child bones
  8014. */
  8015. children: Bone[];
  8016. /** Gets the animations associated with this bone */
  8017. animations: import("babylonjs/Animations/animation").Animation[];
  8018. /**
  8019. * Gets or sets bone length
  8020. */
  8021. length: number;
  8022. /**
  8023. * @hidden Internal only
  8024. * Set this value to map this bone to a different index in the transform matrices
  8025. * Set this value to -1 to exclude the bone from the transform matrices
  8026. */
  8027. _index: Nullable<number>;
  8028. private _skeleton;
  8029. private _localMatrix;
  8030. private _restPose;
  8031. private _baseMatrix;
  8032. private _absoluteTransform;
  8033. private _invertedAbsoluteTransform;
  8034. private _parent;
  8035. private _scalingDeterminant;
  8036. private _worldTransform;
  8037. private _localScaling;
  8038. private _localRotation;
  8039. private _localPosition;
  8040. private _needToDecompose;
  8041. private _needToCompose;
  8042. /** @hidden */
  8043. _linkedTransformNode: Nullable<TransformNode>;
  8044. /** @hidden */
  8045. /** @hidden */
  8046. _matrix: Matrix;
  8047. /**
  8048. * Create a new bone
  8049. * @param name defines the bone name
  8050. * @param skeleton defines the parent skeleton
  8051. * @param parentBone defines the parent (can be null if the bone is the root)
  8052. * @param localMatrix defines the local matrix
  8053. * @param restPose defines the rest pose matrix
  8054. * @param baseMatrix defines the base matrix
  8055. * @param index defines index of the bone in the hiearchy
  8056. */
  8057. constructor(
  8058. /**
  8059. * defines the bone name
  8060. */
  8061. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8062. /**
  8063. * Gets the current object class name.
  8064. * @return the class name
  8065. */
  8066. getClassName(): string;
  8067. /**
  8068. * Gets the parent skeleton
  8069. * @returns a skeleton
  8070. */
  8071. getSkeleton(): Skeleton;
  8072. /**
  8073. * Gets parent bone
  8074. * @returns a bone or null if the bone is the root of the bone hierarchy
  8075. */
  8076. getParent(): Nullable<Bone>;
  8077. /**
  8078. * Returns an array containing the root bones
  8079. * @returns an array containing the root bones
  8080. */
  8081. getChildren(): Array<Bone>;
  8082. /**
  8083. * Sets the parent bone
  8084. * @param parent defines the parent (can be null if the bone is the root)
  8085. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8086. */
  8087. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8088. /**
  8089. * Gets the local matrix
  8090. * @returns a matrix
  8091. */
  8092. getLocalMatrix(): Matrix;
  8093. /**
  8094. * Gets the base matrix (initial matrix which remains unchanged)
  8095. * @returns a matrix
  8096. */
  8097. getBaseMatrix(): Matrix;
  8098. /**
  8099. * Gets the rest pose matrix
  8100. * @returns a matrix
  8101. */
  8102. getRestPose(): Matrix;
  8103. /**
  8104. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8105. */
  8106. getWorldMatrix(): Matrix;
  8107. /**
  8108. * Sets the local matrix to rest pose matrix
  8109. */
  8110. returnToRest(): void;
  8111. /**
  8112. * Gets the inverse of the absolute transform matrix.
  8113. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8114. * @returns a matrix
  8115. */
  8116. getInvertedAbsoluteTransform(): Matrix;
  8117. /**
  8118. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8119. * @returns a matrix
  8120. */
  8121. getAbsoluteTransform(): Matrix;
  8122. /**
  8123. * Links with the given transform node.
  8124. * The local matrix of this bone is copied from the transform node every frame.
  8125. * @param transformNode defines the transform node to link to
  8126. */
  8127. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8128. /** Gets or sets current position (in local space) */
  8129. position: Vector3;
  8130. /** Gets or sets current rotation (in local space) */
  8131. rotation: Vector3;
  8132. /** Gets or sets current rotation quaternion (in local space) */
  8133. rotationQuaternion: Quaternion;
  8134. /** Gets or sets current scaling (in local space) */
  8135. scaling: Vector3;
  8136. /**
  8137. * Gets the animation properties override
  8138. */
  8139. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8140. private _decompose;
  8141. private _compose;
  8142. /**
  8143. * Update the base and local matrices
  8144. * @param matrix defines the new base or local matrix
  8145. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8146. * @param updateLocalMatrix defines if the local matrix should be updated
  8147. */
  8148. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8149. /** @hidden */
  8150. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8151. /**
  8152. * Flag the bone as dirty (Forcing it to update everything)
  8153. */
  8154. markAsDirty(): void;
  8155. private _markAsDirtyAndCompose;
  8156. private _markAsDirtyAndDecompose;
  8157. /**
  8158. * Translate the bone in local or world space
  8159. * @param vec The amount to translate the bone
  8160. * @param space The space that the translation is in
  8161. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8162. */
  8163. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8164. /**
  8165. * Set the postion of the bone in local or world space
  8166. * @param position The position to set the bone
  8167. * @param space The space that the position is in
  8168. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8169. */
  8170. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8171. /**
  8172. * Set the absolute position of the bone (world space)
  8173. * @param position The position to set the bone
  8174. * @param mesh The mesh that this bone is attached to
  8175. */
  8176. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8177. /**
  8178. * Scale the bone on the x, y and z axes (in local space)
  8179. * @param x The amount to scale the bone on the x axis
  8180. * @param y The amount to scale the bone on the y axis
  8181. * @param z The amount to scale the bone on the z axis
  8182. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8183. */
  8184. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8185. /**
  8186. * Set the bone scaling in local space
  8187. * @param scale defines the scaling vector
  8188. */
  8189. setScale(scale: Vector3): void;
  8190. /**
  8191. * Gets the current scaling in local space
  8192. * @returns the current scaling vector
  8193. */
  8194. getScale(): Vector3;
  8195. /**
  8196. * Gets the current scaling in local space and stores it in a target vector
  8197. * @param result defines the target vector
  8198. */
  8199. getScaleToRef(result: Vector3): void;
  8200. /**
  8201. * Set the yaw, pitch, and roll of the bone in local or world space
  8202. * @param yaw The rotation of the bone on the y axis
  8203. * @param pitch The rotation of the bone on the x axis
  8204. * @param roll The rotation of the bone on the z axis
  8205. * @param space The space that the axes of rotation are in
  8206. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8207. */
  8208. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8209. /**
  8210. * Add a rotation to the bone on an axis in local or world space
  8211. * @param axis The axis to rotate the bone on
  8212. * @param amount The amount to rotate the bone
  8213. * @param space The space that the axis is in
  8214. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8215. */
  8216. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8217. /**
  8218. * Set the rotation of the bone to a particular axis angle in local or world space
  8219. * @param axis The axis to rotate the bone on
  8220. * @param angle The angle that the bone should be rotated to
  8221. * @param space The space that the axis is in
  8222. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8223. */
  8224. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8225. /**
  8226. * Set the euler rotation of the bone in local of world space
  8227. * @param rotation The euler rotation that the bone should be set to
  8228. * @param space The space that the rotation is in
  8229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8230. */
  8231. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8232. /**
  8233. * Set the quaternion rotation of the bone in local of world space
  8234. * @param quat The quaternion rotation that the bone should be set to
  8235. * @param space The space that the rotation is in
  8236. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8237. */
  8238. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8239. /**
  8240. * Set the rotation matrix of the bone in local of world space
  8241. * @param rotMat The rotation matrix that the bone should be set to
  8242. * @param space The space that the rotation is in
  8243. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8244. */
  8245. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8246. private _rotateWithMatrix;
  8247. private _getNegativeRotationToRef;
  8248. /**
  8249. * Get the position of the bone in local or world space
  8250. * @param space The space that the returned position is in
  8251. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8252. * @returns The position of the bone
  8253. */
  8254. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8255. /**
  8256. * Copy the position of the bone to a vector3 in local or world space
  8257. * @param space The space that the returned position is in
  8258. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8259. * @param result The vector3 to copy the position to
  8260. */
  8261. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8262. /**
  8263. * Get the absolute position of the bone (world space)
  8264. * @param mesh The mesh that this bone is attached to
  8265. * @returns The absolute position of the bone
  8266. */
  8267. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8268. /**
  8269. * Copy the absolute position of the bone (world space) to the result param
  8270. * @param mesh The mesh that this bone is attached to
  8271. * @param result The vector3 to copy the absolute position to
  8272. */
  8273. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8274. /**
  8275. * Compute the absolute transforms of this bone and its children
  8276. */
  8277. computeAbsoluteTransforms(): void;
  8278. /**
  8279. * Get the world direction from an axis that is in the local space of the bone
  8280. * @param localAxis The local direction that is used to compute the world direction
  8281. * @param mesh The mesh that this bone is attached to
  8282. * @returns The world direction
  8283. */
  8284. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8285. /**
  8286. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8287. * @param localAxis The local direction that is used to compute the world direction
  8288. * @param mesh The mesh that this bone is attached to
  8289. * @param result The vector3 that the world direction will be copied to
  8290. */
  8291. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8292. /**
  8293. * Get the euler rotation of the bone in local or world space
  8294. * @param space The space that the rotation should be in
  8295. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8296. * @returns The euler rotation
  8297. */
  8298. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8299. /**
  8300. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8301. * @param space The space that the rotation should be in
  8302. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8303. * @param result The vector3 that the rotation should be copied to
  8304. */
  8305. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8306. /**
  8307. * Get the quaternion rotation of the bone in either local or world space
  8308. * @param space The space that the rotation should be in
  8309. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8310. * @returns The quaternion rotation
  8311. */
  8312. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8313. /**
  8314. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8315. * @param space The space that the rotation should be in
  8316. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8317. * @param result The quaternion that the rotation should be copied to
  8318. */
  8319. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8320. /**
  8321. * Get the rotation matrix of the bone in local or world space
  8322. * @param space The space that the rotation should be in
  8323. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8324. * @returns The rotation matrix
  8325. */
  8326. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8327. /**
  8328. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8329. * @param space The space that the rotation should be in
  8330. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8331. * @param result The quaternion that the rotation should be copied to
  8332. */
  8333. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8334. /**
  8335. * Get the world position of a point that is in the local space of the bone
  8336. * @param position The local position
  8337. * @param mesh The mesh that this bone is attached to
  8338. * @returns The world position
  8339. */
  8340. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8341. /**
  8342. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8343. * @param position The local position
  8344. * @param mesh The mesh that this bone is attached to
  8345. * @param result The vector3 that the world position should be copied to
  8346. */
  8347. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8348. /**
  8349. * Get the local position of a point that is in world space
  8350. * @param position The world position
  8351. * @param mesh The mesh that this bone is attached to
  8352. * @returns The local position
  8353. */
  8354. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8355. /**
  8356. * Get the local position of a point that is in world space and copy it to the result param
  8357. * @param position The world position
  8358. * @param mesh The mesh that this bone is attached to
  8359. * @param result The vector3 that the local position should be copied to
  8360. */
  8361. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8362. }
  8363. }
  8364. declare module "babylonjs/Misc/iInspectable" {
  8365. /**
  8366. * Enum that determines the text-wrapping mode to use.
  8367. */
  8368. export enum InspectableType {
  8369. /**
  8370. * Checkbox for booleans
  8371. */
  8372. Checkbox = 0,
  8373. /**
  8374. * Sliders for numbers
  8375. */
  8376. Slider = 1,
  8377. /**
  8378. * Vector3
  8379. */
  8380. Vector3 = 2,
  8381. /**
  8382. * Quaternions
  8383. */
  8384. Quaternion = 3,
  8385. /**
  8386. * Color3
  8387. */
  8388. Color3 = 4
  8389. }
  8390. /**
  8391. * Interface used to define custom inspectable properties.
  8392. * This interface is used by the inspector to display custom property grids
  8393. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8394. */
  8395. export interface IInspectable {
  8396. /**
  8397. * Gets the label to display
  8398. */
  8399. label: string;
  8400. /**
  8401. * Gets the name of the property to edit
  8402. */
  8403. propertyName: string;
  8404. /**
  8405. * Gets the type of the editor to use
  8406. */
  8407. type: InspectableType;
  8408. /**
  8409. * Gets the minimum value of the property when using in "slider" mode
  8410. */
  8411. min?: number;
  8412. /**
  8413. * Gets the maximum value of the property when using in "slider" mode
  8414. */
  8415. max?: number;
  8416. /**
  8417. * Gets the setp to use when using in "slider" mode
  8418. */
  8419. step?: number;
  8420. }
  8421. }
  8422. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  8423. import { Nullable } from "babylonjs/types";
  8424. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8425. /**
  8426. * This represents the required contract to create a new type of texture loader.
  8427. */
  8428. export interface IInternalTextureLoader {
  8429. /**
  8430. * Defines wether the loader supports cascade loading the different faces.
  8431. */
  8432. supportCascades: boolean;
  8433. /**
  8434. * This returns if the loader support the current file information.
  8435. * @param extension defines the file extension of the file being loaded
  8436. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8437. * @param fallback defines the fallback internal texture if any
  8438. * @param isBase64 defines whether the texture is encoded as a base64
  8439. * @param isBuffer defines whether the texture data are stored as a buffer
  8440. * @returns true if the loader can load the specified file
  8441. */
  8442. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8443. /**
  8444. * Transform the url before loading if required.
  8445. * @param rootUrl the url of the texture
  8446. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8447. * @returns the transformed texture
  8448. */
  8449. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8450. /**
  8451. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8452. * @param rootUrl the url of the texture
  8453. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8454. * @returns the fallback texture
  8455. */
  8456. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8457. /**
  8458. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8459. * @param data contains the texture data
  8460. * @param texture defines the BabylonJS internal texture
  8461. * @param createPolynomials will be true if polynomials have been requested
  8462. * @param onLoad defines the callback to trigger once the texture is ready
  8463. * @param onError defines the callback to trigger in case of error
  8464. */
  8465. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8466. /**
  8467. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8468. * @param data contains the texture data
  8469. * @param texture defines the BabylonJS internal texture
  8470. * @param callback defines the method to call once ready to upload
  8471. */
  8472. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8473. }
  8474. }
  8475. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  8476. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8477. import { Nullable } from "babylonjs/types";
  8478. import { Scene } from "babylonjs/scene";
  8479. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  8480. module "babylonjs/Engines/engine" {
  8481. interface Engine {
  8482. /**
  8483. * Creates a depth stencil cube texture.
  8484. * This is only available in WebGL 2.
  8485. * @param size The size of face edge in the cube texture.
  8486. * @param options The options defining the cube texture.
  8487. * @returns The cube texture
  8488. */
  8489. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8490. /**
  8491. * Creates a cube texture
  8492. * @param rootUrl defines the url where the files to load is located
  8493. * @param scene defines the current scene
  8494. * @param files defines the list of files to load (1 per face)
  8495. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8496. * @param onLoad defines an optional callback raised when the texture is loaded
  8497. * @param onError defines an optional callback raised if there is an issue to load the texture
  8498. * @param format defines the format of the data
  8499. * @param forcedExtension defines the extension to use to pick the right loader
  8500. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8501. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8502. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8503. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8504. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8505. * @returns the cube texture as an InternalTexture
  8506. */
  8507. 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;
  8508. /**
  8509. * Creates a cube texture
  8510. * @param rootUrl defines the url where the files to load is located
  8511. * @param scene defines the current scene
  8512. * @param files defines the list of files to load (1 per face)
  8513. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8514. * @param onLoad defines an optional callback raised when the texture is loaded
  8515. * @param onError defines an optional callback raised if there is an issue to load the texture
  8516. * @param format defines the format of the data
  8517. * @param forcedExtension defines the extension to use to pick the right loader
  8518. * @returns the cube texture as an InternalTexture
  8519. */
  8520. 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;
  8521. /**
  8522. * Creates a cube texture
  8523. * @param rootUrl defines the url where the files to load is located
  8524. * @param scene defines the current scene
  8525. * @param files defines the list of files to load (1 per face)
  8526. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8527. * @param onLoad defines an optional callback raised when the texture is loaded
  8528. * @param onError defines an optional callback raised if there is an issue to load the texture
  8529. * @param format defines the format of the data
  8530. * @param forcedExtension defines the extension to use to pick the right loader
  8531. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8532. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8533. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8534. * @returns the cube texture as an InternalTexture
  8535. */
  8536. 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;
  8537. /** @hidden */
  8538. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8539. /** @hidden */
  8540. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8541. /** @hidden */
  8542. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8543. /** @hidden */
  8544. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8545. }
  8546. }
  8547. }
  8548. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8549. import { Nullable } from "babylonjs/types";
  8550. import { Scene } from "babylonjs/scene";
  8551. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8552. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8553. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  8554. /**
  8555. * Class for creating a cube texture
  8556. */
  8557. export class CubeTexture extends BaseTexture {
  8558. private _delayedOnLoad;
  8559. /**
  8560. * The url of the texture
  8561. */
  8562. url: string;
  8563. /**
  8564. * Gets or sets the center of the bounding box associated with the cube texture.
  8565. * It must define where the camera used to render the texture was set
  8566. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8567. */
  8568. boundingBoxPosition: Vector3;
  8569. private _boundingBoxSize;
  8570. /**
  8571. * Gets or sets the size of the bounding box associated with the cube texture
  8572. * When defined, the cubemap will switch to local mode
  8573. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8574. * @example https://www.babylonjs-playground.com/#RNASML
  8575. */
  8576. /**
  8577. * Returns the bounding box size
  8578. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8579. */
  8580. boundingBoxSize: Vector3;
  8581. protected _rotationY: number;
  8582. /**
  8583. * Sets texture matrix rotation angle around Y axis in radians.
  8584. */
  8585. /**
  8586. * Gets texture matrix rotation angle around Y axis radians.
  8587. */
  8588. rotationY: number;
  8589. /**
  8590. * Are mip maps generated for this texture or not.
  8591. */
  8592. readonly noMipmap: boolean;
  8593. private _noMipmap;
  8594. private _files;
  8595. private _extensions;
  8596. private _textureMatrix;
  8597. private _format;
  8598. private _createPolynomials;
  8599. /** @hidden */
  8600. _prefiltered: boolean;
  8601. /**
  8602. * Creates a cube texture from an array of image urls
  8603. * @param files defines an array of image urls
  8604. * @param scene defines the hosting scene
  8605. * @param noMipmap specifies if mip maps are not used
  8606. * @returns a cube texture
  8607. */
  8608. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8609. /**
  8610. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8611. * @param url defines the url of the prefiltered texture
  8612. * @param scene defines the scene the texture is attached to
  8613. * @param forcedExtension defines the extension of the file if different from the url
  8614. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8615. * @return the prefiltered texture
  8616. */
  8617. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8618. /**
  8619. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8620. * as prefiltered data.
  8621. * @param rootUrl defines the url of the texture or the root name of the six images
  8622. * @param scene defines the scene the texture is attached to
  8623. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8624. * @param noMipmap defines if mipmaps should be created or not
  8625. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8626. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8627. * @param onError defines a callback triggered in case of error during load
  8628. * @param format defines the internal format to use for the texture once loaded
  8629. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8630. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8631. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8632. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8633. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8634. * @return the cube texture
  8635. */
  8636. 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);
  8637. /**
  8638. * Get the current class name of the texture useful for serialization or dynamic coding.
  8639. * @returns "CubeTexture"
  8640. */
  8641. getClassName(): string;
  8642. /**
  8643. * Update the url (and optional buffer) of this texture if url was null during construction.
  8644. * @param url the url of the texture
  8645. * @param forcedExtension defines the extension to use
  8646. * @param onLoad callback called when the texture is loaded (defaults to null)
  8647. */
  8648. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8649. /**
  8650. * Delays loading of the cube texture
  8651. * @param forcedExtension defines the extension to use
  8652. */
  8653. delayLoad(forcedExtension?: string): void;
  8654. /**
  8655. * Returns the reflection texture matrix
  8656. * @returns the reflection texture matrix
  8657. */
  8658. getReflectionTextureMatrix(): Matrix;
  8659. /**
  8660. * Sets the reflection texture matrix
  8661. * @param value Reflection texture matrix
  8662. */
  8663. setReflectionTextureMatrix(value: Matrix): void;
  8664. /**
  8665. * Parses text to create a cube texture
  8666. * @param parsedTexture define the serialized text to read from
  8667. * @param scene defines the hosting scene
  8668. * @param rootUrl defines the root url of the cube texture
  8669. * @returns a cube texture
  8670. */
  8671. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8672. /**
  8673. * Makes a clone, or deep copy, of the cube texture
  8674. * @returns a new cube texture
  8675. */
  8676. clone(): CubeTexture;
  8677. }
  8678. }
  8679. declare module "babylonjs/Shaders/postprocess.vertex" {
  8680. /** @hidden */
  8681. export var postprocessVertexShader: {
  8682. name: string;
  8683. shader: string;
  8684. };
  8685. }
  8686. declare module "babylonjs/Cameras/targetCamera" {
  8687. import { Nullable } from "babylonjs/types";
  8688. import { Camera } from "babylonjs/Cameras/camera";
  8689. import { Scene } from "babylonjs/scene";
  8690. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8691. /**
  8692. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8693. * This is the base of the follow, arc rotate cameras and Free camera
  8694. * @see http://doc.babylonjs.com/features/cameras
  8695. */
  8696. export class TargetCamera extends Camera {
  8697. private static _RigCamTransformMatrix;
  8698. private static _TargetTransformMatrix;
  8699. private static _TargetFocalPoint;
  8700. /**
  8701. * Define the current direction the camera is moving to
  8702. */
  8703. cameraDirection: Vector3;
  8704. /**
  8705. * Define the current rotation the camera is rotating to
  8706. */
  8707. cameraRotation: Vector2;
  8708. /**
  8709. * When set, the up vector of the camera will be updated by the rotation of the camera
  8710. */
  8711. updateUpVectorFromRotation: boolean;
  8712. private _tmpQuaternion;
  8713. /**
  8714. * Define the current rotation of the camera
  8715. */
  8716. rotation: Vector3;
  8717. /**
  8718. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8719. */
  8720. rotationQuaternion: Quaternion;
  8721. /**
  8722. * Define the current speed of the camera
  8723. */
  8724. speed: number;
  8725. /**
  8726. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8727. * around all axis.
  8728. */
  8729. noRotationConstraint: boolean;
  8730. /**
  8731. * Define the current target of the camera as an object or a position.
  8732. */
  8733. lockedTarget: any;
  8734. /** @hidden */
  8735. _currentTarget: Vector3;
  8736. /** @hidden */
  8737. _initialFocalDistance: number;
  8738. /** @hidden */
  8739. _viewMatrix: Matrix;
  8740. /** @hidden */
  8741. _camMatrix: Matrix;
  8742. /** @hidden */
  8743. _cameraTransformMatrix: Matrix;
  8744. /** @hidden */
  8745. _cameraRotationMatrix: Matrix;
  8746. /** @hidden */
  8747. _referencePoint: Vector3;
  8748. /** @hidden */
  8749. _transformedReferencePoint: Vector3;
  8750. protected _globalCurrentTarget: Vector3;
  8751. protected _globalCurrentUpVector: Vector3;
  8752. /** @hidden */
  8753. _reset: () => void;
  8754. private _defaultUp;
  8755. /**
  8756. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8757. * This is the base of the follow, arc rotate cameras and Free camera
  8758. * @see http://doc.babylonjs.com/features/cameras
  8759. * @param name Defines the name of the camera in the scene
  8760. * @param position Defines the start position of the camera in the scene
  8761. * @param scene Defines the scene the camera belongs to
  8762. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8763. */
  8764. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8765. /**
  8766. * Gets the position in front of the camera at a given distance.
  8767. * @param distance The distance from the camera we want the position to be
  8768. * @returns the position
  8769. */
  8770. getFrontPosition(distance: number): Vector3;
  8771. /** @hidden */
  8772. _getLockedTargetPosition(): Nullable<Vector3>;
  8773. private _storedPosition;
  8774. private _storedRotation;
  8775. private _storedRotationQuaternion;
  8776. /**
  8777. * Store current camera state of the camera (fov, position, rotation, etc..)
  8778. * @returns the camera
  8779. */
  8780. storeState(): Camera;
  8781. /**
  8782. * Restored camera state. You must call storeState() first
  8783. * @returns whether it was successful or not
  8784. * @hidden
  8785. */
  8786. _restoreStateValues(): boolean;
  8787. /** @hidden */
  8788. _initCache(): void;
  8789. /** @hidden */
  8790. _updateCache(ignoreParentClass?: boolean): void;
  8791. /** @hidden */
  8792. _isSynchronizedViewMatrix(): boolean;
  8793. /** @hidden */
  8794. _computeLocalCameraSpeed(): number;
  8795. /**
  8796. * Defines the target the camera should look at.
  8797. * This will automatically adapt alpha beta and radius to fit within the new target.
  8798. * @param target Defines the new target as a Vector or a mesh
  8799. */
  8800. setTarget(target: Vector3): void;
  8801. /**
  8802. * Return the current target position of the camera. This value is expressed in local space.
  8803. * @returns the target position
  8804. */
  8805. getTarget(): Vector3;
  8806. /** @hidden */
  8807. _decideIfNeedsToMove(): boolean;
  8808. /** @hidden */
  8809. _updatePosition(): void;
  8810. /** @hidden */
  8811. _checkInputs(): void;
  8812. protected _updateCameraRotationMatrix(): void;
  8813. /**
  8814. * 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)
  8815. * @returns the current camera
  8816. */
  8817. private _rotateUpVectorWithCameraRotationMatrix;
  8818. private _cachedRotationZ;
  8819. private _cachedQuaternionRotationZ;
  8820. /** @hidden */
  8821. _getViewMatrix(): Matrix;
  8822. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8823. /**
  8824. * @hidden
  8825. */
  8826. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8827. /**
  8828. * @hidden
  8829. */
  8830. _updateRigCameras(): void;
  8831. private _getRigCamPositionAndTarget;
  8832. /**
  8833. * Gets the current object class name.
  8834. * @return the class name
  8835. */
  8836. getClassName(): string;
  8837. }
  8838. }
  8839. declare module "babylonjs/Cameras/cameraInputsManager" {
  8840. import { Nullable } from "babylonjs/types";
  8841. import { Camera } from "babylonjs/Cameras/camera";
  8842. /**
  8843. * @ignore
  8844. * This is a list of all the different input types that are available in the application.
  8845. * Fo instance: ArcRotateCameraGamepadInput...
  8846. */
  8847. export var CameraInputTypes: {};
  8848. /**
  8849. * This is the contract to implement in order to create a new input class.
  8850. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8851. */
  8852. export interface ICameraInput<TCamera extends Camera> {
  8853. /**
  8854. * Defines the camera the input is attached to.
  8855. */
  8856. camera: Nullable<TCamera>;
  8857. /**
  8858. * Gets the class name of the current intput.
  8859. * @returns the class name
  8860. */
  8861. getClassName(): string;
  8862. /**
  8863. * Get the friendly name associated with the input class.
  8864. * @returns the input friendly name
  8865. */
  8866. getSimpleName(): string;
  8867. /**
  8868. * Attach the input controls to a specific dom element to get the input from.
  8869. * @param element Defines the element the controls should be listened from
  8870. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8871. */
  8872. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8873. /**
  8874. * Detach the current controls from the specified dom element.
  8875. * @param element Defines the element to stop listening the inputs from
  8876. */
  8877. detachControl(element: Nullable<HTMLElement>): void;
  8878. /**
  8879. * Update the current camera state depending on the inputs that have been used this frame.
  8880. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8881. */
  8882. checkInputs?: () => void;
  8883. }
  8884. /**
  8885. * Represents a map of input types to input instance or input index to input instance.
  8886. */
  8887. export interface CameraInputsMap<TCamera extends Camera> {
  8888. /**
  8889. * Accessor to the input by input type.
  8890. */
  8891. [name: string]: ICameraInput<TCamera>;
  8892. /**
  8893. * Accessor to the input by input index.
  8894. */
  8895. [idx: number]: ICameraInput<TCamera>;
  8896. }
  8897. /**
  8898. * This represents the input manager used within a camera.
  8899. * It helps dealing with all the different kind of input attached to a camera.
  8900. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8901. */
  8902. export class CameraInputsManager<TCamera extends Camera> {
  8903. /**
  8904. * Defines the list of inputs attahed to the camera.
  8905. */
  8906. attached: CameraInputsMap<TCamera>;
  8907. /**
  8908. * Defines the dom element the camera is collecting inputs from.
  8909. * This is null if the controls have not been attached.
  8910. */
  8911. attachedElement: Nullable<HTMLElement>;
  8912. /**
  8913. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8914. */
  8915. noPreventDefault: boolean;
  8916. /**
  8917. * Defined the camera the input manager belongs to.
  8918. */
  8919. camera: TCamera;
  8920. /**
  8921. * Update the current camera state depending on the inputs that have been used this frame.
  8922. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8923. */
  8924. checkInputs: () => void;
  8925. /**
  8926. * Instantiate a new Camera Input Manager.
  8927. * @param camera Defines the camera the input manager blongs to
  8928. */
  8929. constructor(camera: TCamera);
  8930. /**
  8931. * Add an input method to a camera
  8932. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8933. * @param input camera input method
  8934. */
  8935. add(input: ICameraInput<TCamera>): void;
  8936. /**
  8937. * Remove a specific input method from a camera
  8938. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8939. * @param inputToRemove camera input method
  8940. */
  8941. remove(inputToRemove: ICameraInput<TCamera>): void;
  8942. /**
  8943. * Remove a specific input type from a camera
  8944. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8945. * @param inputType the type of the input to remove
  8946. */
  8947. removeByType(inputType: string): void;
  8948. private _addCheckInputs;
  8949. /**
  8950. * Attach the input controls to the currently attached dom element to listen the events from.
  8951. * @param input Defines the input to attach
  8952. */
  8953. attachInput(input: ICameraInput<TCamera>): void;
  8954. /**
  8955. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8956. * @param element Defines the dom element to collect the events from
  8957. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8958. */
  8959. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8960. /**
  8961. * Detach the current manager inputs controls from a specific dom element.
  8962. * @param element Defines the dom element to collect the events from
  8963. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8964. */
  8965. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8966. /**
  8967. * Rebuild the dynamic inputCheck function from the current list of
  8968. * defined inputs in the manager.
  8969. */
  8970. rebuildInputCheck(): void;
  8971. /**
  8972. * Remove all attached input methods from a camera
  8973. */
  8974. clear(): void;
  8975. /**
  8976. * Serialize the current input manager attached to a camera.
  8977. * This ensures than once parsed,
  8978. * the input associated to the camera will be identical to the current ones
  8979. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8980. */
  8981. serialize(serializedCamera: any): void;
  8982. /**
  8983. * Parses an input manager serialized JSON to restore the previous list of inputs
  8984. * and states associated to a camera.
  8985. * @param parsedCamera Defines the JSON to parse
  8986. */
  8987. parse(parsedCamera: any): void;
  8988. }
  8989. }
  8990. declare module "babylonjs/Events/keyboardEvents" {
  8991. /**
  8992. * Gather the list of keyboard event types as constants.
  8993. */
  8994. export class KeyboardEventTypes {
  8995. /**
  8996. * The keydown event is fired when a key becomes active (pressed).
  8997. */
  8998. static readonly KEYDOWN: number;
  8999. /**
  9000. * The keyup event is fired when a key has been released.
  9001. */
  9002. static readonly KEYUP: number;
  9003. }
  9004. /**
  9005. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9006. */
  9007. export class KeyboardInfo {
  9008. /**
  9009. * Defines the type of event (KeyboardEventTypes)
  9010. */
  9011. type: number;
  9012. /**
  9013. * Defines the related dom event
  9014. */
  9015. event: KeyboardEvent;
  9016. /**
  9017. * Instantiates a new keyboard info.
  9018. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9019. * @param type Defines the type of event (KeyboardEventTypes)
  9020. * @param event Defines the related dom event
  9021. */
  9022. constructor(
  9023. /**
  9024. * Defines the type of event (KeyboardEventTypes)
  9025. */
  9026. type: number,
  9027. /**
  9028. * Defines the related dom event
  9029. */
  9030. event: KeyboardEvent);
  9031. }
  9032. /**
  9033. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9034. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9035. */
  9036. export class KeyboardInfoPre extends KeyboardInfo {
  9037. /**
  9038. * Defines the type of event (KeyboardEventTypes)
  9039. */
  9040. type: number;
  9041. /**
  9042. * Defines the related dom event
  9043. */
  9044. event: KeyboardEvent;
  9045. /**
  9046. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9047. */
  9048. skipOnPointerObservable: boolean;
  9049. /**
  9050. * Instantiates a new keyboard pre info.
  9051. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9052. * @param type Defines the type of event (KeyboardEventTypes)
  9053. * @param event Defines the related dom event
  9054. */
  9055. constructor(
  9056. /**
  9057. * Defines the type of event (KeyboardEventTypes)
  9058. */
  9059. type: number,
  9060. /**
  9061. * Defines the related dom event
  9062. */
  9063. event: KeyboardEvent);
  9064. }
  9065. }
  9066. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  9067. import { Nullable } from "babylonjs/types";
  9068. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  9069. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  9070. /**
  9071. * Manage the keyboard inputs to control the movement of a free camera.
  9072. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9073. */
  9074. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9075. /**
  9076. * Defines the camera the input is attached to.
  9077. */
  9078. camera: FreeCamera;
  9079. /**
  9080. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9081. */
  9082. keysUp: number[];
  9083. /**
  9084. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9085. */
  9086. keysDown: number[];
  9087. /**
  9088. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9089. */
  9090. keysLeft: number[];
  9091. /**
  9092. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9093. */
  9094. keysRight: number[];
  9095. private _keys;
  9096. private _onCanvasBlurObserver;
  9097. private _onKeyboardObserver;
  9098. private _engine;
  9099. private _scene;
  9100. /**
  9101. * Attach the input controls to a specific dom element to get the input from.
  9102. * @param element Defines the element the controls should be listened from
  9103. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9104. */
  9105. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9106. /**
  9107. * Detach the current controls from the specified dom element.
  9108. * @param element Defines the element to stop listening the inputs from
  9109. */
  9110. detachControl(element: Nullable<HTMLElement>): void;
  9111. /**
  9112. * Update the current camera state depending on the inputs that have been used this frame.
  9113. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9114. */
  9115. checkInputs(): void;
  9116. /**
  9117. * Gets the class name of the current intput.
  9118. * @returns the class name
  9119. */
  9120. getClassName(): string;
  9121. /** @hidden */
  9122. _onLostFocus(): void;
  9123. /**
  9124. * Get the friendly name associated with the input class.
  9125. * @returns the input friendly name
  9126. */
  9127. getSimpleName(): string;
  9128. }
  9129. }
  9130. declare module "babylonjs/Lights/shadowLight" {
  9131. import { Camera } from "babylonjs/Cameras/camera";
  9132. import { Scene } from "babylonjs/scene";
  9133. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  9134. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9135. import { Light } from "babylonjs/Lights/light";
  9136. /**
  9137. * Interface describing all the common properties and methods a shadow light needs to implement.
  9138. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9139. * as well as binding the different shadow properties to the effects.
  9140. */
  9141. export interface IShadowLight extends Light {
  9142. /**
  9143. * The light id in the scene (used in scene.findLighById for instance)
  9144. */
  9145. id: string;
  9146. /**
  9147. * The position the shdow will be casted from.
  9148. */
  9149. position: Vector3;
  9150. /**
  9151. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9152. */
  9153. direction: Vector3;
  9154. /**
  9155. * The transformed position. Position of the light in world space taking parenting in account.
  9156. */
  9157. transformedPosition: Vector3;
  9158. /**
  9159. * The transformed direction. Direction of the light in world space taking parenting in account.
  9160. */
  9161. transformedDirection: Vector3;
  9162. /**
  9163. * The friendly name of the light in the scene.
  9164. */
  9165. name: string;
  9166. /**
  9167. * Defines the shadow projection clipping minimum z value.
  9168. */
  9169. shadowMinZ: number;
  9170. /**
  9171. * Defines the shadow projection clipping maximum z value.
  9172. */
  9173. shadowMaxZ: number;
  9174. /**
  9175. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9176. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9177. */
  9178. computeTransformedInformation(): boolean;
  9179. /**
  9180. * Gets the scene the light belongs to.
  9181. * @returns The scene
  9182. */
  9183. getScene(): Scene;
  9184. /**
  9185. * Callback defining a custom Projection Matrix Builder.
  9186. * This can be used to override the default projection matrix computation.
  9187. */
  9188. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9189. /**
  9190. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9191. * @param matrix The materix to updated with the projection information
  9192. * @param viewMatrix The transform matrix of the light
  9193. * @param renderList The list of mesh to render in the map
  9194. * @returns The current light
  9195. */
  9196. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9197. /**
  9198. * Gets the current depth scale used in ESM.
  9199. * @returns The scale
  9200. */
  9201. getDepthScale(): number;
  9202. /**
  9203. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9204. * @returns true if a cube texture needs to be use
  9205. */
  9206. needCube(): boolean;
  9207. /**
  9208. * Detects if the projection matrix requires to be recomputed this frame.
  9209. * @returns true if it requires to be recomputed otherwise, false.
  9210. */
  9211. needProjectionMatrixCompute(): boolean;
  9212. /**
  9213. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9214. */
  9215. forceProjectionMatrixCompute(): void;
  9216. /**
  9217. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9218. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9219. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9220. */
  9221. getShadowDirection(faceIndex?: number): Vector3;
  9222. /**
  9223. * Gets the minZ used for shadow according to both the scene and the light.
  9224. * @param activeCamera The camera we are returning the min for
  9225. * @returns the depth min z
  9226. */
  9227. getDepthMinZ(activeCamera: Camera): number;
  9228. /**
  9229. * Gets the maxZ used for shadow according to both the scene and the light.
  9230. * @param activeCamera The camera we are returning the max for
  9231. * @returns the depth max z
  9232. */
  9233. getDepthMaxZ(activeCamera: Camera): number;
  9234. }
  9235. /**
  9236. * Base implementation IShadowLight
  9237. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9238. */
  9239. export abstract class ShadowLight extends Light implements IShadowLight {
  9240. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9241. protected _position: Vector3;
  9242. protected _setPosition(value: Vector3): void;
  9243. /**
  9244. * Sets the position the shadow will be casted from. Also use as the light position for both
  9245. * point and spot lights.
  9246. */
  9247. /**
  9248. * Sets the position the shadow will be casted from. Also use as the light position for both
  9249. * point and spot lights.
  9250. */
  9251. position: Vector3;
  9252. protected _direction: Vector3;
  9253. protected _setDirection(value: Vector3): void;
  9254. /**
  9255. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9256. * Also use as the light direction on spot and directional lights.
  9257. */
  9258. /**
  9259. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9260. * Also use as the light direction on spot and directional lights.
  9261. */
  9262. direction: Vector3;
  9263. private _shadowMinZ;
  9264. /**
  9265. * Gets the shadow projection clipping minimum z value.
  9266. */
  9267. /**
  9268. * Sets the shadow projection clipping minimum z value.
  9269. */
  9270. shadowMinZ: number;
  9271. private _shadowMaxZ;
  9272. /**
  9273. * Sets the shadow projection clipping maximum z value.
  9274. */
  9275. /**
  9276. * Gets the shadow projection clipping maximum z value.
  9277. */
  9278. shadowMaxZ: number;
  9279. /**
  9280. * Callback defining a custom Projection Matrix Builder.
  9281. * This can be used to override the default projection matrix computation.
  9282. */
  9283. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9284. /**
  9285. * The transformed position. Position of the light in world space taking parenting in account.
  9286. */
  9287. transformedPosition: Vector3;
  9288. /**
  9289. * The transformed direction. Direction of the light in world space taking parenting in account.
  9290. */
  9291. transformedDirection: Vector3;
  9292. private _needProjectionMatrixCompute;
  9293. /**
  9294. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9295. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9296. */
  9297. computeTransformedInformation(): boolean;
  9298. /**
  9299. * Return the depth scale used for the shadow map.
  9300. * @returns the depth scale.
  9301. */
  9302. getDepthScale(): number;
  9303. /**
  9304. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9305. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9306. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9307. */
  9308. getShadowDirection(faceIndex?: number): Vector3;
  9309. /**
  9310. * Returns the ShadowLight absolute position in the World.
  9311. * @returns the position vector in world space
  9312. */
  9313. getAbsolutePosition(): Vector3;
  9314. /**
  9315. * Sets the ShadowLight direction toward the passed target.
  9316. * @param target The point to target in local space
  9317. * @returns the updated ShadowLight direction
  9318. */
  9319. setDirectionToTarget(target: Vector3): Vector3;
  9320. /**
  9321. * Returns the light rotation in euler definition.
  9322. * @returns the x y z rotation in local space.
  9323. */
  9324. getRotation(): Vector3;
  9325. /**
  9326. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9327. * @returns true if a cube texture needs to be use
  9328. */
  9329. needCube(): boolean;
  9330. /**
  9331. * Detects if the projection matrix requires to be recomputed this frame.
  9332. * @returns true if it requires to be recomputed otherwise, false.
  9333. */
  9334. needProjectionMatrixCompute(): boolean;
  9335. /**
  9336. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9337. */
  9338. forceProjectionMatrixCompute(): void;
  9339. /** @hidden */
  9340. _initCache(): void;
  9341. /** @hidden */
  9342. _isSynchronized(): boolean;
  9343. /**
  9344. * Computes the world matrix of the node
  9345. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9346. * @returns the world matrix
  9347. */
  9348. computeWorldMatrix(force?: boolean): Matrix;
  9349. /**
  9350. * Gets the minZ used for shadow according to both the scene and the light.
  9351. * @param activeCamera The camera we are returning the min for
  9352. * @returns the depth min z
  9353. */
  9354. getDepthMinZ(activeCamera: Camera): number;
  9355. /**
  9356. * Gets the maxZ used for shadow according to both the scene and the light.
  9357. * @param activeCamera The camera we are returning the max for
  9358. * @returns the depth max z
  9359. */
  9360. getDepthMaxZ(activeCamera: Camera): number;
  9361. /**
  9362. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9363. * @param matrix The materix to updated with the projection information
  9364. * @param viewMatrix The transform matrix of the light
  9365. * @param renderList The list of mesh to render in the map
  9366. * @returns The current light
  9367. */
  9368. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9369. }
  9370. }
  9371. declare module "babylonjs/Materials/materialHelper" {
  9372. import { Nullable } from "babylonjs/types";
  9373. import { Scene } from "babylonjs/scene";
  9374. import { Engine } from "babylonjs/Engines/engine";
  9375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9376. import { Light } from "babylonjs/Lights/light";
  9377. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9378. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9379. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9380. /**
  9381. * "Static Class" containing the most commonly used helper while dealing with material for
  9382. * rendering purpose.
  9383. *
  9384. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9385. *
  9386. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9387. */
  9388. export class MaterialHelper {
  9389. /**
  9390. * Bind the current view position to an effect.
  9391. * @param effect The effect to be bound
  9392. * @param scene The scene the eyes position is used from
  9393. */
  9394. static BindEyePosition(effect: Effect, scene: Scene): void;
  9395. /**
  9396. * Helps preparing the defines values about the UVs in used in the effect.
  9397. * UVs are shared as much as we can accross channels in the shaders.
  9398. * @param texture The texture we are preparing the UVs for
  9399. * @param defines The defines to update
  9400. * @param key The channel key "diffuse", "specular"... used in the shader
  9401. */
  9402. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9403. /**
  9404. * Binds a texture matrix value to its corrsponding uniform
  9405. * @param texture The texture to bind the matrix for
  9406. * @param uniformBuffer The uniform buffer receivin the data
  9407. * @param key The channel key "diffuse", "specular"... used in the shader
  9408. */
  9409. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9410. /**
  9411. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9412. * @param mesh defines the current mesh
  9413. * @param scene defines the current scene
  9414. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9415. * @param pointsCloud defines if point cloud rendering has to be turned on
  9416. * @param fogEnabled defines if fog has to be turned on
  9417. * @param alphaTest defines if alpha testing has to be turned on
  9418. * @param defines defines the current list of defines
  9419. */
  9420. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9421. /**
  9422. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9423. * @param scene defines the current scene
  9424. * @param engine defines the current engine
  9425. * @param defines specifies the list of active defines
  9426. * @param useInstances defines if instances have to be turned on
  9427. * @param useClipPlane defines if clip plane have to be turned on
  9428. */
  9429. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9430. /**
  9431. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9432. * @param mesh The mesh containing the geometry data we will draw
  9433. * @param defines The defines to update
  9434. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9435. * @param useBones Precise whether bones should be used or not (override mesh info)
  9436. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9437. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9438. * @returns false if defines are considered not dirty and have not been checked
  9439. */
  9440. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9441. /**
  9442. * Prepares the defines related to multiview
  9443. * @param scene The scene we are intending to draw
  9444. * @param defines The defines to update
  9445. */
  9446. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9447. /**
  9448. * Prepares the defines related to the light information passed in parameter
  9449. * @param scene The scene we are intending to draw
  9450. * @param mesh The mesh the effect is compiling for
  9451. * @param defines The defines to update
  9452. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9453. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9454. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9455. * @returns true if normals will be required for the rest of the effect
  9456. */
  9457. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9458. /**
  9459. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9460. * that won t be acctive due to defines being turned off.
  9461. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9462. * @param samplersList The samplers list
  9463. * @param defines The defines helping in the list generation
  9464. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9465. */
  9466. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9467. /**
  9468. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9469. * @param defines The defines to update while falling back
  9470. * @param fallbacks The authorized effect fallbacks
  9471. * @param maxSimultaneousLights The maximum number of lights allowed
  9472. * @param rank the current rank of the Effect
  9473. * @returns The newly affected rank
  9474. */
  9475. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9476. /**
  9477. * Prepares the list of attributes required for morph targets according to the effect defines.
  9478. * @param attribs The current list of supported attribs
  9479. * @param mesh The mesh to prepare the morph targets attributes for
  9480. * @param defines The current Defines of the effect
  9481. */
  9482. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9483. /**
  9484. * Prepares the list of attributes required for bones according to the effect defines.
  9485. * @param attribs The current list of supported attribs
  9486. * @param mesh The mesh to prepare the bones attributes for
  9487. * @param defines The current Defines of the effect
  9488. * @param fallbacks The current efffect fallback strategy
  9489. */
  9490. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9491. /**
  9492. * Prepares the list of attributes required for instances according to the effect defines.
  9493. * @param attribs The current list of supported attribs
  9494. * @param defines The current Defines of the effect
  9495. */
  9496. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9497. /**
  9498. * Binds the light shadow information to the effect for the given mesh.
  9499. * @param light The light containing the generator
  9500. * @param scene The scene the lights belongs to
  9501. * @param mesh The mesh we are binding the information to render
  9502. * @param lightIndex The light index in the effect used to render the mesh
  9503. * @param effect The effect we are binding the data to
  9504. */
  9505. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9506. /**
  9507. * Binds the light information to the effect.
  9508. * @param light The light containing the generator
  9509. * @param effect The effect we are binding the data to
  9510. * @param lightIndex The light index in the effect used to render
  9511. */
  9512. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9513. /**
  9514. * Binds the lights information from the scene to the effect for the given mesh.
  9515. * @param scene The scene the lights belongs to
  9516. * @param mesh The mesh we are binding the information to render
  9517. * @param effect The effect we are binding the data to
  9518. * @param defines The generated defines for the effect
  9519. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9520. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9521. */
  9522. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9523. private static _tempFogColor;
  9524. /**
  9525. * Binds the fog information from the scene to the effect for the given mesh.
  9526. * @param scene The scene the lights belongs to
  9527. * @param mesh The mesh we are binding the information to render
  9528. * @param effect The effect we are binding the data to
  9529. * @param linearSpace Defines if the fog effect is applied in linear space
  9530. */
  9531. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9532. /**
  9533. * Binds the bones information from the mesh to the effect.
  9534. * @param mesh The mesh we are binding the information to render
  9535. * @param effect The effect we are binding the data to
  9536. */
  9537. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9538. /**
  9539. * Binds the morph targets information from the mesh to the effect.
  9540. * @param abstractMesh The mesh we are binding the information to render
  9541. * @param effect The effect we are binding the data to
  9542. */
  9543. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9544. /**
  9545. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9546. * @param defines The generated defines used in the effect
  9547. * @param effect The effect we are binding the data to
  9548. * @param scene The scene we are willing to render with logarithmic scale for
  9549. */
  9550. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9551. /**
  9552. * Binds the clip plane information from the scene to the effect.
  9553. * @param scene The scene the clip plane information are extracted from
  9554. * @param effect The effect we are binding the data to
  9555. */
  9556. static BindClipPlane(effect: Effect, scene: Scene): void;
  9557. }
  9558. }
  9559. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9560. /** @hidden */
  9561. export var kernelBlurVaryingDeclaration: {
  9562. name: string;
  9563. shader: string;
  9564. };
  9565. }
  9566. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9567. /** @hidden */
  9568. export var kernelBlurFragment: {
  9569. name: string;
  9570. shader: string;
  9571. };
  9572. }
  9573. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9574. /** @hidden */
  9575. export var kernelBlurFragment2: {
  9576. name: string;
  9577. shader: string;
  9578. };
  9579. }
  9580. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9581. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9582. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9583. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9584. /** @hidden */
  9585. export var kernelBlurPixelShader: {
  9586. name: string;
  9587. shader: string;
  9588. };
  9589. }
  9590. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9591. /** @hidden */
  9592. export var kernelBlurVertex: {
  9593. name: string;
  9594. shader: string;
  9595. };
  9596. }
  9597. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9598. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9599. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9600. /** @hidden */
  9601. export var kernelBlurVertexShader: {
  9602. name: string;
  9603. shader: string;
  9604. };
  9605. }
  9606. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9607. import { Vector2 } from "babylonjs/Maths/math";
  9608. import { Nullable } from "babylonjs/types";
  9609. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9610. import { Camera } from "babylonjs/Cameras/camera";
  9611. import { Effect } from "babylonjs/Materials/effect";
  9612. import { Engine } from "babylonjs/Engines/engine";
  9613. import "babylonjs/Shaders/kernelBlur.fragment";
  9614. import "babylonjs/Shaders/kernelBlur.vertex";
  9615. /**
  9616. * The Blur Post Process which blurs an image based on a kernel and direction.
  9617. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9618. */
  9619. export class BlurPostProcess extends PostProcess {
  9620. /** The direction in which to blur the image. */
  9621. direction: Vector2;
  9622. private blockCompilation;
  9623. protected _kernel: number;
  9624. protected _idealKernel: number;
  9625. protected _packedFloat: boolean;
  9626. private _staticDefines;
  9627. /**
  9628. * Sets the length in pixels of the blur sample region
  9629. */
  9630. /**
  9631. * Gets the length in pixels of the blur sample region
  9632. */
  9633. kernel: number;
  9634. /**
  9635. * Sets wether or not the blur needs to unpack/repack floats
  9636. */
  9637. /**
  9638. * Gets wether or not the blur is unpacking/repacking floats
  9639. */
  9640. packedFloat: boolean;
  9641. /**
  9642. * Creates a new instance BlurPostProcess
  9643. * @param name The name of the effect.
  9644. * @param direction The direction in which to blur the image.
  9645. * @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.
  9646. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9647. * @param camera The camera to apply the render pass to.
  9648. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9649. * @param engine The engine which the post process will be applied. (default: current engine)
  9650. * @param reusable If the post process can be reused on the same frame. (default: false)
  9651. * @param textureType Type of textures used when performing the post process. (default: 0)
  9652. * @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)
  9653. */
  9654. constructor(name: string,
  9655. /** The direction in which to blur the image. */
  9656. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9657. /**
  9658. * Updates the effect with the current post process compile time values and recompiles the shader.
  9659. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9660. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9661. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9662. * @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
  9663. * @param onCompiled Called when the shader has been compiled.
  9664. * @param onError Called if there is an error when compiling a shader.
  9665. */
  9666. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9667. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9668. /**
  9669. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9670. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9671. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9672. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9673. * The gaps between physical kernels are compensated for in the weighting of the samples
  9674. * @param idealKernel Ideal blur kernel.
  9675. * @return Nearest best kernel.
  9676. */
  9677. protected _nearestBestKernel(idealKernel: number): number;
  9678. /**
  9679. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9680. * @param x The point on the Gaussian distribution to sample.
  9681. * @return the value of the Gaussian function at x.
  9682. */
  9683. protected _gaussianWeight(x: number): number;
  9684. /**
  9685. * Generates a string that can be used as a floating point number in GLSL.
  9686. * @param x Value to print.
  9687. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9688. * @return GLSL float string.
  9689. */
  9690. protected _glslFloat(x: number, decimalFigures?: number): string;
  9691. }
  9692. }
  9693. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9694. /** @hidden */
  9695. export var shadowMapPixelShader: {
  9696. name: string;
  9697. shader: string;
  9698. };
  9699. }
  9700. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9701. /** @hidden */
  9702. export var bonesDeclaration: {
  9703. name: string;
  9704. shader: string;
  9705. };
  9706. }
  9707. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9708. /** @hidden */
  9709. export var morphTargetsVertexGlobalDeclaration: {
  9710. name: string;
  9711. shader: string;
  9712. };
  9713. }
  9714. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9715. /** @hidden */
  9716. export var morphTargetsVertexDeclaration: {
  9717. name: string;
  9718. shader: string;
  9719. };
  9720. }
  9721. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9722. /** @hidden */
  9723. export var instancesDeclaration: {
  9724. name: string;
  9725. shader: string;
  9726. };
  9727. }
  9728. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9729. /** @hidden */
  9730. export var helperFunctions: {
  9731. name: string;
  9732. shader: string;
  9733. };
  9734. }
  9735. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9736. /** @hidden */
  9737. export var morphTargetsVertex: {
  9738. name: string;
  9739. shader: string;
  9740. };
  9741. }
  9742. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9743. /** @hidden */
  9744. export var instancesVertex: {
  9745. name: string;
  9746. shader: string;
  9747. };
  9748. }
  9749. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9750. /** @hidden */
  9751. export var bonesVertex: {
  9752. name: string;
  9753. shader: string;
  9754. };
  9755. }
  9756. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9757. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9758. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9759. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9760. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9761. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9762. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9763. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9764. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9765. /** @hidden */
  9766. export var shadowMapVertexShader: {
  9767. name: string;
  9768. shader: string;
  9769. };
  9770. }
  9771. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9772. /** @hidden */
  9773. export var depthBoxBlurPixelShader: {
  9774. name: string;
  9775. shader: string;
  9776. };
  9777. }
  9778. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9779. import { Nullable } from "babylonjs/types";
  9780. import { Scene } from "babylonjs/scene";
  9781. import { Matrix } from "babylonjs/Maths/math";
  9782. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9784. import { Mesh } from "babylonjs/Meshes/mesh";
  9785. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9786. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9787. import { Effect } from "babylonjs/Materials/effect";
  9788. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9789. import "babylonjs/Shaders/shadowMap.fragment";
  9790. import "babylonjs/Shaders/shadowMap.vertex";
  9791. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9792. import { Observable } from "babylonjs/Misc/observable";
  9793. /**
  9794. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9795. */
  9796. export interface ICustomShaderOptions {
  9797. /**
  9798. * Gets or sets the custom shader name to use
  9799. */
  9800. shaderName: string;
  9801. /**
  9802. * The list of attribute names used in the shader
  9803. */
  9804. attributes?: string[];
  9805. /**
  9806. * The list of unifrom names used in the shader
  9807. */
  9808. uniforms?: string[];
  9809. /**
  9810. * The list of sampler names used in the shader
  9811. */
  9812. samplers?: string[];
  9813. /**
  9814. * The list of defines used in the shader
  9815. */
  9816. defines?: string[];
  9817. }
  9818. /**
  9819. * Interface to implement to create a shadow generator compatible with BJS.
  9820. */
  9821. export interface IShadowGenerator {
  9822. /**
  9823. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9824. * @returns The render target texture if present otherwise, null
  9825. */
  9826. getShadowMap(): Nullable<RenderTargetTexture>;
  9827. /**
  9828. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9829. * @returns The render target texture if the shadow map is present otherwise, null
  9830. */
  9831. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9832. /**
  9833. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9834. * @param subMesh The submesh we want to render in the shadow map
  9835. * @param useInstances Defines wether will draw in the map using instances
  9836. * @returns true if ready otherwise, false
  9837. */
  9838. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9839. /**
  9840. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9841. * @param defines Defines of the material we want to update
  9842. * @param lightIndex Index of the light in the enabled light list of the material
  9843. */
  9844. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9845. /**
  9846. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9847. * defined in the generator but impacting the effect).
  9848. * It implies the unifroms available on the materials are the standard BJS ones.
  9849. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9850. * @param effect The effect we are binfing the information for
  9851. */
  9852. bindShadowLight(lightIndex: string, effect: Effect): void;
  9853. /**
  9854. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9855. * (eq to shadow prjection matrix * light transform matrix)
  9856. * @returns The transform matrix used to create the shadow map
  9857. */
  9858. getTransformMatrix(): Matrix;
  9859. /**
  9860. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9861. * Cube and 2D textures for instance.
  9862. */
  9863. recreateShadowMap(): void;
  9864. /**
  9865. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9866. * @param onCompiled Callback triggered at the and of the effects compilation
  9867. * @param options Sets of optional options forcing the compilation with different modes
  9868. */
  9869. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9870. useInstances: boolean;
  9871. }>): void;
  9872. /**
  9873. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9874. * @param options Sets of optional options forcing the compilation with different modes
  9875. * @returns A promise that resolves when the compilation completes
  9876. */
  9877. forceCompilationAsync(options?: Partial<{
  9878. useInstances: boolean;
  9879. }>): Promise<void>;
  9880. /**
  9881. * Serializes the shadow generator setup to a json object.
  9882. * @returns The serialized JSON object
  9883. */
  9884. serialize(): any;
  9885. /**
  9886. * Disposes the Shadow map and related Textures and effects.
  9887. */
  9888. dispose(): void;
  9889. }
  9890. /**
  9891. * Default implementation IShadowGenerator.
  9892. * This is the main object responsible of generating shadows in the framework.
  9893. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9894. */
  9895. export class ShadowGenerator implements IShadowGenerator {
  9896. /**
  9897. * Shadow generator mode None: no filtering applied.
  9898. */
  9899. static readonly FILTER_NONE: number;
  9900. /**
  9901. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9902. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9903. */
  9904. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9905. /**
  9906. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9907. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9908. */
  9909. static readonly FILTER_POISSONSAMPLING: number;
  9910. /**
  9911. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9912. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9913. */
  9914. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9915. /**
  9916. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9917. * edge artifacts on steep falloff.
  9918. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9919. */
  9920. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9921. /**
  9922. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9923. * edge artifacts on steep falloff.
  9924. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9925. */
  9926. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9927. /**
  9928. * Shadow generator mode PCF: Percentage Closer Filtering
  9929. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9930. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9931. */
  9932. static readonly FILTER_PCF: number;
  9933. /**
  9934. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9935. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9936. * Contact Hardening
  9937. */
  9938. static readonly FILTER_PCSS: number;
  9939. /**
  9940. * Reserved for PCF and PCSS
  9941. * Highest Quality.
  9942. *
  9943. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9944. *
  9945. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9946. */
  9947. static readonly QUALITY_HIGH: number;
  9948. /**
  9949. * Reserved for PCF and PCSS
  9950. * Good tradeoff for quality/perf cross devices
  9951. *
  9952. * Execute PCF on a 3*3 kernel.
  9953. *
  9954. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9955. */
  9956. static readonly QUALITY_MEDIUM: number;
  9957. /**
  9958. * Reserved for PCF and PCSS
  9959. * The lowest quality but the fastest.
  9960. *
  9961. * Execute PCF on a 1*1 kernel.
  9962. *
  9963. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9964. */
  9965. static readonly QUALITY_LOW: number;
  9966. /** Gets or sets the custom shader name to use */
  9967. customShaderOptions: ICustomShaderOptions;
  9968. /**
  9969. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9970. */
  9971. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9972. /**
  9973. * Observable triggered before a mesh is rendered in the shadow map.
  9974. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9975. */
  9976. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9977. private _bias;
  9978. /**
  9979. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9980. */
  9981. /**
  9982. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9983. */
  9984. bias: number;
  9985. private _normalBias;
  9986. /**
  9987. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9988. */
  9989. /**
  9990. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9991. */
  9992. normalBias: number;
  9993. private _blurBoxOffset;
  9994. /**
  9995. * Gets the blur box offset: offset applied during the blur pass.
  9996. * Only useful if useKernelBlur = false
  9997. */
  9998. /**
  9999. * Sets the blur box offset: offset applied during the blur pass.
  10000. * Only useful if useKernelBlur = false
  10001. */
  10002. blurBoxOffset: number;
  10003. private _blurScale;
  10004. /**
  10005. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  10006. * 2 means half of the size.
  10007. */
  10008. /**
  10009. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  10010. * 2 means half of the size.
  10011. */
  10012. blurScale: number;
  10013. private _blurKernel;
  10014. /**
  10015. * Gets the blur kernel: kernel size of the blur pass.
  10016. * Only useful if useKernelBlur = true
  10017. */
  10018. /**
  10019. * Sets the blur kernel: kernel size of the blur pass.
  10020. * Only useful if useKernelBlur = true
  10021. */
  10022. blurKernel: number;
  10023. private _useKernelBlur;
  10024. /**
  10025. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  10026. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10027. */
  10028. /**
  10029. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  10030. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10031. */
  10032. useKernelBlur: boolean;
  10033. private _depthScale;
  10034. /**
  10035. * Gets the depth scale used in ESM mode.
  10036. */
  10037. /**
  10038. * Sets the depth scale used in ESM mode.
  10039. * This can override the scale stored on the light.
  10040. */
  10041. depthScale: number;
  10042. private _filter;
  10043. /**
  10044. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  10045. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10046. */
  10047. /**
  10048. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  10049. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10050. */
  10051. filter: number;
  10052. /**
  10053. * Gets if the current filter is set to Poisson Sampling.
  10054. */
  10055. /**
  10056. * Sets the current filter to Poisson Sampling.
  10057. */
  10058. usePoissonSampling: boolean;
  10059. /**
  10060. * Gets if the current filter is set to ESM.
  10061. */
  10062. /**
  10063. * Sets the current filter is to ESM.
  10064. */
  10065. useExponentialShadowMap: boolean;
  10066. /**
  10067. * Gets if the current filter is set to filtered ESM.
  10068. */
  10069. /**
  10070. * Gets if the current filter is set to filtered ESM.
  10071. */
  10072. useBlurExponentialShadowMap: boolean;
  10073. /**
  10074. * Gets if the current filter is set to "close ESM" (using the inverse of the
  10075. * exponential to prevent steep falloff artifacts).
  10076. */
  10077. /**
  10078. * Sets the current filter to "close ESM" (using the inverse of the
  10079. * exponential to prevent steep falloff artifacts).
  10080. */
  10081. useCloseExponentialShadowMap: boolean;
  10082. /**
  10083. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  10084. * exponential to prevent steep falloff artifacts).
  10085. */
  10086. /**
  10087. * Sets the current filter to filtered "close ESM" (using the inverse of the
  10088. * exponential to prevent steep falloff artifacts).
  10089. */
  10090. useBlurCloseExponentialShadowMap: boolean;
  10091. /**
  10092. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  10093. */
  10094. /**
  10095. * Sets the current filter to "PCF" (percentage closer filtering).
  10096. */
  10097. usePercentageCloserFiltering: boolean;
  10098. private _filteringQuality;
  10099. /**
  10100. * Gets the PCF or PCSS Quality.
  10101. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10102. */
  10103. /**
  10104. * Sets the PCF or PCSS Quality.
  10105. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10106. */
  10107. filteringQuality: number;
  10108. /**
  10109. * Gets if the current filter is set to "PCSS" (contact hardening).
  10110. */
  10111. /**
  10112. * Sets the current filter to "PCSS" (contact hardening).
  10113. */
  10114. useContactHardeningShadow: boolean;
  10115. private _contactHardeningLightSizeUVRatio;
  10116. /**
  10117. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10118. * Using a ratio helps keeping shape stability independently of the map size.
  10119. *
  10120. * It does not account for the light projection as it was having too much
  10121. * instability during the light setup or during light position changes.
  10122. *
  10123. * Only valid if useContactHardeningShadow is true.
  10124. */
  10125. /**
  10126. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10127. * Using a ratio helps keeping shape stability independently of the map size.
  10128. *
  10129. * It does not account for the light projection as it was having too much
  10130. * instability during the light setup or during light position changes.
  10131. *
  10132. * Only valid if useContactHardeningShadow is true.
  10133. */
  10134. contactHardeningLightSizeUVRatio: number;
  10135. private _darkness;
  10136. /**
  10137. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10138. * 0 means strongest and 1 would means no shadow.
  10139. * @returns the darkness.
  10140. */
  10141. getDarkness(): number;
  10142. /**
  10143. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10144. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10145. * @returns the shadow generator allowing fluent coding.
  10146. */
  10147. setDarkness(darkness: number): ShadowGenerator;
  10148. private _transparencyShadow;
  10149. /**
  10150. * Sets the ability to have transparent shadow (boolean).
  10151. * @param transparent True if transparent else False
  10152. * @returns the shadow generator allowing fluent coding
  10153. */
  10154. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10155. private _shadowMap;
  10156. private _shadowMap2;
  10157. /**
  10158. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10159. * @returns The render target texture if present otherwise, null
  10160. */
  10161. getShadowMap(): Nullable<RenderTargetTexture>;
  10162. /**
  10163. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10164. * @returns The render target texture if the shadow map is present otherwise, null
  10165. */
  10166. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10167. /**
  10168. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10169. * @param mesh Mesh to add
  10170. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10171. * @returns the Shadow Generator itself
  10172. */
  10173. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10174. /**
  10175. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10176. * @param mesh Mesh to remove
  10177. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10178. * @returns the Shadow Generator itself
  10179. */
  10180. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10181. /**
  10182. * Controls the extent to which the shadows fade out at the edge of the frustum
  10183. * Used only by directionals and spots
  10184. */
  10185. frustumEdgeFalloff: number;
  10186. private _light;
  10187. /**
  10188. * Returns the associated light object.
  10189. * @returns the light generating the shadow
  10190. */
  10191. getLight(): IShadowLight;
  10192. /**
  10193. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10194. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10195. * It might on the other hand introduce peter panning.
  10196. */
  10197. forceBackFacesOnly: boolean;
  10198. private _scene;
  10199. private _lightDirection;
  10200. private _effect;
  10201. private _viewMatrix;
  10202. private _projectionMatrix;
  10203. private _transformMatrix;
  10204. private _cachedPosition;
  10205. private _cachedDirection;
  10206. private _cachedDefines;
  10207. private _currentRenderID;
  10208. private _boxBlurPostprocess;
  10209. private _kernelBlurXPostprocess;
  10210. private _kernelBlurYPostprocess;
  10211. private _blurPostProcesses;
  10212. private _mapSize;
  10213. private _currentFaceIndex;
  10214. private _currentFaceIndexCache;
  10215. private _textureType;
  10216. private _defaultTextureMatrix;
  10217. /** @hidden */
  10218. static _SceneComponentInitialization: (scene: Scene) => void;
  10219. /**
  10220. * Creates a ShadowGenerator object.
  10221. * A ShadowGenerator is the required tool to use the shadows.
  10222. * Each light casting shadows needs to use its own ShadowGenerator.
  10223. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10224. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10225. * @param light The light object generating the shadows.
  10226. * @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.
  10227. */
  10228. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10229. private _initializeGenerator;
  10230. private _initializeShadowMap;
  10231. private _initializeBlurRTTAndPostProcesses;
  10232. private _renderForShadowMap;
  10233. private _renderSubMeshForShadowMap;
  10234. private _applyFilterValues;
  10235. /**
  10236. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10237. * @param onCompiled Callback triggered at the and of the effects compilation
  10238. * @param options Sets of optional options forcing the compilation with different modes
  10239. */
  10240. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10241. useInstances: boolean;
  10242. }>): void;
  10243. /**
  10244. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10245. * @param options Sets of optional options forcing the compilation with different modes
  10246. * @returns A promise that resolves when the compilation completes
  10247. */
  10248. forceCompilationAsync(options?: Partial<{
  10249. useInstances: boolean;
  10250. }>): Promise<void>;
  10251. /**
  10252. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10253. * @param subMesh The submesh we want to render in the shadow map
  10254. * @param useInstances Defines wether will draw in the map using instances
  10255. * @returns true if ready otherwise, false
  10256. */
  10257. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10258. /**
  10259. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10260. * @param defines Defines of the material we want to update
  10261. * @param lightIndex Index of the light in the enabled light list of the material
  10262. */
  10263. prepareDefines(defines: any, lightIndex: number): void;
  10264. /**
  10265. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10266. * defined in the generator but impacting the effect).
  10267. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10268. * @param effect The effect we are binfing the information for
  10269. */
  10270. bindShadowLight(lightIndex: string, effect: Effect): void;
  10271. /**
  10272. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10273. * (eq to shadow prjection matrix * light transform matrix)
  10274. * @returns The transform matrix used to create the shadow map
  10275. */
  10276. getTransformMatrix(): Matrix;
  10277. /**
  10278. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10279. * Cube and 2D textures for instance.
  10280. */
  10281. recreateShadowMap(): void;
  10282. private _disposeBlurPostProcesses;
  10283. private _disposeRTTandPostProcesses;
  10284. /**
  10285. * Disposes the ShadowGenerator.
  10286. * Returns nothing.
  10287. */
  10288. dispose(): void;
  10289. /**
  10290. * Serializes the shadow generator setup to a json object.
  10291. * @returns The serialized JSON object
  10292. */
  10293. serialize(): any;
  10294. /**
  10295. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10296. * @param parsedShadowGenerator The JSON object to parse
  10297. * @param scene The scene to create the shadow map for
  10298. * @returns The parsed shadow generator
  10299. */
  10300. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10301. }
  10302. }
  10303. declare module "babylonjs/Lights/light" {
  10304. import { Nullable } from "babylonjs/types";
  10305. import { Scene } from "babylonjs/scene";
  10306. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10307. import { Node } from "babylonjs/node";
  10308. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10309. import { Effect } from "babylonjs/Materials/effect";
  10310. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10311. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10312. /**
  10313. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10314. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10315. * 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.
  10316. */
  10317. export abstract class Light extends Node {
  10318. /**
  10319. * Falloff Default: light is falling off following the material specification:
  10320. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10321. */
  10322. static readonly FALLOFF_DEFAULT: number;
  10323. /**
  10324. * Falloff Physical: light is falling off following the inverse squared distance law.
  10325. */
  10326. static readonly FALLOFF_PHYSICAL: number;
  10327. /**
  10328. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10329. * to enhance interoperability with other engines.
  10330. */
  10331. static readonly FALLOFF_GLTF: number;
  10332. /**
  10333. * Falloff Standard: light is falling off like in the standard material
  10334. * to enhance interoperability with other materials.
  10335. */
  10336. static readonly FALLOFF_STANDARD: number;
  10337. /**
  10338. * If every light affecting the material is in this lightmapMode,
  10339. * material.lightmapTexture adds or multiplies
  10340. * (depends on material.useLightmapAsShadowmap)
  10341. * after every other light calculations.
  10342. */
  10343. static readonly LIGHTMAP_DEFAULT: number;
  10344. /**
  10345. * material.lightmapTexture as only diffuse lighting from this light
  10346. * adds only specular lighting from this light
  10347. * adds dynamic shadows
  10348. */
  10349. static readonly LIGHTMAP_SPECULAR: number;
  10350. /**
  10351. * material.lightmapTexture as only lighting
  10352. * no light calculation from this light
  10353. * only adds dynamic shadows from this light
  10354. */
  10355. static readonly LIGHTMAP_SHADOWSONLY: number;
  10356. /**
  10357. * Each light type uses the default quantity according to its type:
  10358. * point/spot lights use luminous intensity
  10359. * directional lights use illuminance
  10360. */
  10361. static readonly INTENSITYMODE_AUTOMATIC: number;
  10362. /**
  10363. * lumen (lm)
  10364. */
  10365. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10366. /**
  10367. * candela (lm/sr)
  10368. */
  10369. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10370. /**
  10371. * lux (lm/m^2)
  10372. */
  10373. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10374. /**
  10375. * nit (cd/m^2)
  10376. */
  10377. static readonly INTENSITYMODE_LUMINANCE: number;
  10378. /**
  10379. * Light type const id of the point light.
  10380. */
  10381. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10382. /**
  10383. * Light type const id of the directional light.
  10384. */
  10385. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10386. /**
  10387. * Light type const id of the spot light.
  10388. */
  10389. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10390. /**
  10391. * Light type const id of the hemispheric light.
  10392. */
  10393. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10394. /**
  10395. * Diffuse gives the basic color to an object.
  10396. */
  10397. diffuse: Color3;
  10398. /**
  10399. * Specular produces a highlight color on an object.
  10400. * Note: This is note affecting PBR materials.
  10401. */
  10402. specular: Color3;
  10403. /**
  10404. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10405. * falling off base on range or angle.
  10406. * This can be set to any values in Light.FALLOFF_x.
  10407. *
  10408. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10409. * other types of materials.
  10410. */
  10411. falloffType: number;
  10412. /**
  10413. * Strength of the light.
  10414. * Note: By default it is define in the framework own unit.
  10415. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10416. */
  10417. intensity: number;
  10418. private _range;
  10419. protected _inverseSquaredRange: number;
  10420. /**
  10421. * Defines how far from the source the light is impacting in scene units.
  10422. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10423. */
  10424. /**
  10425. * Defines how far from the source the light is impacting in scene units.
  10426. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10427. */
  10428. range: number;
  10429. /**
  10430. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10431. * of light.
  10432. */
  10433. private _photometricScale;
  10434. private _intensityMode;
  10435. /**
  10436. * Gets the photometric scale used to interpret the intensity.
  10437. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10438. */
  10439. /**
  10440. * Sets the photometric scale used to interpret the intensity.
  10441. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10442. */
  10443. intensityMode: number;
  10444. private _radius;
  10445. /**
  10446. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10447. */
  10448. /**
  10449. * sets the light radius used by PBR Materials to simulate soft area lights.
  10450. */
  10451. radius: number;
  10452. private _renderPriority;
  10453. /**
  10454. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10455. * exceeding the number allowed of the materials.
  10456. */
  10457. renderPriority: number;
  10458. private _shadowEnabled;
  10459. /**
  10460. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10461. * the current shadow generator.
  10462. */
  10463. /**
  10464. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10465. * the current shadow generator.
  10466. */
  10467. shadowEnabled: boolean;
  10468. private _includedOnlyMeshes;
  10469. /**
  10470. * Gets the only meshes impacted by this light.
  10471. */
  10472. /**
  10473. * Sets the only meshes impacted by this light.
  10474. */
  10475. includedOnlyMeshes: AbstractMesh[];
  10476. private _excludedMeshes;
  10477. /**
  10478. * Gets the meshes not impacted by this light.
  10479. */
  10480. /**
  10481. * Sets the meshes not impacted by this light.
  10482. */
  10483. excludedMeshes: AbstractMesh[];
  10484. private _excludeWithLayerMask;
  10485. /**
  10486. * Gets the layer id use to find what meshes are not impacted by the light.
  10487. * Inactive if 0
  10488. */
  10489. /**
  10490. * Sets the layer id use to find what meshes are not impacted by the light.
  10491. * Inactive if 0
  10492. */
  10493. excludeWithLayerMask: number;
  10494. private _includeOnlyWithLayerMask;
  10495. /**
  10496. * Gets the layer id use to find what meshes are impacted by the light.
  10497. * Inactive if 0
  10498. */
  10499. /**
  10500. * Sets the layer id use to find what meshes are impacted by the light.
  10501. * Inactive if 0
  10502. */
  10503. includeOnlyWithLayerMask: number;
  10504. private _lightmapMode;
  10505. /**
  10506. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10507. */
  10508. /**
  10509. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10510. */
  10511. lightmapMode: number;
  10512. /**
  10513. * Shadow generator associted to the light.
  10514. * @hidden Internal use only.
  10515. */
  10516. _shadowGenerator: Nullable<IShadowGenerator>;
  10517. /**
  10518. * @hidden Internal use only.
  10519. */
  10520. _excludedMeshesIds: string[];
  10521. /**
  10522. * @hidden Internal use only.
  10523. */
  10524. _includedOnlyMeshesIds: string[];
  10525. /**
  10526. * The current light unifom buffer.
  10527. * @hidden Internal use only.
  10528. */
  10529. _uniformBuffer: UniformBuffer;
  10530. /**
  10531. * Creates a Light object in the scene.
  10532. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10533. * @param name The firendly name of the light
  10534. * @param scene The scene the light belongs too
  10535. */
  10536. constructor(name: string, scene: Scene);
  10537. protected abstract _buildUniformLayout(): void;
  10538. /**
  10539. * Sets the passed Effect "effect" with the Light information.
  10540. * @param effect The effect to update
  10541. * @param lightIndex The index of the light in the effect to update
  10542. * @returns The light
  10543. */
  10544. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10545. /**
  10546. * Returns the string "Light".
  10547. * @returns the class name
  10548. */
  10549. getClassName(): string;
  10550. /** @hidden */
  10551. readonly _isLight: boolean;
  10552. /**
  10553. * Converts the light information to a readable string for debug purpose.
  10554. * @param fullDetails Supports for multiple levels of logging within scene loading
  10555. * @returns the human readable light info
  10556. */
  10557. toString(fullDetails?: boolean): string;
  10558. /** @hidden */
  10559. protected _syncParentEnabledState(): void;
  10560. /**
  10561. * Set the enabled state of this node.
  10562. * @param value - the new enabled state
  10563. */
  10564. setEnabled(value: boolean): void;
  10565. /**
  10566. * Returns the Light associated shadow generator if any.
  10567. * @return the associated shadow generator.
  10568. */
  10569. getShadowGenerator(): Nullable<IShadowGenerator>;
  10570. /**
  10571. * Returns a Vector3, the absolute light position in the World.
  10572. * @returns the world space position of the light
  10573. */
  10574. getAbsolutePosition(): Vector3;
  10575. /**
  10576. * Specifies if the light will affect the passed mesh.
  10577. * @param mesh The mesh to test against the light
  10578. * @return true the mesh is affected otherwise, false.
  10579. */
  10580. canAffectMesh(mesh: AbstractMesh): boolean;
  10581. /**
  10582. * Sort function to order lights for rendering.
  10583. * @param a First Light object to compare to second.
  10584. * @param b Second Light object to compare first.
  10585. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10586. */
  10587. static CompareLightsPriority(a: Light, b: Light): number;
  10588. /**
  10589. * Releases resources associated with this node.
  10590. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10591. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10592. */
  10593. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10594. /**
  10595. * Returns the light type ID (integer).
  10596. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10597. */
  10598. getTypeID(): number;
  10599. /**
  10600. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10601. * @returns the scaled intensity in intensity mode unit
  10602. */
  10603. getScaledIntensity(): number;
  10604. /**
  10605. * Returns a new Light object, named "name", from the current one.
  10606. * @param name The name of the cloned light
  10607. * @returns the new created light
  10608. */
  10609. clone(name: string): Nullable<Light>;
  10610. /**
  10611. * Serializes the current light into a Serialization object.
  10612. * @returns the serialized object.
  10613. */
  10614. serialize(): any;
  10615. /**
  10616. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10617. * This new light is named "name" and added to the passed scene.
  10618. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10619. * @param name The friendly name of the light
  10620. * @param scene The scene the new light will belong to
  10621. * @returns the constructor function
  10622. */
  10623. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10624. /**
  10625. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10626. * @param parsedLight The JSON representation of the light
  10627. * @param scene The scene to create the parsed light in
  10628. * @returns the created light after parsing
  10629. */
  10630. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10631. private _hookArrayForExcluded;
  10632. private _hookArrayForIncludedOnly;
  10633. private _resyncMeshes;
  10634. /**
  10635. * Forces the meshes to update their light related information in their rendering used effects
  10636. * @hidden Internal Use Only
  10637. */
  10638. _markMeshesAsLightDirty(): void;
  10639. /**
  10640. * Recomputes the cached photometric scale if needed.
  10641. */
  10642. private _computePhotometricScale;
  10643. /**
  10644. * Returns the Photometric Scale according to the light type and intensity mode.
  10645. */
  10646. private _getPhotometricScale;
  10647. /**
  10648. * Reorder the light in the scene according to their defined priority.
  10649. * @hidden Internal Use Only
  10650. */
  10651. _reorderLightsInScene(): void;
  10652. /**
  10653. * Prepares the list of defines specific to the light type.
  10654. * @param defines the list of defines
  10655. * @param lightIndex defines the index of the light for the effect
  10656. */
  10657. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10658. }
  10659. }
  10660. declare module "babylonjs/Actions/action" {
  10661. import { Observable } from "babylonjs/Misc/observable";
  10662. import { Condition } from "babylonjs/Actions/condition";
  10663. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10664. import { ActionManager } from "babylonjs/Actions/actionManager";
  10665. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10666. /**
  10667. * Interface used to define Action
  10668. */
  10669. export interface IAction {
  10670. /**
  10671. * Trigger for the action
  10672. */
  10673. trigger: number;
  10674. /** Options of the trigger */
  10675. triggerOptions: any;
  10676. /**
  10677. * Gets the trigger parameters
  10678. * @returns the trigger parameters
  10679. */
  10680. getTriggerParameter(): any;
  10681. /**
  10682. * Internal only - executes current action event
  10683. * @hidden
  10684. */
  10685. _executeCurrent(evt?: ActionEvent): void;
  10686. /**
  10687. * Serialize placeholder for child classes
  10688. * @param parent of child
  10689. * @returns the serialized object
  10690. */
  10691. serialize(parent: any): any;
  10692. /**
  10693. * Internal only
  10694. * @hidden
  10695. */
  10696. _prepare(): void;
  10697. /**
  10698. * Internal only - manager for action
  10699. * @hidden
  10700. */
  10701. _actionManager: AbstractActionManager;
  10702. }
  10703. /**
  10704. * The action to be carried out following a trigger
  10705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10706. */
  10707. export class Action implements IAction {
  10708. /** the trigger, with or without parameters, for the action */
  10709. triggerOptions: any;
  10710. /**
  10711. * Trigger for the action
  10712. */
  10713. trigger: number;
  10714. /**
  10715. * Internal only - manager for action
  10716. * @hidden
  10717. */
  10718. _actionManager: ActionManager;
  10719. private _nextActiveAction;
  10720. private _child;
  10721. private _condition?;
  10722. private _triggerParameter;
  10723. /**
  10724. * An event triggered prior to action being executed.
  10725. */
  10726. onBeforeExecuteObservable: Observable<Action>;
  10727. /**
  10728. * Creates a new Action
  10729. * @param triggerOptions the trigger, with or without parameters, for the action
  10730. * @param condition an optional determinant of action
  10731. */
  10732. constructor(
  10733. /** the trigger, with or without parameters, for the action */
  10734. triggerOptions: any, condition?: Condition);
  10735. /**
  10736. * Internal only
  10737. * @hidden
  10738. */
  10739. _prepare(): void;
  10740. /**
  10741. * Gets the trigger parameters
  10742. * @returns the trigger parameters
  10743. */
  10744. getTriggerParameter(): any;
  10745. /**
  10746. * Internal only - executes current action event
  10747. * @hidden
  10748. */
  10749. _executeCurrent(evt?: ActionEvent): void;
  10750. /**
  10751. * Execute placeholder for child classes
  10752. * @param evt optional action event
  10753. */
  10754. execute(evt?: ActionEvent): void;
  10755. /**
  10756. * Skips to next active action
  10757. */
  10758. skipToNextActiveAction(): void;
  10759. /**
  10760. * Adds action to chain of actions, may be a DoNothingAction
  10761. * @param action defines the next action to execute
  10762. * @returns The action passed in
  10763. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10764. */
  10765. then(action: Action): Action;
  10766. /**
  10767. * Internal only
  10768. * @hidden
  10769. */
  10770. _getProperty(propertyPath: string): string;
  10771. /**
  10772. * Internal only
  10773. * @hidden
  10774. */
  10775. _getEffectiveTarget(target: any, propertyPath: string): any;
  10776. /**
  10777. * Serialize placeholder for child classes
  10778. * @param parent of child
  10779. * @returns the serialized object
  10780. */
  10781. serialize(parent: any): any;
  10782. /**
  10783. * Internal only called by serialize
  10784. * @hidden
  10785. */
  10786. protected _serialize(serializedAction: any, parent?: any): any;
  10787. /**
  10788. * Internal only
  10789. * @hidden
  10790. */
  10791. static _SerializeValueAsString: (value: any) => string;
  10792. /**
  10793. * Internal only
  10794. * @hidden
  10795. */
  10796. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10797. name: string;
  10798. targetType: string;
  10799. value: string;
  10800. };
  10801. }
  10802. }
  10803. declare module "babylonjs/Actions/condition" {
  10804. import { ActionManager } from "babylonjs/Actions/actionManager";
  10805. /**
  10806. * A Condition applied to an Action
  10807. */
  10808. export class Condition {
  10809. /**
  10810. * Internal only - manager for action
  10811. * @hidden
  10812. */
  10813. _actionManager: ActionManager;
  10814. /**
  10815. * Internal only
  10816. * @hidden
  10817. */
  10818. _evaluationId: number;
  10819. /**
  10820. * Internal only
  10821. * @hidden
  10822. */
  10823. _currentResult: boolean;
  10824. /**
  10825. * Creates a new Condition
  10826. * @param actionManager the manager of the action the condition is applied to
  10827. */
  10828. constructor(actionManager: ActionManager);
  10829. /**
  10830. * Check if the current condition is valid
  10831. * @returns a boolean
  10832. */
  10833. isValid(): boolean;
  10834. /**
  10835. * Internal only
  10836. * @hidden
  10837. */
  10838. _getProperty(propertyPath: string): string;
  10839. /**
  10840. * Internal only
  10841. * @hidden
  10842. */
  10843. _getEffectiveTarget(target: any, propertyPath: string): any;
  10844. /**
  10845. * Serialize placeholder for child classes
  10846. * @returns the serialized object
  10847. */
  10848. serialize(): any;
  10849. /**
  10850. * Internal only
  10851. * @hidden
  10852. */
  10853. protected _serialize(serializedCondition: any): any;
  10854. }
  10855. /**
  10856. * Defines specific conditional operators as extensions of Condition
  10857. */
  10858. export class ValueCondition extends Condition {
  10859. /** path to specify the property of the target the conditional operator uses */
  10860. propertyPath: string;
  10861. /** the value compared by the conditional operator against the current value of the property */
  10862. value: any;
  10863. /** the conditional operator, default ValueCondition.IsEqual */
  10864. operator: number;
  10865. /**
  10866. * Internal only
  10867. * @hidden
  10868. */
  10869. private static _IsEqual;
  10870. /**
  10871. * Internal only
  10872. * @hidden
  10873. */
  10874. private static _IsDifferent;
  10875. /**
  10876. * Internal only
  10877. * @hidden
  10878. */
  10879. private static _IsGreater;
  10880. /**
  10881. * Internal only
  10882. * @hidden
  10883. */
  10884. private static _IsLesser;
  10885. /**
  10886. * returns the number for IsEqual
  10887. */
  10888. static readonly IsEqual: number;
  10889. /**
  10890. * Returns the number for IsDifferent
  10891. */
  10892. static readonly IsDifferent: number;
  10893. /**
  10894. * Returns the number for IsGreater
  10895. */
  10896. static readonly IsGreater: number;
  10897. /**
  10898. * Returns the number for IsLesser
  10899. */
  10900. static readonly IsLesser: number;
  10901. /**
  10902. * Internal only The action manager for the condition
  10903. * @hidden
  10904. */
  10905. _actionManager: ActionManager;
  10906. /**
  10907. * Internal only
  10908. * @hidden
  10909. */
  10910. private _target;
  10911. /**
  10912. * Internal only
  10913. * @hidden
  10914. */
  10915. private _effectiveTarget;
  10916. /**
  10917. * Internal only
  10918. * @hidden
  10919. */
  10920. private _property;
  10921. /**
  10922. * Creates a new ValueCondition
  10923. * @param actionManager manager for the action the condition applies to
  10924. * @param target for the action
  10925. * @param propertyPath path to specify the property of the target the conditional operator uses
  10926. * @param value the value compared by the conditional operator against the current value of the property
  10927. * @param operator the conditional operator, default ValueCondition.IsEqual
  10928. */
  10929. constructor(actionManager: ActionManager, target: any,
  10930. /** path to specify the property of the target the conditional operator uses */
  10931. propertyPath: string,
  10932. /** the value compared by the conditional operator against the current value of the property */
  10933. value: any,
  10934. /** the conditional operator, default ValueCondition.IsEqual */
  10935. operator?: number);
  10936. /**
  10937. * Compares the given value with the property value for the specified conditional operator
  10938. * @returns the result of the comparison
  10939. */
  10940. isValid(): boolean;
  10941. /**
  10942. * Serialize the ValueCondition into a JSON compatible object
  10943. * @returns serialization object
  10944. */
  10945. serialize(): any;
  10946. /**
  10947. * Gets the name of the conditional operator for the ValueCondition
  10948. * @param operator the conditional operator
  10949. * @returns the name
  10950. */
  10951. static GetOperatorName(operator: number): string;
  10952. }
  10953. /**
  10954. * Defines a predicate condition as an extension of Condition
  10955. */
  10956. export class PredicateCondition extends Condition {
  10957. /** defines the predicate function used to validate the condition */
  10958. predicate: () => boolean;
  10959. /**
  10960. * Internal only - manager for action
  10961. * @hidden
  10962. */
  10963. _actionManager: ActionManager;
  10964. /**
  10965. * Creates a new PredicateCondition
  10966. * @param actionManager manager for the action the condition applies to
  10967. * @param predicate defines the predicate function used to validate the condition
  10968. */
  10969. constructor(actionManager: ActionManager,
  10970. /** defines the predicate function used to validate the condition */
  10971. predicate: () => boolean);
  10972. /**
  10973. * @returns the validity of the predicate condition
  10974. */
  10975. isValid(): boolean;
  10976. }
  10977. /**
  10978. * Defines a state condition as an extension of Condition
  10979. */
  10980. export class StateCondition extends Condition {
  10981. /** Value to compare with target state */
  10982. value: string;
  10983. /**
  10984. * Internal only - manager for action
  10985. * @hidden
  10986. */
  10987. _actionManager: ActionManager;
  10988. /**
  10989. * Internal only
  10990. * @hidden
  10991. */
  10992. private _target;
  10993. /**
  10994. * Creates a new StateCondition
  10995. * @param actionManager manager for the action the condition applies to
  10996. * @param target of the condition
  10997. * @param value to compare with target state
  10998. */
  10999. constructor(actionManager: ActionManager, target: any,
  11000. /** Value to compare with target state */
  11001. value: string);
  11002. /**
  11003. * Gets a boolean indicating if the current condition is met
  11004. * @returns the validity of the state
  11005. */
  11006. isValid(): boolean;
  11007. /**
  11008. * Serialize the StateCondition into a JSON compatible object
  11009. * @returns serialization object
  11010. */
  11011. serialize(): any;
  11012. }
  11013. }
  11014. declare module "babylonjs/Actions/directActions" {
  11015. import { Action } from "babylonjs/Actions/action";
  11016. import { Condition } from "babylonjs/Actions/condition";
  11017. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  11018. /**
  11019. * This defines an action responsible to toggle a boolean once triggered.
  11020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11021. */
  11022. export class SwitchBooleanAction extends Action {
  11023. /**
  11024. * The path to the boolean property in the target object
  11025. */
  11026. propertyPath: string;
  11027. private _target;
  11028. private _effectiveTarget;
  11029. private _property;
  11030. /**
  11031. * Instantiate the action
  11032. * @param triggerOptions defines the trigger options
  11033. * @param target defines the object containing the boolean
  11034. * @param propertyPath defines the path to the boolean property in the target object
  11035. * @param condition defines the trigger related conditions
  11036. */
  11037. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  11038. /** @hidden */
  11039. _prepare(): void;
  11040. /**
  11041. * Execute the action toggle the boolean value.
  11042. */
  11043. execute(): void;
  11044. /**
  11045. * Serializes the actions and its related information.
  11046. * @param parent defines the object to serialize in
  11047. * @returns the serialized object
  11048. */
  11049. serialize(parent: any): any;
  11050. }
  11051. /**
  11052. * This defines an action responsible to set a the state field of the target
  11053. * to a desired value once triggered.
  11054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11055. */
  11056. export class SetStateAction extends Action {
  11057. /**
  11058. * The value to store in the state field.
  11059. */
  11060. value: string;
  11061. private _target;
  11062. /**
  11063. * Instantiate the action
  11064. * @param triggerOptions defines the trigger options
  11065. * @param target defines the object containing the state property
  11066. * @param value defines the value to store in the state field
  11067. * @param condition defines the trigger related conditions
  11068. */
  11069. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  11070. /**
  11071. * Execute the action and store the value on the target state property.
  11072. */
  11073. execute(): void;
  11074. /**
  11075. * Serializes the actions and its related information.
  11076. * @param parent defines the object to serialize in
  11077. * @returns the serialized object
  11078. */
  11079. serialize(parent: any): any;
  11080. }
  11081. /**
  11082. * This defines an action responsible to set a property of the target
  11083. * to a desired value once triggered.
  11084. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11085. */
  11086. export class SetValueAction extends Action {
  11087. /**
  11088. * The path of the property to set in the target.
  11089. */
  11090. propertyPath: string;
  11091. /**
  11092. * The value to set in the property
  11093. */
  11094. value: any;
  11095. private _target;
  11096. private _effectiveTarget;
  11097. private _property;
  11098. /**
  11099. * Instantiate the action
  11100. * @param triggerOptions defines the trigger options
  11101. * @param target defines the object containing the property
  11102. * @param propertyPath defines the path of the property to set in the target
  11103. * @param value defines the value to set in the property
  11104. * @param condition defines the trigger related conditions
  11105. */
  11106. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11107. /** @hidden */
  11108. _prepare(): void;
  11109. /**
  11110. * Execute the action and set the targetted property to the desired value.
  11111. */
  11112. execute(): void;
  11113. /**
  11114. * Serializes the actions and its related information.
  11115. * @param parent defines the object to serialize in
  11116. * @returns the serialized object
  11117. */
  11118. serialize(parent: any): any;
  11119. }
  11120. /**
  11121. * This defines an action responsible to increment the target value
  11122. * to a desired value once triggered.
  11123. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11124. */
  11125. export class IncrementValueAction extends Action {
  11126. /**
  11127. * The path of the property to increment in the target.
  11128. */
  11129. propertyPath: string;
  11130. /**
  11131. * The value we should increment the property by.
  11132. */
  11133. value: any;
  11134. private _target;
  11135. private _effectiveTarget;
  11136. private _property;
  11137. /**
  11138. * Instantiate the action
  11139. * @param triggerOptions defines the trigger options
  11140. * @param target defines the object containing the property
  11141. * @param propertyPath defines the path of the property to increment in the target
  11142. * @param value defines the value value we should increment the property by
  11143. * @param condition defines the trigger related conditions
  11144. */
  11145. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11146. /** @hidden */
  11147. _prepare(): void;
  11148. /**
  11149. * Execute the action and increment the target of the value amount.
  11150. */
  11151. execute(): void;
  11152. /**
  11153. * Serializes the actions and its related information.
  11154. * @param parent defines the object to serialize in
  11155. * @returns the serialized object
  11156. */
  11157. serialize(parent: any): any;
  11158. }
  11159. /**
  11160. * This defines an action responsible to start an animation once triggered.
  11161. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11162. */
  11163. export class PlayAnimationAction extends Action {
  11164. /**
  11165. * Where the animation should start (animation frame)
  11166. */
  11167. from: number;
  11168. /**
  11169. * Where the animation should stop (animation frame)
  11170. */
  11171. to: number;
  11172. /**
  11173. * Define if the animation should loop or stop after the first play.
  11174. */
  11175. loop?: boolean;
  11176. private _target;
  11177. /**
  11178. * Instantiate the action
  11179. * @param triggerOptions defines the trigger options
  11180. * @param target defines the target animation or animation name
  11181. * @param from defines from where the animation should start (animation frame)
  11182. * @param end defines where the animation should stop (animation frame)
  11183. * @param loop defines if the animation should loop or stop after the first play
  11184. * @param condition defines the trigger related conditions
  11185. */
  11186. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11187. /** @hidden */
  11188. _prepare(): void;
  11189. /**
  11190. * Execute the action and play the animation.
  11191. */
  11192. execute(): void;
  11193. /**
  11194. * Serializes the actions and its related information.
  11195. * @param parent defines the object to serialize in
  11196. * @returns the serialized object
  11197. */
  11198. serialize(parent: any): any;
  11199. }
  11200. /**
  11201. * This defines an action responsible to stop an animation once triggered.
  11202. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11203. */
  11204. export class StopAnimationAction extends Action {
  11205. private _target;
  11206. /**
  11207. * Instantiate the action
  11208. * @param triggerOptions defines the trigger options
  11209. * @param target defines the target animation or animation name
  11210. * @param condition defines the trigger related conditions
  11211. */
  11212. constructor(triggerOptions: any, target: any, condition?: Condition);
  11213. /** @hidden */
  11214. _prepare(): void;
  11215. /**
  11216. * Execute the action and stop the animation.
  11217. */
  11218. execute(): void;
  11219. /**
  11220. * Serializes the actions and its related information.
  11221. * @param parent defines the object to serialize in
  11222. * @returns the serialized object
  11223. */
  11224. serialize(parent: any): any;
  11225. }
  11226. /**
  11227. * This defines an action responsible that does nothing once triggered.
  11228. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11229. */
  11230. export class DoNothingAction extends Action {
  11231. /**
  11232. * Instantiate the action
  11233. * @param triggerOptions defines the trigger options
  11234. * @param condition defines the trigger related conditions
  11235. */
  11236. constructor(triggerOptions?: any, condition?: Condition);
  11237. /**
  11238. * Execute the action and do nothing.
  11239. */
  11240. execute(): void;
  11241. /**
  11242. * Serializes the actions and its related information.
  11243. * @param parent defines the object to serialize in
  11244. * @returns the serialized object
  11245. */
  11246. serialize(parent: any): any;
  11247. }
  11248. /**
  11249. * This defines an action responsible to trigger several actions once triggered.
  11250. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11251. */
  11252. export class CombineAction extends Action {
  11253. /**
  11254. * The list of aggregated animations to run.
  11255. */
  11256. children: Action[];
  11257. /**
  11258. * Instantiate the action
  11259. * @param triggerOptions defines the trigger options
  11260. * @param children defines the list of aggregated animations to run
  11261. * @param condition defines the trigger related conditions
  11262. */
  11263. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11264. /** @hidden */
  11265. _prepare(): void;
  11266. /**
  11267. * Execute the action and executes all the aggregated actions.
  11268. */
  11269. execute(evt: ActionEvent): void;
  11270. /**
  11271. * Serializes the actions and its related information.
  11272. * @param parent defines the object to serialize in
  11273. * @returns the serialized object
  11274. */
  11275. serialize(parent: any): any;
  11276. }
  11277. /**
  11278. * This defines an action responsible to run code (external event) once triggered.
  11279. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11280. */
  11281. export class ExecuteCodeAction extends Action {
  11282. /**
  11283. * The callback function to run.
  11284. */
  11285. func: (evt: ActionEvent) => void;
  11286. /**
  11287. * Instantiate the action
  11288. * @param triggerOptions defines the trigger options
  11289. * @param func defines the callback function to run
  11290. * @param condition defines the trigger related conditions
  11291. */
  11292. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11293. /**
  11294. * Execute the action and run the attached code.
  11295. */
  11296. execute(evt: ActionEvent): void;
  11297. }
  11298. /**
  11299. * This defines an action responsible to set the parent property of the target once triggered.
  11300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11301. */
  11302. export class SetParentAction extends Action {
  11303. private _parent;
  11304. private _target;
  11305. /**
  11306. * Instantiate the action
  11307. * @param triggerOptions defines the trigger options
  11308. * @param target defines the target containing the parent property
  11309. * @param parent defines from where the animation should start (animation frame)
  11310. * @param condition defines the trigger related conditions
  11311. */
  11312. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11313. /** @hidden */
  11314. _prepare(): void;
  11315. /**
  11316. * Execute the action and set the parent property.
  11317. */
  11318. execute(): void;
  11319. /**
  11320. * Serializes the actions and its related information.
  11321. * @param parent defines the object to serialize in
  11322. * @returns the serialized object
  11323. */
  11324. serialize(parent: any): any;
  11325. }
  11326. }
  11327. declare module "babylonjs/Actions/actionManager" {
  11328. import { Nullable } from "babylonjs/types";
  11329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11330. import { Scene } from "babylonjs/scene";
  11331. import { IAction } from "babylonjs/Actions/action";
  11332. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11333. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11334. /**
  11335. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11336. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11337. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11338. */
  11339. export class ActionManager extends AbstractActionManager {
  11340. /**
  11341. * Nothing
  11342. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11343. */
  11344. static readonly NothingTrigger: number;
  11345. /**
  11346. * On pick
  11347. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11348. */
  11349. static readonly OnPickTrigger: number;
  11350. /**
  11351. * On left pick
  11352. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11353. */
  11354. static readonly OnLeftPickTrigger: number;
  11355. /**
  11356. * On right pick
  11357. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11358. */
  11359. static readonly OnRightPickTrigger: number;
  11360. /**
  11361. * On center pick
  11362. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11363. */
  11364. static readonly OnCenterPickTrigger: number;
  11365. /**
  11366. * On pick down
  11367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11368. */
  11369. static readonly OnPickDownTrigger: number;
  11370. /**
  11371. * On double pick
  11372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11373. */
  11374. static readonly OnDoublePickTrigger: number;
  11375. /**
  11376. * On pick up
  11377. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11378. */
  11379. static readonly OnPickUpTrigger: number;
  11380. /**
  11381. * On pick out.
  11382. * This trigger will only be raised if you also declared a OnPickDown
  11383. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11384. */
  11385. static readonly OnPickOutTrigger: number;
  11386. /**
  11387. * On long press
  11388. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11389. */
  11390. static readonly OnLongPressTrigger: number;
  11391. /**
  11392. * On pointer over
  11393. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11394. */
  11395. static readonly OnPointerOverTrigger: number;
  11396. /**
  11397. * On pointer out
  11398. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11399. */
  11400. static readonly OnPointerOutTrigger: number;
  11401. /**
  11402. * On every frame
  11403. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11404. */
  11405. static readonly OnEveryFrameTrigger: number;
  11406. /**
  11407. * On intersection enter
  11408. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11409. */
  11410. static readonly OnIntersectionEnterTrigger: number;
  11411. /**
  11412. * On intersection exit
  11413. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11414. */
  11415. static readonly OnIntersectionExitTrigger: number;
  11416. /**
  11417. * On key down
  11418. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11419. */
  11420. static readonly OnKeyDownTrigger: number;
  11421. /**
  11422. * On key up
  11423. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11424. */
  11425. static readonly OnKeyUpTrigger: number;
  11426. private _scene;
  11427. /**
  11428. * Creates a new action manager
  11429. * @param scene defines the hosting scene
  11430. */
  11431. constructor(scene: Scene);
  11432. /**
  11433. * Releases all associated resources
  11434. */
  11435. dispose(): void;
  11436. /**
  11437. * Gets hosting scene
  11438. * @returns the hosting scene
  11439. */
  11440. getScene(): Scene;
  11441. /**
  11442. * Does this action manager handles actions of any of the given triggers
  11443. * @param triggers defines the triggers to be tested
  11444. * @return a boolean indicating whether one (or more) of the triggers is handled
  11445. */
  11446. hasSpecificTriggers(triggers: number[]): boolean;
  11447. /**
  11448. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11449. * speed.
  11450. * @param triggerA defines the trigger to be tested
  11451. * @param triggerB defines the trigger to be tested
  11452. * @return a boolean indicating whether one (or more) of the triggers is handled
  11453. */
  11454. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11455. /**
  11456. * Does this action manager handles actions of a given trigger
  11457. * @param trigger defines the trigger to be tested
  11458. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11459. * @return whether the trigger is handled
  11460. */
  11461. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11462. /**
  11463. * Does this action manager has pointer triggers
  11464. */
  11465. readonly hasPointerTriggers: boolean;
  11466. /**
  11467. * Does this action manager has pick triggers
  11468. */
  11469. readonly hasPickTriggers: boolean;
  11470. /**
  11471. * Registers an action to this action manager
  11472. * @param action defines the action to be registered
  11473. * @return the action amended (prepared) after registration
  11474. */
  11475. registerAction(action: IAction): Nullable<IAction>;
  11476. /**
  11477. * Unregisters an action to this action manager
  11478. * @param action defines the action to be unregistered
  11479. * @return a boolean indicating whether the action has been unregistered
  11480. */
  11481. unregisterAction(action: IAction): Boolean;
  11482. /**
  11483. * Process a specific trigger
  11484. * @param trigger defines the trigger to process
  11485. * @param evt defines the event details to be processed
  11486. */
  11487. processTrigger(trigger: number, evt?: IActionEvent): void;
  11488. /** @hidden */
  11489. _getEffectiveTarget(target: any, propertyPath: string): any;
  11490. /** @hidden */
  11491. _getProperty(propertyPath: string): string;
  11492. /**
  11493. * Serialize this manager to a JSON object
  11494. * @param name defines the property name to store this manager
  11495. * @returns a JSON representation of this manager
  11496. */
  11497. serialize(name: string): any;
  11498. /**
  11499. * Creates a new ActionManager from a JSON data
  11500. * @param parsedActions defines the JSON data to read from
  11501. * @param object defines the hosting mesh
  11502. * @param scene defines the hosting scene
  11503. */
  11504. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11505. /**
  11506. * Get a trigger name by index
  11507. * @param trigger defines the trigger index
  11508. * @returns a trigger name
  11509. */
  11510. static GetTriggerName(trigger: number): string;
  11511. }
  11512. }
  11513. declare module "babylonjs/Culling/ray" {
  11514. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11515. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11517. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11518. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11519. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11520. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11521. /**
  11522. * Class representing a ray with position and direction
  11523. */
  11524. export class Ray {
  11525. /** origin point */
  11526. origin: Vector3;
  11527. /** direction */
  11528. direction: Vector3;
  11529. /** length of the ray */
  11530. length: number;
  11531. private static readonly TmpVector3;
  11532. private _tmpRay;
  11533. /**
  11534. * Creates a new ray
  11535. * @param origin origin point
  11536. * @param direction direction
  11537. * @param length length of the ray
  11538. */
  11539. constructor(
  11540. /** origin point */
  11541. origin: Vector3,
  11542. /** direction */
  11543. direction: Vector3,
  11544. /** length of the ray */
  11545. length?: number);
  11546. /**
  11547. * Checks if the ray intersects a box
  11548. * @param minimum bound of the box
  11549. * @param maximum bound of the box
  11550. * @param intersectionTreshold extra extend to be added to the box in all direction
  11551. * @returns if the box was hit
  11552. */
  11553. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11554. /**
  11555. * Checks if the ray intersects a box
  11556. * @param box the bounding box to check
  11557. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11558. * @returns if the box was hit
  11559. */
  11560. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11561. /**
  11562. * If the ray hits a sphere
  11563. * @param sphere the bounding sphere to check
  11564. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11565. * @returns true if it hits the sphere
  11566. */
  11567. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11568. /**
  11569. * If the ray hits a triange
  11570. * @param vertex0 triangle vertex
  11571. * @param vertex1 triangle vertex
  11572. * @param vertex2 triangle vertex
  11573. * @returns intersection information if hit
  11574. */
  11575. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11576. /**
  11577. * Checks if ray intersects a plane
  11578. * @param plane the plane to check
  11579. * @returns the distance away it was hit
  11580. */
  11581. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11582. /**
  11583. * Checks if ray intersects a mesh
  11584. * @param mesh the mesh to check
  11585. * @param fastCheck if only the bounding box should checked
  11586. * @returns picking info of the intersecton
  11587. */
  11588. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11589. /**
  11590. * Checks if ray intersects a mesh
  11591. * @param meshes the meshes to check
  11592. * @param fastCheck if only the bounding box should checked
  11593. * @param results array to store result in
  11594. * @returns Array of picking infos
  11595. */
  11596. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11597. private _comparePickingInfo;
  11598. private static smallnum;
  11599. private static rayl;
  11600. /**
  11601. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11602. * @param sega the first point of the segment to test the intersection against
  11603. * @param segb the second point of the segment to test the intersection against
  11604. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11605. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11606. */
  11607. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11608. /**
  11609. * Update the ray from viewport position
  11610. * @param x position
  11611. * @param y y position
  11612. * @param viewportWidth viewport width
  11613. * @param viewportHeight viewport height
  11614. * @param world world matrix
  11615. * @param view view matrix
  11616. * @param projection projection matrix
  11617. * @returns this ray updated
  11618. */
  11619. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11620. /**
  11621. * Creates a ray with origin and direction of 0,0,0
  11622. * @returns the new ray
  11623. */
  11624. static Zero(): Ray;
  11625. /**
  11626. * Creates a new ray from screen space and viewport
  11627. * @param x position
  11628. * @param y y position
  11629. * @param viewportWidth viewport width
  11630. * @param viewportHeight viewport height
  11631. * @param world world matrix
  11632. * @param view view matrix
  11633. * @param projection projection matrix
  11634. * @returns new ray
  11635. */
  11636. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11637. /**
  11638. * 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
  11639. * transformed to the given world matrix.
  11640. * @param origin The origin point
  11641. * @param end The end point
  11642. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11643. * @returns the new ray
  11644. */
  11645. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11646. /**
  11647. * Transforms a ray by a matrix
  11648. * @param ray ray to transform
  11649. * @param matrix matrix to apply
  11650. * @returns the resulting new ray
  11651. */
  11652. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11653. /**
  11654. * Transforms a ray by a matrix
  11655. * @param ray ray to transform
  11656. * @param matrix matrix to apply
  11657. * @param result ray to store result in
  11658. */
  11659. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11660. /**
  11661. * Unproject a ray from screen space to object space
  11662. * @param sourceX defines the screen space x coordinate to use
  11663. * @param sourceY defines the screen space y coordinate to use
  11664. * @param viewportWidth defines the current width of the viewport
  11665. * @param viewportHeight defines the current height of the viewport
  11666. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11667. * @param view defines the view matrix to use
  11668. * @param projection defines the projection matrix to use
  11669. */
  11670. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11671. }
  11672. /**
  11673. * Type used to define predicate used to select faces when a mesh intersection is detected
  11674. */
  11675. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11676. module "babylonjs/scene" {
  11677. interface Scene {
  11678. /** @hidden */
  11679. _tempPickingRay: Nullable<Ray>;
  11680. /** @hidden */
  11681. _cachedRayForTransform: Ray;
  11682. /** @hidden */
  11683. _pickWithRayInverseMatrix: Matrix;
  11684. /** @hidden */
  11685. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11686. /** @hidden */
  11687. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11688. }
  11689. }
  11690. }
  11691. declare module "babylonjs/sceneComponent" {
  11692. import { Scene } from "babylonjs/scene";
  11693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11694. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11695. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11696. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11697. import { Nullable } from "babylonjs/types";
  11698. import { Camera } from "babylonjs/Cameras/camera";
  11699. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11700. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11701. import { AbstractScene } from "babylonjs/abstractScene";
  11702. /**
  11703. * Groups all the scene component constants in one place to ease maintenance.
  11704. * @hidden
  11705. */
  11706. export class SceneComponentConstants {
  11707. static readonly NAME_EFFECTLAYER: string;
  11708. static readonly NAME_LAYER: string;
  11709. static readonly NAME_LENSFLARESYSTEM: string;
  11710. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11711. static readonly NAME_PARTICLESYSTEM: string;
  11712. static readonly NAME_GAMEPAD: string;
  11713. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11714. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11715. static readonly NAME_DEPTHRENDERER: string;
  11716. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11717. static readonly NAME_SPRITE: string;
  11718. static readonly NAME_OUTLINERENDERER: string;
  11719. static readonly NAME_PROCEDURALTEXTURE: string;
  11720. static readonly NAME_SHADOWGENERATOR: string;
  11721. static readonly NAME_OCTREE: string;
  11722. static readonly NAME_PHYSICSENGINE: string;
  11723. static readonly NAME_AUDIO: string;
  11724. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11725. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11726. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11727. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11728. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11729. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11730. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11731. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11732. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11733. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11734. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11735. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11736. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11737. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11738. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11739. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11740. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11741. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11742. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11743. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11744. static readonly STEP_AFTERRENDER_AUDIO: number;
  11745. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11746. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11747. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11748. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11749. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11750. static readonly STEP_POINTERMOVE_SPRITE: number;
  11751. static readonly STEP_POINTERDOWN_SPRITE: number;
  11752. static readonly STEP_POINTERUP_SPRITE: number;
  11753. }
  11754. /**
  11755. * This represents a scene component.
  11756. *
  11757. * This is used to decouple the dependency the scene is having on the different workloads like
  11758. * layers, post processes...
  11759. */
  11760. export interface ISceneComponent {
  11761. /**
  11762. * The name of the component. Each component must have a unique name.
  11763. */
  11764. name: string;
  11765. /**
  11766. * The scene the component belongs to.
  11767. */
  11768. scene: Scene;
  11769. /**
  11770. * Register the component to one instance of a scene.
  11771. */
  11772. register(): void;
  11773. /**
  11774. * Rebuilds the elements related to this component in case of
  11775. * context lost for instance.
  11776. */
  11777. rebuild(): void;
  11778. /**
  11779. * Disposes the component and the associated ressources.
  11780. */
  11781. dispose(): void;
  11782. }
  11783. /**
  11784. * This represents a SERIALIZABLE scene component.
  11785. *
  11786. * This extends Scene Component to add Serialization methods on top.
  11787. */
  11788. export interface ISceneSerializableComponent extends ISceneComponent {
  11789. /**
  11790. * Adds all the element from the container to the scene
  11791. * @param container the container holding the elements
  11792. */
  11793. addFromContainer(container: AbstractScene): void;
  11794. /**
  11795. * Removes all the elements in the container from the scene
  11796. * @param container contains the elements to remove
  11797. * @param dispose if the removed element should be disposed (default: false)
  11798. */
  11799. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11800. /**
  11801. * Serializes the component data to the specified json object
  11802. * @param serializationObject The object to serialize to
  11803. */
  11804. serialize(serializationObject: any): void;
  11805. }
  11806. /**
  11807. * Strong typing of a Mesh related stage step action
  11808. */
  11809. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11810. /**
  11811. * Strong typing of a Evaluate Sub Mesh related stage step action
  11812. */
  11813. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11814. /**
  11815. * Strong typing of a Active Mesh related stage step action
  11816. */
  11817. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11818. /**
  11819. * Strong typing of a Camera related stage step action
  11820. */
  11821. export type CameraStageAction = (camera: Camera) => void;
  11822. /**
  11823. * Strong typing of a Camera Frame buffer related stage step action
  11824. */
  11825. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11826. /**
  11827. * Strong typing of a Render Target related stage step action
  11828. */
  11829. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11830. /**
  11831. * Strong typing of a RenderingGroup related stage step action
  11832. */
  11833. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11834. /**
  11835. * Strong typing of a Mesh Render related stage step action
  11836. */
  11837. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11838. /**
  11839. * Strong typing of a simple stage step action
  11840. */
  11841. export type SimpleStageAction = () => void;
  11842. /**
  11843. * Strong typing of a render target action.
  11844. */
  11845. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11846. /**
  11847. * Strong typing of a pointer move action.
  11848. */
  11849. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11850. /**
  11851. * Strong typing of a pointer up/down action.
  11852. */
  11853. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11854. /**
  11855. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11856. * @hidden
  11857. */
  11858. export class Stage<T extends Function> extends Array<{
  11859. index: number;
  11860. component: ISceneComponent;
  11861. action: T;
  11862. }> {
  11863. /**
  11864. * Hide ctor from the rest of the world.
  11865. * @param items The items to add.
  11866. */
  11867. private constructor();
  11868. /**
  11869. * Creates a new Stage.
  11870. * @returns A new instance of a Stage
  11871. */
  11872. static Create<T extends Function>(): Stage<T>;
  11873. /**
  11874. * Registers a step in an ordered way in the targeted stage.
  11875. * @param index Defines the position to register the step in
  11876. * @param component Defines the component attached to the step
  11877. * @param action Defines the action to launch during the step
  11878. */
  11879. registerStep(index: number, component: ISceneComponent, action: T): void;
  11880. /**
  11881. * Clears all the steps from the stage.
  11882. */
  11883. clear(): void;
  11884. }
  11885. }
  11886. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11887. import { Nullable } from "babylonjs/types";
  11888. import { Observable } from "babylonjs/Misc/observable";
  11889. import { Scene } from "babylonjs/scene";
  11890. import { Sprite } from "babylonjs/Sprites/sprite";
  11891. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11892. import { Ray } from "babylonjs/Culling/ray";
  11893. import { Camera } from "babylonjs/Cameras/camera";
  11894. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11895. import { ISceneComponent } from "babylonjs/sceneComponent";
  11896. module "babylonjs/scene" {
  11897. interface Scene {
  11898. /** @hidden */
  11899. _pointerOverSprite: Nullable<Sprite>;
  11900. /** @hidden */
  11901. _pickedDownSprite: Nullable<Sprite>;
  11902. /** @hidden */
  11903. _tempSpritePickingRay: Nullable<Ray>;
  11904. /**
  11905. * All of the sprite managers added to this scene
  11906. * @see http://doc.babylonjs.com/babylon101/sprites
  11907. */
  11908. spriteManagers: Array<ISpriteManager>;
  11909. /**
  11910. * An event triggered when sprites rendering is about to start
  11911. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11912. */
  11913. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11914. /**
  11915. * An event triggered when sprites rendering is done
  11916. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11917. */
  11918. onAfterSpritesRenderingObservable: Observable<Scene>;
  11919. /** @hidden */
  11920. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11921. /** Launch a ray to try to pick a sprite in the scene
  11922. * @param x position on screen
  11923. * @param y position on screen
  11924. * @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
  11925. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11926. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11927. * @returns a PickingInfo
  11928. */
  11929. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11930. /** Use the given ray to pick a sprite in the scene
  11931. * @param ray The ray (in world space) to use to pick meshes
  11932. * @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
  11933. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11934. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11935. * @returns a PickingInfo
  11936. */
  11937. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11938. /**
  11939. * Force the sprite under the pointer
  11940. * @param sprite defines the sprite to use
  11941. */
  11942. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11943. /**
  11944. * Gets the sprite under the pointer
  11945. * @returns a Sprite or null if no sprite is under the pointer
  11946. */
  11947. getPointerOverSprite(): Nullable<Sprite>;
  11948. }
  11949. }
  11950. /**
  11951. * Defines the sprite scene component responsible to manage sprites
  11952. * in a given scene.
  11953. */
  11954. export class SpriteSceneComponent implements ISceneComponent {
  11955. /**
  11956. * The component name helpfull to identify the component in the list of scene components.
  11957. */
  11958. readonly name: string;
  11959. /**
  11960. * The scene the component belongs to.
  11961. */
  11962. scene: Scene;
  11963. /** @hidden */
  11964. private _spritePredicate;
  11965. /**
  11966. * Creates a new instance of the component for the given scene
  11967. * @param scene Defines the scene to register the component in
  11968. */
  11969. constructor(scene: Scene);
  11970. /**
  11971. * Registers the component in a given scene
  11972. */
  11973. register(): void;
  11974. /**
  11975. * Rebuilds the elements related to this component in case of
  11976. * context lost for instance.
  11977. */
  11978. rebuild(): void;
  11979. /**
  11980. * Disposes the component and the associated ressources.
  11981. */
  11982. dispose(): void;
  11983. private _pickSpriteButKeepRay;
  11984. private _pointerMove;
  11985. private _pointerDown;
  11986. private _pointerUp;
  11987. }
  11988. }
  11989. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11990. /** @hidden */
  11991. export var fogFragmentDeclaration: {
  11992. name: string;
  11993. shader: string;
  11994. };
  11995. }
  11996. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11997. /** @hidden */
  11998. export var fogFragment: {
  11999. name: string;
  12000. shader: string;
  12001. };
  12002. }
  12003. declare module "babylonjs/Shaders/sprites.fragment" {
  12004. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  12005. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  12006. /** @hidden */
  12007. export var spritesPixelShader: {
  12008. name: string;
  12009. shader: string;
  12010. };
  12011. }
  12012. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  12013. /** @hidden */
  12014. export var fogVertexDeclaration: {
  12015. name: string;
  12016. shader: string;
  12017. };
  12018. }
  12019. declare module "babylonjs/Shaders/sprites.vertex" {
  12020. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  12021. /** @hidden */
  12022. export var spritesVertexShader: {
  12023. name: string;
  12024. shader: string;
  12025. };
  12026. }
  12027. declare module "babylonjs/Sprites/spriteManager" {
  12028. import { IDisposable, Scene } from "babylonjs/scene";
  12029. import { Nullable } from "babylonjs/types";
  12030. import { Observable } from "babylonjs/Misc/observable";
  12031. import { Sprite } from "babylonjs/Sprites/sprite";
  12032. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12033. import { Camera } from "babylonjs/Cameras/camera";
  12034. import { Texture } from "babylonjs/Materials/Textures/texture";
  12035. import "babylonjs/Shaders/sprites.fragment";
  12036. import "babylonjs/Shaders/sprites.vertex";
  12037. import { Ray } from "babylonjs/Culling/ray";
  12038. /**
  12039. * Defines the minimum interface to fullfil in order to be a sprite manager.
  12040. */
  12041. export interface ISpriteManager extends IDisposable {
  12042. /**
  12043. * Restricts the camera to viewing objects with the same layerMask.
  12044. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  12045. */
  12046. layerMask: number;
  12047. /**
  12048. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  12049. */
  12050. isPickable: boolean;
  12051. /**
  12052. * Specifies the rendering group id for this mesh (0 by default)
  12053. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  12054. */
  12055. renderingGroupId: number;
  12056. /**
  12057. * Defines the list of sprites managed by the manager.
  12058. */
  12059. sprites: Array<Sprite>;
  12060. /**
  12061. * Tests the intersection of a sprite with a specific ray.
  12062. * @param ray The ray we are sending to test the collision
  12063. * @param camera The camera space we are sending rays in
  12064. * @param predicate A predicate allowing excluding sprites from the list of object to test
  12065. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  12066. * @returns picking info or null.
  12067. */
  12068. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12069. /**
  12070. * Renders the list of sprites on screen.
  12071. */
  12072. render(): void;
  12073. }
  12074. /**
  12075. * Class used to manage multiple sprites on the same spritesheet
  12076. * @see http://doc.babylonjs.com/babylon101/sprites
  12077. */
  12078. export class SpriteManager implements ISpriteManager {
  12079. /** defines the manager's name */
  12080. name: string;
  12081. /** Gets the list of sprites */
  12082. sprites: Sprite[];
  12083. /** Gets or sets the rendering group id (0 by default) */
  12084. renderingGroupId: number;
  12085. /** Gets or sets camera layer mask */
  12086. layerMask: number;
  12087. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  12088. fogEnabled: boolean;
  12089. /** Gets or sets a boolean indicating if the sprites are pickable */
  12090. isPickable: boolean;
  12091. /** Defines the default width of a cell in the spritesheet */
  12092. cellWidth: number;
  12093. /** Defines the default height of a cell in the spritesheet */
  12094. cellHeight: number;
  12095. /**
  12096. * An event triggered when the manager is disposed.
  12097. */
  12098. onDisposeObservable: Observable<SpriteManager>;
  12099. private _onDisposeObserver;
  12100. /**
  12101. * Callback called when the manager is disposed
  12102. */
  12103. onDispose: () => void;
  12104. private _capacity;
  12105. private _spriteTexture;
  12106. private _epsilon;
  12107. private _scene;
  12108. private _vertexData;
  12109. private _buffer;
  12110. private _vertexBuffers;
  12111. private _indexBuffer;
  12112. private _effectBase;
  12113. private _effectFog;
  12114. /**
  12115. * Gets or sets the spritesheet texture
  12116. */
  12117. texture: Texture;
  12118. /**
  12119. * Creates a new sprite manager
  12120. * @param name defines the manager's name
  12121. * @param imgUrl defines the sprite sheet url
  12122. * @param capacity defines the maximum allowed number of sprites
  12123. * @param cellSize defines the size of a sprite cell
  12124. * @param scene defines the hosting scene
  12125. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  12126. * @param samplingMode defines the smapling mode to use with spritesheet
  12127. */
  12128. constructor(
  12129. /** defines the manager's name */
  12130. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  12131. private _appendSpriteVertex;
  12132. /**
  12133. * Intersects the sprites with a ray
  12134. * @param ray defines the ray to intersect with
  12135. * @param camera defines the current active camera
  12136. * @param predicate defines a predicate used to select candidate sprites
  12137. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12138. * @returns null if no hit or a PickingInfo
  12139. */
  12140. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12141. /**
  12142. * Render all child sprites
  12143. */
  12144. render(): void;
  12145. /**
  12146. * Release associated resources
  12147. */
  12148. dispose(): void;
  12149. }
  12150. }
  12151. declare module "babylonjs/Sprites/sprite" {
  12152. import { Vector3, Color4 } from "babylonjs/Maths/math";
  12153. import { Nullable } from "babylonjs/types";
  12154. import { ActionManager } from "babylonjs/Actions/actionManager";
  12155. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12156. /**
  12157. * Class used to represent a sprite
  12158. * @see http://doc.babylonjs.com/babylon101/sprites
  12159. */
  12160. export class Sprite {
  12161. /** defines the name */
  12162. name: string;
  12163. /** Gets or sets the current world position */
  12164. position: Vector3;
  12165. /** Gets or sets the main color */
  12166. color: Color4;
  12167. /** Gets or sets the width */
  12168. width: number;
  12169. /** Gets or sets the height */
  12170. height: number;
  12171. /** Gets or sets rotation angle */
  12172. angle: number;
  12173. /** Gets or sets the cell index in the sprite sheet */
  12174. cellIndex: number;
  12175. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12176. invertU: number;
  12177. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12178. invertV: number;
  12179. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12180. disposeWhenFinishedAnimating: boolean;
  12181. /** Gets the list of attached animations */
  12182. animations: Animation[];
  12183. /** Gets or sets a boolean indicating if the sprite can be picked */
  12184. isPickable: boolean;
  12185. /**
  12186. * Gets or sets the associated action manager
  12187. */
  12188. actionManager: Nullable<ActionManager>;
  12189. private _animationStarted;
  12190. private _loopAnimation;
  12191. private _fromIndex;
  12192. private _toIndex;
  12193. private _delay;
  12194. private _direction;
  12195. private _manager;
  12196. private _time;
  12197. private _onAnimationEnd;
  12198. /**
  12199. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12200. */
  12201. isVisible: boolean;
  12202. /**
  12203. * Gets or sets the sprite size
  12204. */
  12205. size: number;
  12206. /**
  12207. * Creates a new Sprite
  12208. * @param name defines the name
  12209. * @param manager defines the manager
  12210. */
  12211. constructor(
  12212. /** defines the name */
  12213. name: string, manager: ISpriteManager);
  12214. /**
  12215. * Starts an animation
  12216. * @param from defines the initial key
  12217. * @param to defines the end key
  12218. * @param loop defines if the animation must loop
  12219. * @param delay defines the start delay (in ms)
  12220. * @param onAnimationEnd defines a callback to call when animation ends
  12221. */
  12222. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12223. /** Stops current animation (if any) */
  12224. stopAnimation(): void;
  12225. /** @hidden */
  12226. _animate(deltaTime: number): void;
  12227. /** Release associated resources */
  12228. dispose(): void;
  12229. }
  12230. }
  12231. declare module "babylonjs/Collisions/pickingInfo" {
  12232. import { Nullable } from "babylonjs/types";
  12233. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12235. import { Sprite } from "babylonjs/Sprites/sprite";
  12236. import { Ray } from "babylonjs/Culling/ray";
  12237. /**
  12238. * Information about the result of picking within a scene
  12239. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12240. */
  12241. export class PickingInfo {
  12242. /** @hidden */
  12243. _pickingUnavailable: boolean;
  12244. /**
  12245. * If the pick collided with an object
  12246. */
  12247. hit: boolean;
  12248. /**
  12249. * Distance away where the pick collided
  12250. */
  12251. distance: number;
  12252. /**
  12253. * The location of pick collision
  12254. */
  12255. pickedPoint: Nullable<Vector3>;
  12256. /**
  12257. * The mesh corresponding the the pick collision
  12258. */
  12259. pickedMesh: Nullable<AbstractMesh>;
  12260. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12261. bu: number;
  12262. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12263. bv: number;
  12264. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12265. faceId: number;
  12266. /** Id of the the submesh that was picked */
  12267. subMeshId: number;
  12268. /** If a sprite was picked, this will be the sprite the pick collided with */
  12269. pickedSprite: Nullable<Sprite>;
  12270. /**
  12271. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12272. */
  12273. originMesh: Nullable<AbstractMesh>;
  12274. /**
  12275. * The ray that was used to perform the picking.
  12276. */
  12277. ray: Nullable<Ray>;
  12278. /**
  12279. * Gets the normal correspodning to the face the pick collided with
  12280. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12281. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12282. * @returns The normal correspodning to the face the pick collided with
  12283. */
  12284. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12285. /**
  12286. * Gets the texture coordinates of where the pick occured
  12287. * @returns the vector containing the coordnates of the texture
  12288. */
  12289. getTextureCoordinates(): Nullable<Vector2>;
  12290. }
  12291. }
  12292. declare module "babylonjs/Events/pointerEvents" {
  12293. import { Nullable } from "babylonjs/types";
  12294. import { Vector2 } from "babylonjs/Maths/math";
  12295. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12296. import { Ray } from "babylonjs/Culling/ray";
  12297. /**
  12298. * Gather the list of pointer event types as constants.
  12299. */
  12300. export class PointerEventTypes {
  12301. /**
  12302. * 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.
  12303. */
  12304. static readonly POINTERDOWN: number;
  12305. /**
  12306. * The pointerup event is fired when a pointer is no longer active.
  12307. */
  12308. static readonly POINTERUP: number;
  12309. /**
  12310. * The pointermove event is fired when a pointer changes coordinates.
  12311. */
  12312. static readonly POINTERMOVE: number;
  12313. /**
  12314. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12315. */
  12316. static readonly POINTERWHEEL: number;
  12317. /**
  12318. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12319. */
  12320. static readonly POINTERPICK: number;
  12321. /**
  12322. * The pointertap event is fired when a the object has been touched and released without drag.
  12323. */
  12324. static readonly POINTERTAP: number;
  12325. /**
  12326. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12327. */
  12328. static readonly POINTERDOUBLETAP: number;
  12329. }
  12330. /**
  12331. * Base class of pointer info types.
  12332. */
  12333. export class PointerInfoBase {
  12334. /**
  12335. * Defines the type of event (PointerEventTypes)
  12336. */
  12337. type: number;
  12338. /**
  12339. * Defines the related dom event
  12340. */
  12341. event: PointerEvent | MouseWheelEvent;
  12342. /**
  12343. * Instantiates the base class of pointers info.
  12344. * @param type Defines the type of event (PointerEventTypes)
  12345. * @param event Defines the related dom event
  12346. */
  12347. constructor(
  12348. /**
  12349. * Defines the type of event (PointerEventTypes)
  12350. */
  12351. type: number,
  12352. /**
  12353. * Defines the related dom event
  12354. */
  12355. event: PointerEvent | MouseWheelEvent);
  12356. }
  12357. /**
  12358. * This class is used to store pointer related info for the onPrePointerObservable event.
  12359. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12360. */
  12361. export class PointerInfoPre extends PointerInfoBase {
  12362. /**
  12363. * Ray from a pointer if availible (eg. 6dof controller)
  12364. */
  12365. ray: Nullable<Ray>;
  12366. /**
  12367. * Defines the local position of the pointer on the canvas.
  12368. */
  12369. localPosition: Vector2;
  12370. /**
  12371. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12372. */
  12373. skipOnPointerObservable: boolean;
  12374. /**
  12375. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12376. * @param type Defines the type of event (PointerEventTypes)
  12377. * @param event Defines the related dom event
  12378. * @param localX Defines the local x coordinates of the pointer when the event occured
  12379. * @param localY Defines the local y coordinates of the pointer when the event occured
  12380. */
  12381. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12382. }
  12383. /**
  12384. * This type contains all the data related to a pointer event in Babylon.js.
  12385. * 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.
  12386. */
  12387. export class PointerInfo extends PointerInfoBase {
  12388. /**
  12389. * Defines the picking info associated to the info (if any)\
  12390. */
  12391. pickInfo: Nullable<PickingInfo>;
  12392. /**
  12393. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12394. * @param type Defines the type of event (PointerEventTypes)
  12395. * @param event Defines the related dom event
  12396. * @param pickInfo Defines the picking info associated to the info (if any)\
  12397. */
  12398. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12399. /**
  12400. * Defines the picking info associated to the info (if any)\
  12401. */
  12402. pickInfo: Nullable<PickingInfo>);
  12403. }
  12404. /**
  12405. * Data relating to a touch event on the screen.
  12406. */
  12407. export interface PointerTouch {
  12408. /**
  12409. * X coordinate of touch.
  12410. */
  12411. x: number;
  12412. /**
  12413. * Y coordinate of touch.
  12414. */
  12415. y: number;
  12416. /**
  12417. * Id of touch. Unique for each finger.
  12418. */
  12419. pointerId: number;
  12420. /**
  12421. * Event type passed from DOM.
  12422. */
  12423. type: any;
  12424. }
  12425. }
  12426. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12427. import { Observable } from "babylonjs/Misc/observable";
  12428. import { Nullable } from "babylonjs/types";
  12429. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12430. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12431. /**
  12432. * Manage the mouse inputs to control the movement of a free camera.
  12433. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12434. */
  12435. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12436. /**
  12437. * Define if touch is enabled in the mouse input
  12438. */
  12439. touchEnabled: boolean;
  12440. /**
  12441. * Defines the camera the input is attached to.
  12442. */
  12443. camera: FreeCamera;
  12444. /**
  12445. * Defines the buttons associated with the input to handle camera move.
  12446. */
  12447. buttons: number[];
  12448. /**
  12449. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12450. */
  12451. angularSensibility: number;
  12452. private _pointerInput;
  12453. private _onMouseMove;
  12454. private _observer;
  12455. private previousPosition;
  12456. /**
  12457. * Observable for when a pointer move event occurs containing the move offset
  12458. */
  12459. onPointerMovedObservable: Observable<{
  12460. offsetX: number;
  12461. offsetY: number;
  12462. }>;
  12463. /**
  12464. * @hidden
  12465. * If the camera should be rotated automatically based on pointer movement
  12466. */
  12467. _allowCameraRotation: boolean;
  12468. /**
  12469. * Manage the mouse inputs to control the movement of a free camera.
  12470. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12471. * @param touchEnabled Defines if touch is enabled or not
  12472. */
  12473. constructor(
  12474. /**
  12475. * Define if touch is enabled in the mouse input
  12476. */
  12477. touchEnabled?: boolean);
  12478. /**
  12479. * Attach the input controls to a specific dom element to get the input from.
  12480. * @param element Defines the element the controls should be listened from
  12481. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12482. */
  12483. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12484. /**
  12485. * Called on JS contextmenu event.
  12486. * Override this method to provide functionality.
  12487. */
  12488. protected onContextMenu(evt: PointerEvent): void;
  12489. /**
  12490. * Detach the current controls from the specified dom element.
  12491. * @param element Defines the element to stop listening the inputs from
  12492. */
  12493. detachControl(element: Nullable<HTMLElement>): void;
  12494. /**
  12495. * Gets the class name of the current intput.
  12496. * @returns the class name
  12497. */
  12498. getClassName(): string;
  12499. /**
  12500. * Get the friendly name associated with the input class.
  12501. * @returns the input friendly name
  12502. */
  12503. getSimpleName(): string;
  12504. }
  12505. }
  12506. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12507. import { Nullable } from "babylonjs/types";
  12508. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12509. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12510. /**
  12511. * Manage the touch inputs to control the movement of a free camera.
  12512. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12513. */
  12514. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12515. /**
  12516. * Defines the camera the input is attached to.
  12517. */
  12518. camera: FreeCamera;
  12519. /**
  12520. * Defines the touch sensibility for rotation.
  12521. * The higher the faster.
  12522. */
  12523. touchAngularSensibility: number;
  12524. /**
  12525. * Defines the touch sensibility for move.
  12526. * The higher the faster.
  12527. */
  12528. touchMoveSensibility: number;
  12529. private _offsetX;
  12530. private _offsetY;
  12531. private _pointerPressed;
  12532. private _pointerInput;
  12533. private _observer;
  12534. private _onLostFocus;
  12535. /**
  12536. * Attach the input controls to a specific dom element to get the input from.
  12537. * @param element Defines the element the controls should be listened from
  12538. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12539. */
  12540. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12541. /**
  12542. * Detach the current controls from the specified dom element.
  12543. * @param element Defines the element to stop listening the inputs from
  12544. */
  12545. detachControl(element: Nullable<HTMLElement>): void;
  12546. /**
  12547. * Update the current camera state depending on the inputs that have been used this frame.
  12548. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12549. */
  12550. checkInputs(): void;
  12551. /**
  12552. * Gets the class name of the current intput.
  12553. * @returns the class name
  12554. */
  12555. getClassName(): string;
  12556. /**
  12557. * Get the friendly name associated with the input class.
  12558. * @returns the input friendly name
  12559. */
  12560. getSimpleName(): string;
  12561. }
  12562. }
  12563. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12564. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12565. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12566. import { FreeCameraKeyboardMoveInput } from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  12567. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12568. import { Nullable } from "babylonjs/types";
  12569. /**
  12570. * Default Inputs manager for the FreeCamera.
  12571. * It groups all the default supported inputs for ease of use.
  12572. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12573. */
  12574. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12575. /**
  12576. * @hidden
  12577. */
  12578. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12579. /**
  12580. * @hidden
  12581. */
  12582. _mouseInput: Nullable<FreeCameraMouseInput>;
  12583. /**
  12584. * Instantiates a new FreeCameraInputsManager.
  12585. * @param camera Defines the camera the inputs belong to
  12586. */
  12587. constructor(camera: FreeCamera);
  12588. /**
  12589. * Add keyboard input support to the input manager.
  12590. * @returns the current input manager
  12591. */
  12592. addKeyboard(): FreeCameraInputsManager;
  12593. /**
  12594. * Add mouse input support to the input manager.
  12595. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12596. * @returns the current input manager
  12597. */
  12598. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12599. /**
  12600. * Removes the mouse input support from the manager
  12601. * @returns the current input manager
  12602. */
  12603. removeMouse(): FreeCameraInputsManager;
  12604. /**
  12605. * Add touch input support to the input manager.
  12606. * @returns the current input manager
  12607. */
  12608. addTouch(): FreeCameraInputsManager;
  12609. }
  12610. }
  12611. declare module "babylonjs/Cameras/freeCamera" {
  12612. import { Vector3 } from "babylonjs/Maths/math";
  12613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12614. import { Scene } from "babylonjs/scene";
  12615. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12616. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12617. /**
  12618. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12619. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12620. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12621. */
  12622. export class FreeCamera extends TargetCamera {
  12623. /**
  12624. * Define the collision ellipsoid of the camera.
  12625. * This is helpful to simulate a camera body like the player body around the camera
  12626. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12627. */
  12628. ellipsoid: Vector3;
  12629. /**
  12630. * Define an offset for the position of the ellipsoid around the camera.
  12631. * This can be helpful to determine the center of the body near the gravity center of the body
  12632. * instead of its head.
  12633. */
  12634. ellipsoidOffset: Vector3;
  12635. /**
  12636. * Enable or disable collisions of the camera with the rest of the scene objects.
  12637. */
  12638. checkCollisions: boolean;
  12639. /**
  12640. * Enable or disable gravity on the camera.
  12641. */
  12642. applyGravity: boolean;
  12643. /**
  12644. * Define the input manager associated to the camera.
  12645. */
  12646. inputs: FreeCameraInputsManager;
  12647. /**
  12648. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12649. * Higher values reduce sensitivity.
  12650. */
  12651. /**
  12652. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12653. * Higher values reduce sensitivity.
  12654. */
  12655. angularSensibility: number;
  12656. /**
  12657. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12658. */
  12659. keysUp: number[];
  12660. /**
  12661. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12662. */
  12663. keysDown: number[];
  12664. /**
  12665. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12666. */
  12667. keysLeft: number[];
  12668. /**
  12669. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12670. */
  12671. keysRight: number[];
  12672. /**
  12673. * Event raised when the camera collide with a mesh in the scene.
  12674. */
  12675. onCollide: (collidedMesh: AbstractMesh) => void;
  12676. private _collider;
  12677. private _needMoveForGravity;
  12678. private _oldPosition;
  12679. private _diffPosition;
  12680. private _newPosition;
  12681. /** @hidden */
  12682. _localDirection: Vector3;
  12683. /** @hidden */
  12684. _transformedDirection: Vector3;
  12685. /**
  12686. * Instantiates a Free Camera.
  12687. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12688. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12689. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12690. * @param name Define the name of the camera in the scene
  12691. * @param position Define the start position of the camera in the scene
  12692. * @param scene Define the scene the camera belongs to
  12693. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12694. */
  12695. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12696. /**
  12697. * Attached controls to the current camera.
  12698. * @param element Defines the element the controls should be listened from
  12699. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12700. */
  12701. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12702. /**
  12703. * Detach the current controls from the camera.
  12704. * The camera will stop reacting to inputs.
  12705. * @param element Defines the element to stop listening the inputs from
  12706. */
  12707. detachControl(element: HTMLElement): void;
  12708. private _collisionMask;
  12709. /**
  12710. * Define a collision mask to limit the list of object the camera can collide with
  12711. */
  12712. collisionMask: number;
  12713. /** @hidden */
  12714. _collideWithWorld(displacement: Vector3): void;
  12715. private _onCollisionPositionChange;
  12716. /** @hidden */
  12717. _checkInputs(): void;
  12718. /** @hidden */
  12719. _decideIfNeedsToMove(): boolean;
  12720. /** @hidden */
  12721. _updatePosition(): void;
  12722. /**
  12723. * Destroy the camera and release the current resources hold by it.
  12724. */
  12725. dispose(): void;
  12726. /**
  12727. * Gets the current object class name.
  12728. * @return the class name
  12729. */
  12730. getClassName(): string;
  12731. }
  12732. }
  12733. declare module "babylonjs/Gamepads/gamepad" {
  12734. import { Observable } from "babylonjs/Misc/observable";
  12735. /**
  12736. * Represents a gamepad control stick position
  12737. */
  12738. export class StickValues {
  12739. /**
  12740. * The x component of the control stick
  12741. */
  12742. x: number;
  12743. /**
  12744. * The y component of the control stick
  12745. */
  12746. y: number;
  12747. /**
  12748. * Initializes the gamepad x and y control stick values
  12749. * @param x The x component of the gamepad control stick value
  12750. * @param y The y component of the gamepad control stick value
  12751. */
  12752. constructor(
  12753. /**
  12754. * The x component of the control stick
  12755. */
  12756. x: number,
  12757. /**
  12758. * The y component of the control stick
  12759. */
  12760. y: number);
  12761. }
  12762. /**
  12763. * An interface which manages callbacks for gamepad button changes
  12764. */
  12765. export interface GamepadButtonChanges {
  12766. /**
  12767. * Called when a gamepad has been changed
  12768. */
  12769. changed: boolean;
  12770. /**
  12771. * Called when a gamepad press event has been triggered
  12772. */
  12773. pressChanged: boolean;
  12774. /**
  12775. * Called when a touch event has been triggered
  12776. */
  12777. touchChanged: boolean;
  12778. /**
  12779. * Called when a value has changed
  12780. */
  12781. valueChanged: boolean;
  12782. }
  12783. /**
  12784. * Represents a gamepad
  12785. */
  12786. export class Gamepad {
  12787. /**
  12788. * The id of the gamepad
  12789. */
  12790. id: string;
  12791. /**
  12792. * The index of the gamepad
  12793. */
  12794. index: number;
  12795. /**
  12796. * The browser gamepad
  12797. */
  12798. browserGamepad: any;
  12799. /**
  12800. * Specifies what type of gamepad this represents
  12801. */
  12802. type: number;
  12803. private _leftStick;
  12804. private _rightStick;
  12805. /** @hidden */
  12806. _isConnected: boolean;
  12807. private _leftStickAxisX;
  12808. private _leftStickAxisY;
  12809. private _rightStickAxisX;
  12810. private _rightStickAxisY;
  12811. /**
  12812. * Triggered when the left control stick has been changed
  12813. */
  12814. private _onleftstickchanged;
  12815. /**
  12816. * Triggered when the right control stick has been changed
  12817. */
  12818. private _onrightstickchanged;
  12819. /**
  12820. * Represents a gamepad controller
  12821. */
  12822. static GAMEPAD: number;
  12823. /**
  12824. * Represents a generic controller
  12825. */
  12826. static GENERIC: number;
  12827. /**
  12828. * Represents an XBox controller
  12829. */
  12830. static XBOX: number;
  12831. /**
  12832. * Represents a pose-enabled controller
  12833. */
  12834. static POSE_ENABLED: number;
  12835. /**
  12836. * Specifies whether the left control stick should be Y-inverted
  12837. */
  12838. protected _invertLeftStickY: boolean;
  12839. /**
  12840. * Specifies if the gamepad has been connected
  12841. */
  12842. readonly isConnected: boolean;
  12843. /**
  12844. * Initializes the gamepad
  12845. * @param id The id of the gamepad
  12846. * @param index The index of the gamepad
  12847. * @param browserGamepad The browser gamepad
  12848. * @param leftStickX The x component of the left joystick
  12849. * @param leftStickY The y component of the left joystick
  12850. * @param rightStickX The x component of the right joystick
  12851. * @param rightStickY The y component of the right joystick
  12852. */
  12853. constructor(
  12854. /**
  12855. * The id of the gamepad
  12856. */
  12857. id: string,
  12858. /**
  12859. * The index of the gamepad
  12860. */
  12861. index: number,
  12862. /**
  12863. * The browser gamepad
  12864. */
  12865. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12866. /**
  12867. * Callback triggered when the left joystick has changed
  12868. * @param callback
  12869. */
  12870. onleftstickchanged(callback: (values: StickValues) => void): void;
  12871. /**
  12872. * Callback triggered when the right joystick has changed
  12873. * @param callback
  12874. */
  12875. onrightstickchanged(callback: (values: StickValues) => void): void;
  12876. /**
  12877. * Gets the left joystick
  12878. */
  12879. /**
  12880. * Sets the left joystick values
  12881. */
  12882. leftStick: StickValues;
  12883. /**
  12884. * Gets the right joystick
  12885. */
  12886. /**
  12887. * Sets the right joystick value
  12888. */
  12889. rightStick: StickValues;
  12890. /**
  12891. * Updates the gamepad joystick positions
  12892. */
  12893. update(): void;
  12894. /**
  12895. * Disposes the gamepad
  12896. */
  12897. dispose(): void;
  12898. }
  12899. /**
  12900. * Represents a generic gamepad
  12901. */
  12902. export class GenericPad extends Gamepad {
  12903. private _buttons;
  12904. private _onbuttondown;
  12905. private _onbuttonup;
  12906. /**
  12907. * Observable triggered when a button has been pressed
  12908. */
  12909. onButtonDownObservable: Observable<number>;
  12910. /**
  12911. * Observable triggered when a button has been released
  12912. */
  12913. onButtonUpObservable: Observable<number>;
  12914. /**
  12915. * Callback triggered when a button has been pressed
  12916. * @param callback Called when a button has been pressed
  12917. */
  12918. onbuttondown(callback: (buttonPressed: number) => void): void;
  12919. /**
  12920. * Callback triggered when a button has been released
  12921. * @param callback Called when a button has been released
  12922. */
  12923. onbuttonup(callback: (buttonReleased: number) => void): void;
  12924. /**
  12925. * Initializes the generic gamepad
  12926. * @param id The id of the generic gamepad
  12927. * @param index The index of the generic gamepad
  12928. * @param browserGamepad The browser gamepad
  12929. */
  12930. constructor(id: string, index: number, browserGamepad: any);
  12931. private _setButtonValue;
  12932. /**
  12933. * Updates the generic gamepad
  12934. */
  12935. update(): void;
  12936. /**
  12937. * Disposes the generic gamepad
  12938. */
  12939. dispose(): void;
  12940. }
  12941. }
  12942. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12943. import { Observable } from "babylonjs/Misc/observable";
  12944. import { Nullable } from "babylonjs/types";
  12945. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12946. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12948. import { Ray } from "babylonjs/Culling/ray";
  12949. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12950. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12951. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12952. /**
  12953. * Defines the types of pose enabled controllers that are supported
  12954. */
  12955. export enum PoseEnabledControllerType {
  12956. /**
  12957. * HTC Vive
  12958. */
  12959. VIVE = 0,
  12960. /**
  12961. * Oculus Rift
  12962. */
  12963. OCULUS = 1,
  12964. /**
  12965. * Windows mixed reality
  12966. */
  12967. WINDOWS = 2,
  12968. /**
  12969. * Samsung gear VR
  12970. */
  12971. GEAR_VR = 3,
  12972. /**
  12973. * Google Daydream
  12974. */
  12975. DAYDREAM = 4,
  12976. /**
  12977. * Generic
  12978. */
  12979. GENERIC = 5
  12980. }
  12981. /**
  12982. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12983. */
  12984. export interface MutableGamepadButton {
  12985. /**
  12986. * Value of the button/trigger
  12987. */
  12988. value: number;
  12989. /**
  12990. * If the button/trigger is currently touched
  12991. */
  12992. touched: boolean;
  12993. /**
  12994. * If the button/trigger is currently pressed
  12995. */
  12996. pressed: boolean;
  12997. }
  12998. /**
  12999. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  13000. * @hidden
  13001. */
  13002. export interface ExtendedGamepadButton extends GamepadButton {
  13003. /**
  13004. * If the button/trigger is currently pressed
  13005. */
  13006. readonly pressed: boolean;
  13007. /**
  13008. * If the button/trigger is currently touched
  13009. */
  13010. readonly touched: boolean;
  13011. /**
  13012. * Value of the button/trigger
  13013. */
  13014. readonly value: number;
  13015. }
  13016. /** @hidden */
  13017. export interface _GamePadFactory {
  13018. /**
  13019. * Returns wether or not the current gamepad can be created for this type of controller.
  13020. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13021. * @returns true if it can be created, otherwise false
  13022. */
  13023. canCreate(gamepadInfo: any): boolean;
  13024. /**
  13025. * Creates a new instance of the Gamepad.
  13026. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13027. * @returns the new gamepad instance
  13028. */
  13029. create(gamepadInfo: any): Gamepad;
  13030. }
  13031. /**
  13032. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13033. */
  13034. export class PoseEnabledControllerHelper {
  13035. /** @hidden */
  13036. static _ControllerFactories: _GamePadFactory[];
  13037. /** @hidden */
  13038. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  13039. /**
  13040. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13041. * @param vrGamepad the gamepad to initialized
  13042. * @returns a vr controller of the type the gamepad identified as
  13043. */
  13044. static InitiateController(vrGamepad: any): Gamepad;
  13045. }
  13046. /**
  13047. * Defines the PoseEnabledController object that contains state of a vr capable controller
  13048. */
  13049. export class PoseEnabledController extends Gamepad implements PoseControlled {
  13050. private _deviceRoomPosition;
  13051. private _deviceRoomRotationQuaternion;
  13052. /**
  13053. * The device position in babylon space
  13054. */
  13055. devicePosition: Vector3;
  13056. /**
  13057. * The device rotation in babylon space
  13058. */
  13059. deviceRotationQuaternion: Quaternion;
  13060. /**
  13061. * The scale factor of the device in babylon space
  13062. */
  13063. deviceScaleFactor: number;
  13064. /**
  13065. * (Likely devicePosition should be used instead) The device position in its room space
  13066. */
  13067. position: Vector3;
  13068. /**
  13069. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  13070. */
  13071. rotationQuaternion: Quaternion;
  13072. /**
  13073. * The type of controller (Eg. Windows mixed reality)
  13074. */
  13075. controllerType: PoseEnabledControllerType;
  13076. protected _calculatedPosition: Vector3;
  13077. private _calculatedRotation;
  13078. /**
  13079. * The raw pose from the device
  13080. */
  13081. rawPose: DevicePose;
  13082. private _trackPosition;
  13083. private _maxRotationDistFromHeadset;
  13084. private _draggedRoomRotation;
  13085. /**
  13086. * @hidden
  13087. */
  13088. _disableTrackPosition(fixedPosition: Vector3): void;
  13089. /**
  13090. * Internal, the mesh attached to the controller
  13091. * @hidden
  13092. */
  13093. _mesh: Nullable<AbstractMesh>;
  13094. private _poseControlledCamera;
  13095. private _leftHandSystemQuaternion;
  13096. /**
  13097. * Internal, matrix used to convert room space to babylon space
  13098. * @hidden
  13099. */
  13100. _deviceToWorld: Matrix;
  13101. /**
  13102. * Node to be used when casting a ray from the controller
  13103. * @hidden
  13104. */
  13105. _pointingPoseNode: Nullable<TransformNode>;
  13106. /**
  13107. * Name of the child mesh that can be used to cast a ray from the controller
  13108. */
  13109. static readonly POINTING_POSE: string;
  13110. /**
  13111. * Creates a new PoseEnabledController from a gamepad
  13112. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  13113. */
  13114. constructor(browserGamepad: any);
  13115. private _workingMatrix;
  13116. /**
  13117. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  13118. */
  13119. update(): void;
  13120. /**
  13121. * Updates only the pose device and mesh without doing any button event checking
  13122. */
  13123. protected _updatePoseAndMesh(): void;
  13124. /**
  13125. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  13126. * @param poseData raw pose fromthe device
  13127. */
  13128. updateFromDevice(poseData: DevicePose): void;
  13129. /**
  13130. * @hidden
  13131. */
  13132. _meshAttachedObservable: Observable<AbstractMesh>;
  13133. /**
  13134. * Attaches a mesh to the controller
  13135. * @param mesh the mesh to be attached
  13136. */
  13137. attachToMesh(mesh: AbstractMesh): void;
  13138. /**
  13139. * Attaches the controllers mesh to a camera
  13140. * @param camera the camera the mesh should be attached to
  13141. */
  13142. attachToPoseControlledCamera(camera: TargetCamera): void;
  13143. /**
  13144. * Disposes of the controller
  13145. */
  13146. dispose(): void;
  13147. /**
  13148. * The mesh that is attached to the controller
  13149. */
  13150. readonly mesh: Nullable<AbstractMesh>;
  13151. /**
  13152. * Gets the ray of the controller in the direction the controller is pointing
  13153. * @param length the length the resulting ray should be
  13154. * @returns a ray in the direction the controller is pointing
  13155. */
  13156. getForwardRay(length?: number): Ray;
  13157. }
  13158. }
  13159. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  13160. import { Observable } from "babylonjs/Misc/observable";
  13161. import { Scene } from "babylonjs/scene";
  13162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13163. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  13164. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  13165. /**
  13166. * Defines the WebVRController object that represents controllers tracked in 3D space
  13167. */
  13168. export abstract class WebVRController extends PoseEnabledController {
  13169. /**
  13170. * Internal, the default controller model for the controller
  13171. */
  13172. protected _defaultModel: AbstractMesh;
  13173. /**
  13174. * Fired when the trigger state has changed
  13175. */
  13176. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13177. /**
  13178. * Fired when the main button state has changed
  13179. */
  13180. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13181. /**
  13182. * Fired when the secondary button state has changed
  13183. */
  13184. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13185. /**
  13186. * Fired when the pad state has changed
  13187. */
  13188. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13189. /**
  13190. * Fired when controllers stick values have changed
  13191. */
  13192. onPadValuesChangedObservable: Observable<StickValues>;
  13193. /**
  13194. * Array of button availible on the controller
  13195. */
  13196. protected _buttons: Array<MutableGamepadButton>;
  13197. private _onButtonStateChange;
  13198. /**
  13199. * Fired when a controller button's state has changed
  13200. * @param callback the callback containing the button that was modified
  13201. */
  13202. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13203. /**
  13204. * X and Y axis corrisponding to the controllers joystick
  13205. */
  13206. pad: StickValues;
  13207. /**
  13208. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13209. */
  13210. hand: string;
  13211. /**
  13212. * The default controller model for the controller
  13213. */
  13214. readonly defaultModel: AbstractMesh;
  13215. /**
  13216. * Creates a new WebVRController from a gamepad
  13217. * @param vrGamepad the gamepad that the WebVRController should be created from
  13218. */
  13219. constructor(vrGamepad: any);
  13220. /**
  13221. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13222. */
  13223. update(): void;
  13224. /**
  13225. * Function to be called when a button is modified
  13226. */
  13227. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13228. /**
  13229. * Loads a mesh and attaches it to the controller
  13230. * @param scene the scene the mesh should be added to
  13231. * @param meshLoaded callback for when the mesh has been loaded
  13232. */
  13233. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13234. private _setButtonValue;
  13235. private _changes;
  13236. private _checkChanges;
  13237. /**
  13238. * Disposes of th webVRCOntroller
  13239. */
  13240. dispose(): void;
  13241. }
  13242. }
  13243. declare module "babylonjs/Lights/hemisphericLight" {
  13244. import { Nullable } from "babylonjs/types";
  13245. import { Scene } from "babylonjs/scene";
  13246. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13247. import { Effect } from "babylonjs/Materials/effect";
  13248. import { Light } from "babylonjs/Lights/light";
  13249. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13250. /**
  13251. * The HemisphericLight simulates the ambient environment light,
  13252. * so the passed direction is the light reflection direction, not the incoming direction.
  13253. */
  13254. export class HemisphericLight extends Light {
  13255. /**
  13256. * The groundColor is the light in the opposite direction to the one specified during creation.
  13257. * 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.
  13258. */
  13259. groundColor: Color3;
  13260. /**
  13261. * The light reflection direction, not the incoming direction.
  13262. */
  13263. direction: Vector3;
  13264. /**
  13265. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13266. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13267. * The HemisphericLight can't cast shadows.
  13268. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13269. * @param name The friendly name of the light
  13270. * @param direction The direction of the light reflection
  13271. * @param scene The scene the light belongs to
  13272. */
  13273. constructor(name: string, direction: Vector3, scene: Scene);
  13274. protected _buildUniformLayout(): void;
  13275. /**
  13276. * Returns the string "HemisphericLight".
  13277. * @return The class name
  13278. */
  13279. getClassName(): string;
  13280. /**
  13281. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13282. * Returns the updated direction.
  13283. * @param target The target the direction should point to
  13284. * @return The computed direction
  13285. */
  13286. setDirectionToTarget(target: Vector3): Vector3;
  13287. /**
  13288. * Returns the shadow generator associated to the light.
  13289. * @returns Always null for hemispheric lights because it does not support shadows.
  13290. */
  13291. getShadowGenerator(): Nullable<IShadowGenerator>;
  13292. /**
  13293. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13294. * @param effect The effect to update
  13295. * @param lightIndex The index of the light in the effect to update
  13296. * @returns The hemispheric light
  13297. */
  13298. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13299. /**
  13300. * Computes the world matrix of the node
  13301. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13302. * @param useWasUpdatedFlag defines a reserved property
  13303. * @returns the world matrix
  13304. */
  13305. computeWorldMatrix(): Matrix;
  13306. /**
  13307. * Returns the integer 3.
  13308. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13309. */
  13310. getTypeID(): number;
  13311. /**
  13312. * Prepares the list of defines specific to the light type.
  13313. * @param defines the list of defines
  13314. * @param lightIndex defines the index of the light for the effect
  13315. */
  13316. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13317. }
  13318. }
  13319. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  13320. /** @hidden */
  13321. export var vrMultiviewToSingleviewPixelShader: {
  13322. name: string;
  13323. shader: string;
  13324. };
  13325. }
  13326. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  13327. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13328. import { Scene } from "babylonjs/scene";
  13329. /**
  13330. * Renders to multiple views with a single draw call
  13331. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13332. */
  13333. export class MultiviewRenderTarget extends RenderTargetTexture {
  13334. /**
  13335. * Creates a multiview render target
  13336. * @param scene scene used with the render target
  13337. * @param size the size of the render target (used for each view)
  13338. */
  13339. constructor(scene: Scene, size?: number | {
  13340. width: number;
  13341. height: number;
  13342. } | {
  13343. ratio: number;
  13344. });
  13345. /**
  13346. * @hidden
  13347. * @param faceIndex the face index, if its a cube texture
  13348. */
  13349. _bindFrameBuffer(faceIndex?: number): void;
  13350. /**
  13351. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13352. * @returns the view count
  13353. */
  13354. getViewCount(): number;
  13355. }
  13356. }
  13357. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  13358. import { Camera } from "babylonjs/Cameras/camera";
  13359. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13360. import { Nullable } from "babylonjs/types";
  13361. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13362. import { Matrix } from "babylonjs/Maths/math";
  13363. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  13364. module "babylonjs/Engines/engine" {
  13365. interface Engine {
  13366. /**
  13367. * Creates a new multiview render target
  13368. * @param width defines the width of the texture
  13369. * @param height defines the height of the texture
  13370. * @returns the created multiview texture
  13371. */
  13372. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13373. /**
  13374. * Binds a multiview framebuffer to be drawn to
  13375. * @param multiviewTexture texture to bind
  13376. */
  13377. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13378. }
  13379. }
  13380. module "babylonjs/Cameras/camera" {
  13381. interface Camera {
  13382. /**
  13383. * @hidden
  13384. * 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)
  13385. */
  13386. _useMultiviewToSingleView: boolean;
  13387. /**
  13388. * @hidden
  13389. * 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)
  13390. */
  13391. _multiviewTexture: Nullable<RenderTargetTexture>;
  13392. /**
  13393. * @hidden
  13394. * ensures the multiview texture of the camera exists and has the specified width/height
  13395. * @param width height to set on the multiview texture
  13396. * @param height width to set on the multiview texture
  13397. */
  13398. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13399. }
  13400. }
  13401. module "babylonjs/scene" {
  13402. interface Scene {
  13403. /** @hidden */
  13404. _transformMatrixR: Matrix;
  13405. /** @hidden */
  13406. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13407. /** @hidden */
  13408. _createMultiviewUbo(): void;
  13409. /** @hidden */
  13410. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13411. /** @hidden */
  13412. _renderMultiviewToSingleView(camera: Camera): void;
  13413. }
  13414. }
  13415. }
  13416. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  13417. import { Camera } from "babylonjs/Cameras/camera";
  13418. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13419. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  13420. import "babylonjs/Engines/Extensions/engine.multiview";
  13421. /**
  13422. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13423. * This will not be used for webXR as it supports displaying texture arrays directly
  13424. */
  13425. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13426. /**
  13427. * Initializes a VRMultiviewToSingleview
  13428. * @param name name of the post process
  13429. * @param camera camera to be applied to
  13430. * @param scaleFactor scaling factor to the size of the output texture
  13431. */
  13432. constructor(name: string, camera: Camera, scaleFactor: number);
  13433. }
  13434. }
  13435. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13436. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13437. import { Nullable } from "babylonjs/types";
  13438. import { Observable } from "babylonjs/Misc/observable";
  13439. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13440. import { Scene } from "babylonjs/scene";
  13441. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13442. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13443. import { Node } from "babylonjs/node";
  13444. import { Ray } from "babylonjs/Culling/ray";
  13445. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13446. /**
  13447. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13448. * IMPORTANT!! The data is right-hand data.
  13449. * @export
  13450. * @interface DevicePose
  13451. */
  13452. export interface DevicePose {
  13453. /**
  13454. * The position of the device, values in array are [x,y,z].
  13455. */
  13456. readonly position: Nullable<Float32Array>;
  13457. /**
  13458. * The linearVelocity of the device, values in array are [x,y,z].
  13459. */
  13460. readonly linearVelocity: Nullable<Float32Array>;
  13461. /**
  13462. * The linearAcceleration of the device, values in array are [x,y,z].
  13463. */
  13464. readonly linearAcceleration: Nullable<Float32Array>;
  13465. /**
  13466. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13467. */
  13468. readonly orientation: Nullable<Float32Array>;
  13469. /**
  13470. * The angularVelocity of the device, values in array are [x,y,z].
  13471. */
  13472. readonly angularVelocity: Nullable<Float32Array>;
  13473. /**
  13474. * The angularAcceleration of the device, values in array are [x,y,z].
  13475. */
  13476. readonly angularAcceleration: Nullable<Float32Array>;
  13477. }
  13478. /**
  13479. * Interface representing a pose controlled object in Babylon.
  13480. * A pose controlled object has both regular pose values as well as pose values
  13481. * from an external device such as a VR head mounted display
  13482. */
  13483. export interface PoseControlled {
  13484. /**
  13485. * The position of the object in babylon space.
  13486. */
  13487. position: Vector3;
  13488. /**
  13489. * The rotation quaternion of the object in babylon space.
  13490. */
  13491. rotationQuaternion: Quaternion;
  13492. /**
  13493. * The position of the device in babylon space.
  13494. */
  13495. devicePosition?: Vector3;
  13496. /**
  13497. * The rotation quaternion of the device in babylon space.
  13498. */
  13499. deviceRotationQuaternion: Quaternion;
  13500. /**
  13501. * The raw pose coming from the device.
  13502. */
  13503. rawPose: Nullable<DevicePose>;
  13504. /**
  13505. * The scale of the device to be used when translating from device space to babylon space.
  13506. */
  13507. deviceScaleFactor: number;
  13508. /**
  13509. * Updates the poseControlled values based on the input device pose.
  13510. * @param poseData the pose data to update the object with
  13511. */
  13512. updateFromDevice(poseData: DevicePose): void;
  13513. }
  13514. /**
  13515. * Set of options to customize the webVRCamera
  13516. */
  13517. export interface WebVROptions {
  13518. /**
  13519. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13520. */
  13521. trackPosition?: boolean;
  13522. /**
  13523. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13524. */
  13525. positionScale?: number;
  13526. /**
  13527. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13528. */
  13529. displayName?: string;
  13530. /**
  13531. * Should the native controller meshes be initialized. (default: true)
  13532. */
  13533. controllerMeshes?: boolean;
  13534. /**
  13535. * Creating a default HemiLight only on controllers. (default: true)
  13536. */
  13537. defaultLightingOnControllers?: boolean;
  13538. /**
  13539. * If you don't want to use the default VR button of the helper. (default: false)
  13540. */
  13541. useCustomVRButton?: boolean;
  13542. /**
  13543. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13544. */
  13545. customVRButton?: HTMLButtonElement;
  13546. /**
  13547. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13548. */
  13549. rayLength?: number;
  13550. /**
  13551. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13552. */
  13553. defaultHeight?: number;
  13554. /**
  13555. * If multiview should be used if availible (default: false)
  13556. */
  13557. useMultiview?: boolean;
  13558. }
  13559. /**
  13560. * This represents a WebVR camera.
  13561. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13562. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13563. */
  13564. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13565. private webVROptions;
  13566. /**
  13567. * @hidden
  13568. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13569. */
  13570. _vrDevice: any;
  13571. /**
  13572. * The rawPose of the vrDevice.
  13573. */
  13574. rawPose: Nullable<DevicePose>;
  13575. private _onVREnabled;
  13576. private _specsVersion;
  13577. private _attached;
  13578. private _frameData;
  13579. protected _descendants: Array<Node>;
  13580. private _deviceRoomPosition;
  13581. /** @hidden */
  13582. _deviceRoomRotationQuaternion: Quaternion;
  13583. private _standingMatrix;
  13584. /**
  13585. * Represents device position in babylon space.
  13586. */
  13587. devicePosition: Vector3;
  13588. /**
  13589. * Represents device rotation in babylon space.
  13590. */
  13591. deviceRotationQuaternion: Quaternion;
  13592. /**
  13593. * The scale of the device to be used when translating from device space to babylon space.
  13594. */
  13595. deviceScaleFactor: number;
  13596. private _deviceToWorld;
  13597. private _worldToDevice;
  13598. /**
  13599. * References to the webVR controllers for the vrDevice.
  13600. */
  13601. controllers: Array<WebVRController>;
  13602. /**
  13603. * Emits an event when a controller is attached.
  13604. */
  13605. onControllersAttachedObservable: Observable<WebVRController[]>;
  13606. /**
  13607. * Emits an event when a controller's mesh has been loaded;
  13608. */
  13609. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13610. /**
  13611. * Emits an event when the HMD's pose has been updated.
  13612. */
  13613. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13614. private _poseSet;
  13615. /**
  13616. * If the rig cameras be used as parent instead of this camera.
  13617. */
  13618. rigParenting: boolean;
  13619. private _lightOnControllers;
  13620. private _defaultHeight?;
  13621. /**
  13622. * Instantiates a WebVRFreeCamera.
  13623. * @param name The name of the WebVRFreeCamera
  13624. * @param position The starting anchor position for the camera
  13625. * @param scene The scene the camera belongs to
  13626. * @param webVROptions a set of customizable options for the webVRCamera
  13627. */
  13628. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13629. /**
  13630. * Gets the device distance from the ground in meters.
  13631. * @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.
  13632. */
  13633. deviceDistanceToRoomGround(): number;
  13634. /**
  13635. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13636. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13637. */
  13638. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13639. /**
  13640. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13641. * @returns A promise with a boolean set to if the standing matrix is supported.
  13642. */
  13643. useStandingMatrixAsync(): Promise<boolean>;
  13644. /**
  13645. * Disposes the camera
  13646. */
  13647. dispose(): void;
  13648. /**
  13649. * Gets a vrController by name.
  13650. * @param name The name of the controller to retreive
  13651. * @returns the controller matching the name specified or null if not found
  13652. */
  13653. getControllerByName(name: string): Nullable<WebVRController>;
  13654. private _leftController;
  13655. /**
  13656. * The controller corrisponding to the users left hand.
  13657. */
  13658. readonly leftController: Nullable<WebVRController>;
  13659. private _rightController;
  13660. /**
  13661. * The controller corrisponding to the users right hand.
  13662. */
  13663. readonly rightController: Nullable<WebVRController>;
  13664. /**
  13665. * Casts a ray forward from the vrCamera's gaze.
  13666. * @param length Length of the ray (default: 100)
  13667. * @returns the ray corrisponding to the gaze
  13668. */
  13669. getForwardRay(length?: number): Ray;
  13670. /**
  13671. * @hidden
  13672. * Updates the camera based on device's frame data
  13673. */
  13674. _checkInputs(): void;
  13675. /**
  13676. * Updates the poseControlled values based on the input device pose.
  13677. * @param poseData Pose coming from the device
  13678. */
  13679. updateFromDevice(poseData: DevicePose): void;
  13680. private _htmlElementAttached;
  13681. private _detachIfAttached;
  13682. /**
  13683. * WebVR's attach control will start broadcasting frames to the device.
  13684. * Note that in certain browsers (chrome for example) this function must be called
  13685. * within a user-interaction callback. Example:
  13686. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13687. *
  13688. * @param element html element to attach the vrDevice to
  13689. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13690. */
  13691. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13692. /**
  13693. * Detaches the camera from the html element and disables VR
  13694. *
  13695. * @param element html element to detach from
  13696. */
  13697. detachControl(element: HTMLElement): void;
  13698. /**
  13699. * @returns the name of this class
  13700. */
  13701. getClassName(): string;
  13702. /**
  13703. * Calls resetPose on the vrDisplay
  13704. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13705. */
  13706. resetToCurrentRotation(): void;
  13707. /**
  13708. * @hidden
  13709. * Updates the rig cameras (left and right eye)
  13710. */
  13711. _updateRigCameras(): void;
  13712. private _workingVector;
  13713. private _oneVector;
  13714. private _workingMatrix;
  13715. private updateCacheCalled;
  13716. private _correctPositionIfNotTrackPosition;
  13717. /**
  13718. * @hidden
  13719. * Updates the cached values of the camera
  13720. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13721. */
  13722. _updateCache(ignoreParentClass?: boolean): void;
  13723. /**
  13724. * @hidden
  13725. * Get current device position in babylon world
  13726. */
  13727. _computeDevicePosition(): void;
  13728. /**
  13729. * Updates the current device position and rotation in the babylon world
  13730. */
  13731. update(): void;
  13732. /**
  13733. * @hidden
  13734. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13735. * @returns an identity matrix
  13736. */
  13737. _getViewMatrix(): Matrix;
  13738. private _tmpMatrix;
  13739. /**
  13740. * This function is called by the two RIG cameras.
  13741. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13742. * @hidden
  13743. */
  13744. _getWebVRViewMatrix(): Matrix;
  13745. /** @hidden */
  13746. _getWebVRProjectionMatrix(): Matrix;
  13747. private _onGamepadConnectedObserver;
  13748. private _onGamepadDisconnectedObserver;
  13749. private _updateCacheWhenTrackingDisabledObserver;
  13750. /**
  13751. * Initializes the controllers and their meshes
  13752. */
  13753. initControllers(): void;
  13754. }
  13755. }
  13756. declare module "babylonjs/PostProcesses/postProcess" {
  13757. import { Nullable } from "babylonjs/types";
  13758. import { SmartArray } from "babylonjs/Misc/smartArray";
  13759. import { Observable } from "babylonjs/Misc/observable";
  13760. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13761. import { Camera } from "babylonjs/Cameras/camera";
  13762. import { Effect } from "babylonjs/Materials/effect";
  13763. import "babylonjs/Shaders/postprocess.vertex";
  13764. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13765. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13766. import { Engine } from "babylonjs/Engines/engine";
  13767. /**
  13768. * Size options for a post process
  13769. */
  13770. export type PostProcessOptions = {
  13771. width: number;
  13772. height: number;
  13773. };
  13774. /**
  13775. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13776. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13777. */
  13778. export class PostProcess {
  13779. /** Name of the PostProcess. */
  13780. name: string;
  13781. /**
  13782. * Gets or sets the unique id of the post process
  13783. */
  13784. uniqueId: number;
  13785. /**
  13786. * Width of the texture to apply the post process on
  13787. */
  13788. width: number;
  13789. /**
  13790. * Height of the texture to apply the post process on
  13791. */
  13792. height: number;
  13793. /**
  13794. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13795. * @hidden
  13796. */
  13797. _outputTexture: Nullable<InternalTexture>;
  13798. /**
  13799. * Sampling mode used by the shader
  13800. * See https://doc.babylonjs.com/classes/3.1/texture
  13801. */
  13802. renderTargetSamplingMode: number;
  13803. /**
  13804. * Clear color to use when screen clearing
  13805. */
  13806. clearColor: Color4;
  13807. /**
  13808. * If the buffer needs to be cleared before applying the post process. (default: true)
  13809. * Should be set to false if shader will overwrite all previous pixels.
  13810. */
  13811. autoClear: boolean;
  13812. /**
  13813. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13814. */
  13815. alphaMode: number;
  13816. /**
  13817. * Sets the setAlphaBlendConstants of the babylon engine
  13818. */
  13819. alphaConstants: Color4;
  13820. /**
  13821. * Animations to be used for the post processing
  13822. */
  13823. animations: import("babylonjs/Animations/animation").Animation[];
  13824. /**
  13825. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13826. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13827. */
  13828. enablePixelPerfectMode: boolean;
  13829. /**
  13830. * Force the postprocess to be applied without taking in account viewport
  13831. */
  13832. forceFullscreenViewport: boolean;
  13833. /**
  13834. * List of inspectable custom properties (used by the Inspector)
  13835. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13836. */
  13837. inspectableCustomProperties: IInspectable[];
  13838. /**
  13839. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13840. *
  13841. * | Value | Type | Description |
  13842. * | ----- | ----------------------------------- | ----------- |
  13843. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13844. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13845. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13846. *
  13847. */
  13848. scaleMode: number;
  13849. /**
  13850. * Force textures to be a power of two (default: false)
  13851. */
  13852. alwaysForcePOT: boolean;
  13853. private _samples;
  13854. /**
  13855. * Number of sample textures (default: 1)
  13856. */
  13857. samples: number;
  13858. /**
  13859. * Modify the scale of the post process to be the same as the viewport (default: false)
  13860. */
  13861. adaptScaleToCurrentViewport: boolean;
  13862. private _camera;
  13863. private _scene;
  13864. private _engine;
  13865. private _options;
  13866. private _reusable;
  13867. private _textureType;
  13868. /**
  13869. * Smart array of input and output textures for the post process.
  13870. * @hidden
  13871. */
  13872. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13873. /**
  13874. * The index in _textures that corresponds to the output texture.
  13875. * @hidden
  13876. */
  13877. _currentRenderTextureInd: number;
  13878. private _effect;
  13879. private _samplers;
  13880. private _fragmentUrl;
  13881. private _vertexUrl;
  13882. private _parameters;
  13883. private _scaleRatio;
  13884. protected _indexParameters: any;
  13885. private _shareOutputWithPostProcess;
  13886. private _texelSize;
  13887. private _forcedOutputTexture;
  13888. /**
  13889. * Returns the fragment url or shader name used in the post process.
  13890. * @returns the fragment url or name in the shader store.
  13891. */
  13892. getEffectName(): string;
  13893. /**
  13894. * An event triggered when the postprocess is activated.
  13895. */
  13896. onActivateObservable: Observable<Camera>;
  13897. private _onActivateObserver;
  13898. /**
  13899. * A function that is added to the onActivateObservable
  13900. */
  13901. onActivate: Nullable<(camera: Camera) => void>;
  13902. /**
  13903. * An event triggered when the postprocess changes its size.
  13904. */
  13905. onSizeChangedObservable: Observable<PostProcess>;
  13906. private _onSizeChangedObserver;
  13907. /**
  13908. * A function that is added to the onSizeChangedObservable
  13909. */
  13910. onSizeChanged: (postProcess: PostProcess) => void;
  13911. /**
  13912. * An event triggered when the postprocess applies its effect.
  13913. */
  13914. onApplyObservable: Observable<Effect>;
  13915. private _onApplyObserver;
  13916. /**
  13917. * A function that is added to the onApplyObservable
  13918. */
  13919. onApply: (effect: Effect) => void;
  13920. /**
  13921. * An event triggered before rendering the postprocess
  13922. */
  13923. onBeforeRenderObservable: Observable<Effect>;
  13924. private _onBeforeRenderObserver;
  13925. /**
  13926. * A function that is added to the onBeforeRenderObservable
  13927. */
  13928. onBeforeRender: (effect: Effect) => void;
  13929. /**
  13930. * An event triggered after rendering the postprocess
  13931. */
  13932. onAfterRenderObservable: Observable<Effect>;
  13933. private _onAfterRenderObserver;
  13934. /**
  13935. * A function that is added to the onAfterRenderObservable
  13936. */
  13937. onAfterRender: (efect: Effect) => void;
  13938. /**
  13939. * 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
  13940. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13941. */
  13942. inputTexture: InternalTexture;
  13943. /**
  13944. * Gets the camera which post process is applied to.
  13945. * @returns The camera the post process is applied to.
  13946. */
  13947. getCamera(): Camera;
  13948. /**
  13949. * Gets the texel size of the postprocess.
  13950. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13951. */
  13952. readonly texelSize: Vector2;
  13953. /**
  13954. * Creates a new instance PostProcess
  13955. * @param name The name of the PostProcess.
  13956. * @param fragmentUrl The url of the fragment shader to be used.
  13957. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13958. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13959. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13960. * @param camera The camera to apply the render pass to.
  13961. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13962. * @param engine The engine which the post process will be applied. (default: current engine)
  13963. * @param reusable If the post process can be reused on the same frame. (default: false)
  13964. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13965. * @param textureType Type of textures used when performing the post process. (default: 0)
  13966. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13967. * @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
  13968. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13969. */
  13970. constructor(
  13971. /** Name of the PostProcess. */
  13972. 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);
  13973. /**
  13974. * Gets a string idenfifying the name of the class
  13975. * @returns "PostProcess" string
  13976. */
  13977. getClassName(): string;
  13978. /**
  13979. * Gets the engine which this post process belongs to.
  13980. * @returns The engine the post process was enabled with.
  13981. */
  13982. getEngine(): Engine;
  13983. /**
  13984. * The effect that is created when initializing the post process.
  13985. * @returns The created effect corrisponding the the postprocess.
  13986. */
  13987. getEffect(): Effect;
  13988. /**
  13989. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13990. * @param postProcess The post process to share the output with.
  13991. * @returns This post process.
  13992. */
  13993. shareOutputWith(postProcess: PostProcess): PostProcess;
  13994. /**
  13995. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13996. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13997. */
  13998. useOwnOutput(): void;
  13999. /**
  14000. * Updates the effect with the current post process compile time values and recompiles the shader.
  14001. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  14002. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  14003. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  14004. * @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
  14005. * @param onCompiled Called when the shader has been compiled.
  14006. * @param onError Called if there is an error when compiling a shader.
  14007. */
  14008. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  14009. /**
  14010. * The post process is reusable if it can be used multiple times within one frame.
  14011. * @returns If the post process is reusable
  14012. */
  14013. isReusable(): boolean;
  14014. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  14015. markTextureDirty(): void;
  14016. /**
  14017. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  14018. * 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.
  14019. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  14020. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  14021. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  14022. * @returns The target texture that was bound to be written to.
  14023. */
  14024. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  14025. /**
  14026. * If the post process is supported.
  14027. */
  14028. readonly isSupported: boolean;
  14029. /**
  14030. * The aspect ratio of the output texture.
  14031. */
  14032. readonly aspectRatio: number;
  14033. /**
  14034. * Get a value indicating if the post-process is ready to be used
  14035. * @returns true if the post-process is ready (shader is compiled)
  14036. */
  14037. isReady(): boolean;
  14038. /**
  14039. * Binds all textures and uniforms to the shader, this will be run on every pass.
  14040. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  14041. */
  14042. apply(): Nullable<Effect>;
  14043. private _disposeTextures;
  14044. /**
  14045. * Disposes the post process.
  14046. * @param camera The camera to dispose the post process on.
  14047. */
  14048. dispose(camera?: Camera): void;
  14049. }
  14050. }
  14051. declare module "babylonjs/PostProcesses/postProcessManager" {
  14052. import { Nullable } from "babylonjs/types";
  14053. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14054. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14055. import { Scene } from "babylonjs/scene";
  14056. /**
  14057. * PostProcessManager is used to manage one or more post processes or post process pipelines
  14058. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14059. */
  14060. export class PostProcessManager {
  14061. private _scene;
  14062. private _indexBuffer;
  14063. private _vertexBuffers;
  14064. /**
  14065. * Creates a new instance PostProcess
  14066. * @param scene The scene that the post process is associated with.
  14067. */
  14068. constructor(scene: Scene);
  14069. private _prepareBuffers;
  14070. private _buildIndexBuffer;
  14071. /**
  14072. * Rebuilds the vertex buffers of the manager.
  14073. * @hidden
  14074. */
  14075. _rebuild(): void;
  14076. /**
  14077. * Prepares a frame to be run through a post process.
  14078. * @param sourceTexture The input texture to the post procesess. (default: null)
  14079. * @param postProcesses An array of post processes to be run. (default: null)
  14080. * @returns True if the post processes were able to be run.
  14081. * @hidden
  14082. */
  14083. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  14084. /**
  14085. * Manually render a set of post processes to a texture.
  14086. * @param postProcesses An array of post processes to be run.
  14087. * @param targetTexture The target texture to render to.
  14088. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  14089. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  14090. * @param lodLevel defines which lod of the texture to render to
  14091. */
  14092. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  14093. /**
  14094. * Finalize the result of the output of the postprocesses.
  14095. * @param doNotPresent If true the result will not be displayed to the screen.
  14096. * @param targetTexture The target texture to render to.
  14097. * @param faceIndex The index of the face to bind the target texture to.
  14098. * @param postProcesses The array of post processes to render.
  14099. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  14100. * @hidden
  14101. */
  14102. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  14103. /**
  14104. * Disposes of the post process manager.
  14105. */
  14106. dispose(): void;
  14107. }
  14108. }
  14109. declare module "babylonjs/Layers/layerSceneComponent" {
  14110. import { Scene } from "babylonjs/scene";
  14111. import { ISceneComponent } from "babylonjs/sceneComponent";
  14112. import { Layer } from "babylonjs/Layers/layer";
  14113. module "babylonjs/abstractScene" {
  14114. interface AbstractScene {
  14115. /**
  14116. * The list of layers (background and foreground) of the scene
  14117. */
  14118. layers: Array<Layer>;
  14119. }
  14120. }
  14121. /**
  14122. * Defines the layer scene component responsible to manage any layers
  14123. * in a given scene.
  14124. */
  14125. export class LayerSceneComponent implements ISceneComponent {
  14126. /**
  14127. * The component name helpfull to identify the component in the list of scene components.
  14128. */
  14129. readonly name: string;
  14130. /**
  14131. * The scene the component belongs to.
  14132. */
  14133. scene: Scene;
  14134. private _engine;
  14135. /**
  14136. * Creates a new instance of the component for the given scene
  14137. * @param scene Defines the scene to register the component in
  14138. */
  14139. constructor(scene: Scene);
  14140. /**
  14141. * Registers the component in a given scene
  14142. */
  14143. register(): void;
  14144. /**
  14145. * Rebuilds the elements related to this component in case of
  14146. * context lost for instance.
  14147. */
  14148. rebuild(): void;
  14149. /**
  14150. * Disposes the component and the associated ressources.
  14151. */
  14152. dispose(): void;
  14153. private _draw;
  14154. private _drawCameraPredicate;
  14155. private _drawCameraBackground;
  14156. private _drawCameraForeground;
  14157. private _drawRenderTargetPredicate;
  14158. private _drawRenderTargetBackground;
  14159. private _drawRenderTargetForeground;
  14160. }
  14161. }
  14162. declare module "babylonjs/Shaders/layer.fragment" {
  14163. /** @hidden */
  14164. export var layerPixelShader: {
  14165. name: string;
  14166. shader: string;
  14167. };
  14168. }
  14169. declare module "babylonjs/Shaders/layer.vertex" {
  14170. /** @hidden */
  14171. export var layerVertexShader: {
  14172. name: string;
  14173. shader: string;
  14174. };
  14175. }
  14176. declare module "babylonjs/Layers/layer" {
  14177. import { Observable } from "babylonjs/Misc/observable";
  14178. import { Nullable } from "babylonjs/types";
  14179. import { Scene } from "babylonjs/scene";
  14180. import { Vector2, Color4 } from "babylonjs/Maths/math";
  14181. import { Texture } from "babylonjs/Materials/Textures/texture";
  14182. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14183. import "babylonjs/Shaders/layer.fragment";
  14184. import "babylonjs/Shaders/layer.vertex";
  14185. /**
  14186. * This represents a full screen 2d layer.
  14187. * This can be useful to display a picture in the background of your scene for instance.
  14188. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14189. */
  14190. export class Layer {
  14191. /**
  14192. * Define the name of the layer.
  14193. */
  14194. name: string;
  14195. /**
  14196. * Define the texture the layer should display.
  14197. */
  14198. texture: Nullable<Texture>;
  14199. /**
  14200. * Is the layer in background or foreground.
  14201. */
  14202. isBackground: boolean;
  14203. /**
  14204. * Define the color of the layer (instead of texture).
  14205. */
  14206. color: Color4;
  14207. /**
  14208. * Define the scale of the layer in order to zoom in out of the texture.
  14209. */
  14210. scale: Vector2;
  14211. /**
  14212. * Define an offset for the layer in order to shift the texture.
  14213. */
  14214. offset: Vector2;
  14215. /**
  14216. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14217. */
  14218. alphaBlendingMode: number;
  14219. /**
  14220. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14221. * Alpha test will not mix with the background color in case of transparency.
  14222. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14223. */
  14224. alphaTest: boolean;
  14225. /**
  14226. * Define a mask to restrict the layer to only some of the scene cameras.
  14227. */
  14228. layerMask: number;
  14229. /**
  14230. * Define the list of render target the layer is visible into.
  14231. */
  14232. renderTargetTextures: RenderTargetTexture[];
  14233. /**
  14234. * Define if the layer is only used in renderTarget or if it also
  14235. * renders in the main frame buffer of the canvas.
  14236. */
  14237. renderOnlyInRenderTargetTextures: boolean;
  14238. private _scene;
  14239. private _vertexBuffers;
  14240. private _indexBuffer;
  14241. private _effect;
  14242. private _alphaTestEffect;
  14243. /**
  14244. * An event triggered when the layer is disposed.
  14245. */
  14246. onDisposeObservable: Observable<Layer>;
  14247. private _onDisposeObserver;
  14248. /**
  14249. * Back compatibility with callback before the onDisposeObservable existed.
  14250. * The set callback will be triggered when the layer has been disposed.
  14251. */
  14252. onDispose: () => void;
  14253. /**
  14254. * An event triggered before rendering the scene
  14255. */
  14256. onBeforeRenderObservable: Observable<Layer>;
  14257. private _onBeforeRenderObserver;
  14258. /**
  14259. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14260. * The set callback will be triggered just before rendering the layer.
  14261. */
  14262. onBeforeRender: () => void;
  14263. /**
  14264. * An event triggered after rendering the scene
  14265. */
  14266. onAfterRenderObservable: Observable<Layer>;
  14267. private _onAfterRenderObserver;
  14268. /**
  14269. * Back compatibility with callback before the onAfterRenderObservable existed.
  14270. * The set callback will be triggered just after rendering the layer.
  14271. */
  14272. onAfterRender: () => void;
  14273. /**
  14274. * Instantiates a new layer.
  14275. * This represents a full screen 2d layer.
  14276. * This can be useful to display a picture in the background of your scene for instance.
  14277. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14278. * @param name Define the name of the layer in the scene
  14279. * @param imgUrl Define the url of the texture to display in the layer
  14280. * @param scene Define the scene the layer belongs to
  14281. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14282. * @param color Defines a color for the layer
  14283. */
  14284. constructor(
  14285. /**
  14286. * Define the name of the layer.
  14287. */
  14288. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14289. private _createIndexBuffer;
  14290. /** @hidden */
  14291. _rebuild(): void;
  14292. /**
  14293. * Renders the layer in the scene.
  14294. */
  14295. render(): void;
  14296. /**
  14297. * Disposes and releases the associated ressources.
  14298. */
  14299. dispose(): void;
  14300. }
  14301. }
  14302. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14303. import { Scene } from "babylonjs/scene";
  14304. import { ISceneComponent } from "babylonjs/sceneComponent";
  14305. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14306. module "babylonjs/abstractScene" {
  14307. interface AbstractScene {
  14308. /**
  14309. * The list of procedural textures added to the scene
  14310. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14311. */
  14312. proceduralTextures: Array<ProceduralTexture>;
  14313. }
  14314. }
  14315. /**
  14316. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14317. * in a given scene.
  14318. */
  14319. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14320. /**
  14321. * The component name helpfull to identify the component in the list of scene components.
  14322. */
  14323. readonly name: string;
  14324. /**
  14325. * The scene the component belongs to.
  14326. */
  14327. scene: Scene;
  14328. /**
  14329. * Creates a new instance of the component for the given scene
  14330. * @param scene Defines the scene to register the component in
  14331. */
  14332. constructor(scene: Scene);
  14333. /**
  14334. * Registers the component in a given scene
  14335. */
  14336. register(): void;
  14337. /**
  14338. * Rebuilds the elements related to this component in case of
  14339. * context lost for instance.
  14340. */
  14341. rebuild(): void;
  14342. /**
  14343. * Disposes the component and the associated ressources.
  14344. */
  14345. dispose(): void;
  14346. private _beforeClear;
  14347. }
  14348. }
  14349. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  14350. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14351. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  14352. module "babylonjs/Engines/engine" {
  14353. interface Engine {
  14354. /**
  14355. * Creates a new render target cube texture
  14356. * @param size defines the size of the texture
  14357. * @param options defines the options used to create the texture
  14358. * @returns a new render target cube texture stored in an InternalTexture
  14359. */
  14360. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14361. }
  14362. }
  14363. }
  14364. declare module "babylonjs/Shaders/procedural.vertex" {
  14365. /** @hidden */
  14366. export var proceduralVertexShader: {
  14367. name: string;
  14368. shader: string;
  14369. };
  14370. }
  14371. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14372. import { Observable } from "babylonjs/Misc/observable";
  14373. import { Nullable } from "babylonjs/types";
  14374. import { Scene } from "babylonjs/scene";
  14375. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14376. import { Effect } from "babylonjs/Materials/effect";
  14377. import { Texture } from "babylonjs/Materials/Textures/texture";
  14378. import "babylonjs/Engines/Extensions/engine.renderTarget";
  14379. import "babylonjs/Shaders/procedural.vertex";
  14380. /**
  14381. * 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.
  14382. * This is the base class of any Procedural texture and contains most of the shareable code.
  14383. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14384. */
  14385. export class ProceduralTexture extends Texture {
  14386. isCube: boolean;
  14387. /**
  14388. * Define if the texture is enabled or not (disabled texture will not render)
  14389. */
  14390. isEnabled: boolean;
  14391. /**
  14392. * Define if the texture must be cleared before rendering (default is true)
  14393. */
  14394. autoClear: boolean;
  14395. /**
  14396. * Callback called when the texture is generated
  14397. */
  14398. onGenerated: () => void;
  14399. /**
  14400. * Event raised when the texture is generated
  14401. */
  14402. onGeneratedObservable: Observable<ProceduralTexture>;
  14403. /** @hidden */
  14404. _generateMipMaps: boolean;
  14405. /** @hidden **/
  14406. _effect: Effect;
  14407. /** @hidden */
  14408. _textures: {
  14409. [key: string]: Texture;
  14410. };
  14411. private _size;
  14412. private _currentRefreshId;
  14413. private _refreshRate;
  14414. private _vertexBuffers;
  14415. private _indexBuffer;
  14416. private _uniforms;
  14417. private _samplers;
  14418. private _fragment;
  14419. private _floats;
  14420. private _ints;
  14421. private _floatsArrays;
  14422. private _colors3;
  14423. private _colors4;
  14424. private _vectors2;
  14425. private _vectors3;
  14426. private _matrices;
  14427. private _fallbackTexture;
  14428. private _fallbackTextureUsed;
  14429. private _engine;
  14430. private _cachedDefines;
  14431. private _contentUpdateId;
  14432. private _contentData;
  14433. /**
  14434. * Instantiates a new procedural texture.
  14435. * 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.
  14436. * This is the base class of any Procedural texture and contains most of the shareable code.
  14437. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14438. * @param name Define the name of the texture
  14439. * @param size Define the size of the texture to create
  14440. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14441. * @param scene Define the scene the texture belongs to
  14442. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14443. * @param generateMipMaps Define if the texture should creates mip maps or not
  14444. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14445. */
  14446. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14447. /**
  14448. * The effect that is created when initializing the post process.
  14449. * @returns The created effect corrisponding the the postprocess.
  14450. */
  14451. getEffect(): Effect;
  14452. /**
  14453. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14454. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14455. */
  14456. getContent(): Nullable<ArrayBufferView>;
  14457. private _createIndexBuffer;
  14458. /** @hidden */
  14459. _rebuild(): void;
  14460. /**
  14461. * Resets the texture in order to recreate its associated resources.
  14462. * This can be called in case of context loss
  14463. */
  14464. reset(): void;
  14465. protected _getDefines(): string;
  14466. /**
  14467. * Is the texture ready to be used ? (rendered at least once)
  14468. * @returns true if ready, otherwise, false.
  14469. */
  14470. isReady(): boolean;
  14471. /**
  14472. * Resets the refresh counter of the texture and start bak from scratch.
  14473. * Could be useful to regenerate the texture if it is setup to render only once.
  14474. */
  14475. resetRefreshCounter(): void;
  14476. /**
  14477. * Set the fragment shader to use in order to render the texture.
  14478. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14479. */
  14480. setFragment(fragment: any): void;
  14481. /**
  14482. * Define the refresh rate of the texture or the rendering frequency.
  14483. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14484. */
  14485. refreshRate: number;
  14486. /** @hidden */
  14487. _shouldRender(): boolean;
  14488. /**
  14489. * Get the size the texture is rendering at.
  14490. * @returns the size (texture is always squared)
  14491. */
  14492. getRenderSize(): number;
  14493. /**
  14494. * Resize the texture to new value.
  14495. * @param size Define the new size the texture should have
  14496. * @param generateMipMaps Define whether the new texture should create mip maps
  14497. */
  14498. resize(size: number, generateMipMaps: boolean): void;
  14499. private _checkUniform;
  14500. /**
  14501. * Set a texture in the shader program used to render.
  14502. * @param name Define the name of the uniform samplers as defined in the shader
  14503. * @param texture Define the texture to bind to this sampler
  14504. * @return the texture itself allowing "fluent" like uniform updates
  14505. */
  14506. setTexture(name: string, texture: Texture): ProceduralTexture;
  14507. /**
  14508. * Set a float in the shader.
  14509. * @param name Define the name of the uniform as defined in the shader
  14510. * @param value Define the value to give to the uniform
  14511. * @return the texture itself allowing "fluent" like uniform updates
  14512. */
  14513. setFloat(name: string, value: number): ProceduralTexture;
  14514. /**
  14515. * Set a int in the shader.
  14516. * @param name Define the name of the uniform as defined in the shader
  14517. * @param value Define the value to give to the uniform
  14518. * @return the texture itself allowing "fluent" like uniform updates
  14519. */
  14520. setInt(name: string, value: number): ProceduralTexture;
  14521. /**
  14522. * Set an array of floats in the shader.
  14523. * @param name Define the name of the uniform as defined in the shader
  14524. * @param value Define the value to give to the uniform
  14525. * @return the texture itself allowing "fluent" like uniform updates
  14526. */
  14527. setFloats(name: string, value: number[]): ProceduralTexture;
  14528. /**
  14529. * Set a vec3 in the shader from a Color3.
  14530. * @param name Define the name of the uniform as defined in the shader
  14531. * @param value Define the value to give to the uniform
  14532. * @return the texture itself allowing "fluent" like uniform updates
  14533. */
  14534. setColor3(name: string, value: Color3): ProceduralTexture;
  14535. /**
  14536. * Set a vec4 in the shader from a Color4.
  14537. * @param name Define the name of the uniform as defined in the shader
  14538. * @param value Define the value to give to the uniform
  14539. * @return the texture itself allowing "fluent" like uniform updates
  14540. */
  14541. setColor4(name: string, value: Color4): ProceduralTexture;
  14542. /**
  14543. * Set a vec2 in the shader from a Vector2.
  14544. * @param name Define the name of the uniform as defined in the shader
  14545. * @param value Define the value to give to the uniform
  14546. * @return the texture itself allowing "fluent" like uniform updates
  14547. */
  14548. setVector2(name: string, value: Vector2): ProceduralTexture;
  14549. /**
  14550. * Set a vec3 in the shader from a Vector3.
  14551. * @param name Define the name of the uniform as defined in the shader
  14552. * @param value Define the value to give to the uniform
  14553. * @return the texture itself allowing "fluent" like uniform updates
  14554. */
  14555. setVector3(name: string, value: Vector3): ProceduralTexture;
  14556. /**
  14557. * Set a mat4 in the shader from a MAtrix.
  14558. * @param name Define the name of the uniform as defined in the shader
  14559. * @param value Define the value to give to the uniform
  14560. * @return the texture itself allowing "fluent" like uniform updates
  14561. */
  14562. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14563. /**
  14564. * Render the texture to its associated render target.
  14565. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14566. */
  14567. render(useCameraPostProcess?: boolean): void;
  14568. /**
  14569. * Clone the texture.
  14570. * @returns the cloned texture
  14571. */
  14572. clone(): ProceduralTexture;
  14573. /**
  14574. * Dispose the texture and release its asoociated resources.
  14575. */
  14576. dispose(): void;
  14577. }
  14578. }
  14579. declare module "babylonjs/Particles/baseParticleSystem" {
  14580. import { Nullable } from "babylonjs/types";
  14581. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14583. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14584. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14585. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14586. import { Scene } from "babylonjs/scene";
  14587. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14588. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14589. import { Texture } from "babylonjs/Materials/Textures/texture";
  14590. import { Animation } from "babylonjs/Animations/animation";
  14591. /**
  14592. * This represents the base class for particle system in Babylon.
  14593. * 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.
  14594. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14595. * @example https://doc.babylonjs.com/babylon101/particles
  14596. */
  14597. export class BaseParticleSystem {
  14598. /**
  14599. * Source color is added to the destination color without alpha affecting the result
  14600. */
  14601. static BLENDMODE_ONEONE: number;
  14602. /**
  14603. * Blend current color and particle color using particle’s alpha
  14604. */
  14605. static BLENDMODE_STANDARD: number;
  14606. /**
  14607. * Add current color and particle color multiplied by particle’s alpha
  14608. */
  14609. static BLENDMODE_ADD: number;
  14610. /**
  14611. * Multiply current color with particle color
  14612. */
  14613. static BLENDMODE_MULTIPLY: number;
  14614. /**
  14615. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14616. */
  14617. static BLENDMODE_MULTIPLYADD: number;
  14618. /**
  14619. * List of animations used by the particle system.
  14620. */
  14621. animations: Animation[];
  14622. /**
  14623. * The id of the Particle system.
  14624. */
  14625. id: string;
  14626. /**
  14627. * The friendly name of the Particle system.
  14628. */
  14629. name: string;
  14630. /**
  14631. * The rendering group used by the Particle system to chose when to render.
  14632. */
  14633. renderingGroupId: number;
  14634. /**
  14635. * The emitter represents the Mesh or position we are attaching the particle system to.
  14636. */
  14637. emitter: Nullable<AbstractMesh | Vector3>;
  14638. /**
  14639. * The maximum number of particles to emit per frame
  14640. */
  14641. emitRate: number;
  14642. /**
  14643. * If you want to launch only a few particles at once, that can be done, as well.
  14644. */
  14645. manualEmitCount: number;
  14646. /**
  14647. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14648. */
  14649. updateSpeed: number;
  14650. /**
  14651. * The amount of time the particle system is running (depends of the overall update speed).
  14652. */
  14653. targetStopDuration: number;
  14654. /**
  14655. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14656. */
  14657. disposeOnStop: boolean;
  14658. /**
  14659. * Minimum power of emitting particles.
  14660. */
  14661. minEmitPower: number;
  14662. /**
  14663. * Maximum power of emitting particles.
  14664. */
  14665. maxEmitPower: number;
  14666. /**
  14667. * Minimum life time of emitting particles.
  14668. */
  14669. minLifeTime: number;
  14670. /**
  14671. * Maximum life time of emitting particles.
  14672. */
  14673. maxLifeTime: number;
  14674. /**
  14675. * Minimum Size of emitting particles.
  14676. */
  14677. minSize: number;
  14678. /**
  14679. * Maximum Size of emitting particles.
  14680. */
  14681. maxSize: number;
  14682. /**
  14683. * Minimum scale of emitting particles on X axis.
  14684. */
  14685. minScaleX: number;
  14686. /**
  14687. * Maximum scale of emitting particles on X axis.
  14688. */
  14689. maxScaleX: number;
  14690. /**
  14691. * Minimum scale of emitting particles on Y axis.
  14692. */
  14693. minScaleY: number;
  14694. /**
  14695. * Maximum scale of emitting particles on Y axis.
  14696. */
  14697. maxScaleY: number;
  14698. /**
  14699. * Gets or sets the minimal initial rotation in radians.
  14700. */
  14701. minInitialRotation: number;
  14702. /**
  14703. * Gets or sets the maximal initial rotation in radians.
  14704. */
  14705. maxInitialRotation: number;
  14706. /**
  14707. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14708. */
  14709. minAngularSpeed: number;
  14710. /**
  14711. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14712. */
  14713. maxAngularSpeed: number;
  14714. /**
  14715. * The texture used to render each particle. (this can be a spritesheet)
  14716. */
  14717. particleTexture: Nullable<Texture>;
  14718. /**
  14719. * The layer mask we are rendering the particles through.
  14720. */
  14721. layerMask: number;
  14722. /**
  14723. * This can help using your own shader to render the particle system.
  14724. * The according effect will be created
  14725. */
  14726. customShader: any;
  14727. /**
  14728. * By default particle system starts as soon as they are created. This prevents the
  14729. * automatic start to happen and let you decide when to start emitting particles.
  14730. */
  14731. preventAutoStart: boolean;
  14732. private _noiseTexture;
  14733. /**
  14734. * Gets or sets a texture used to add random noise to particle positions
  14735. */
  14736. noiseTexture: Nullable<ProceduralTexture>;
  14737. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14738. noiseStrength: Vector3;
  14739. /**
  14740. * Callback triggered when the particle animation is ending.
  14741. */
  14742. onAnimationEnd: Nullable<() => void>;
  14743. /**
  14744. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14745. */
  14746. blendMode: number;
  14747. /**
  14748. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14749. * to override the particles.
  14750. */
  14751. forceDepthWrite: boolean;
  14752. /** 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 */
  14753. preWarmCycles: number;
  14754. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14755. preWarmStepOffset: number;
  14756. /**
  14757. * 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)
  14758. */
  14759. spriteCellChangeSpeed: number;
  14760. /**
  14761. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14762. */
  14763. startSpriteCellID: number;
  14764. /**
  14765. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14766. */
  14767. endSpriteCellID: number;
  14768. /**
  14769. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14770. */
  14771. spriteCellWidth: number;
  14772. /**
  14773. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14774. */
  14775. spriteCellHeight: number;
  14776. /**
  14777. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14778. */
  14779. spriteRandomStartCell: boolean;
  14780. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14781. translationPivot: Vector2;
  14782. /** @hidden */
  14783. protected _isAnimationSheetEnabled: boolean;
  14784. /**
  14785. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14786. */
  14787. beginAnimationOnStart: boolean;
  14788. /**
  14789. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14790. */
  14791. beginAnimationFrom: number;
  14792. /**
  14793. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14794. */
  14795. beginAnimationTo: number;
  14796. /**
  14797. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14798. */
  14799. beginAnimationLoop: boolean;
  14800. /**
  14801. * Gets or sets a world offset applied to all particles
  14802. */
  14803. worldOffset: Vector3;
  14804. /**
  14805. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14806. */
  14807. isAnimationSheetEnabled: boolean;
  14808. /**
  14809. * Get hosting scene
  14810. * @returns the scene
  14811. */
  14812. getScene(): Scene;
  14813. /**
  14814. * You can use gravity if you want to give an orientation to your particles.
  14815. */
  14816. gravity: Vector3;
  14817. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14818. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14819. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14820. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14821. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14822. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14823. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14824. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14825. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14826. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14827. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14828. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14829. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14830. /**
  14831. * Defines the delay in milliseconds before starting the system (0 by default)
  14832. */
  14833. startDelay: number;
  14834. /**
  14835. * Gets the current list of drag gradients.
  14836. * You must use addDragGradient and removeDragGradient to udpate this list
  14837. * @returns the list of drag gradients
  14838. */
  14839. getDragGradients(): Nullable<Array<FactorGradient>>;
  14840. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14841. limitVelocityDamping: number;
  14842. /**
  14843. * Gets the current list of limit velocity gradients.
  14844. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14845. * @returns the list of limit velocity gradients
  14846. */
  14847. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14848. /**
  14849. * Gets the current list of color gradients.
  14850. * You must use addColorGradient and removeColorGradient to udpate this list
  14851. * @returns the list of color gradients
  14852. */
  14853. getColorGradients(): Nullable<Array<ColorGradient>>;
  14854. /**
  14855. * Gets the current list of size gradients.
  14856. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14857. * @returns the list of size gradients
  14858. */
  14859. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14860. /**
  14861. * Gets the current list of color remap gradients.
  14862. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14863. * @returns the list of color remap gradients
  14864. */
  14865. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14866. /**
  14867. * Gets the current list of alpha remap gradients.
  14868. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14869. * @returns the list of alpha remap gradients
  14870. */
  14871. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14872. /**
  14873. * Gets the current list of life time gradients.
  14874. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14875. * @returns the list of life time gradients
  14876. */
  14877. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14878. /**
  14879. * Gets the current list of angular speed gradients.
  14880. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14881. * @returns the list of angular speed gradients
  14882. */
  14883. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14884. /**
  14885. * Gets the current list of velocity gradients.
  14886. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14887. * @returns the list of velocity gradients
  14888. */
  14889. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14890. /**
  14891. * Gets the current list of start size gradients.
  14892. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14893. * @returns the list of start size gradients
  14894. */
  14895. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14896. /**
  14897. * Gets the current list of emit rate gradients.
  14898. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14899. * @returns the list of emit rate gradients
  14900. */
  14901. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14902. /**
  14903. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14904. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14905. */
  14906. direction1: Vector3;
  14907. /**
  14908. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14909. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14910. */
  14911. direction2: Vector3;
  14912. /**
  14913. * 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.
  14914. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14915. */
  14916. minEmitBox: Vector3;
  14917. /**
  14918. * 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.
  14919. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14920. */
  14921. maxEmitBox: Vector3;
  14922. /**
  14923. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14924. */
  14925. color1: Color4;
  14926. /**
  14927. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14928. */
  14929. color2: Color4;
  14930. /**
  14931. * Color the particle will have at the end of its lifetime
  14932. */
  14933. colorDead: Color4;
  14934. /**
  14935. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14936. */
  14937. textureMask: Color4;
  14938. /**
  14939. * The particle emitter type defines the emitter used by the particle system.
  14940. * It can be for example box, sphere, or cone...
  14941. */
  14942. particleEmitterType: IParticleEmitterType;
  14943. /** @hidden */
  14944. _isSubEmitter: boolean;
  14945. /**
  14946. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14947. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14948. */
  14949. billboardMode: number;
  14950. protected _isBillboardBased: boolean;
  14951. /**
  14952. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14953. */
  14954. isBillboardBased: boolean;
  14955. /**
  14956. * The scene the particle system belongs to.
  14957. */
  14958. protected _scene: Scene;
  14959. /**
  14960. * Local cache of defines for image processing.
  14961. */
  14962. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14963. /**
  14964. * Default configuration related to image processing available in the standard Material.
  14965. */
  14966. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14967. /**
  14968. * Gets the image processing configuration used either in this material.
  14969. */
  14970. /**
  14971. * Sets the Default image processing configuration used either in the this material.
  14972. *
  14973. * If sets to null, the scene one is in use.
  14974. */
  14975. imageProcessingConfiguration: ImageProcessingConfiguration;
  14976. /**
  14977. * Attaches a new image processing configuration to the Standard Material.
  14978. * @param configuration
  14979. */
  14980. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14981. /** @hidden */
  14982. protected _reset(): void;
  14983. /** @hidden */
  14984. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14985. /**
  14986. * Instantiates a particle system.
  14987. * 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.
  14988. * @param name The name of the particle system
  14989. */
  14990. constructor(name: string);
  14991. /**
  14992. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14993. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14994. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14995. * @returns the emitter
  14996. */
  14997. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14998. /**
  14999. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15000. * @param radius The radius of the hemisphere to emit from
  15001. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15002. * @returns the emitter
  15003. */
  15004. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15005. /**
  15006. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15007. * @param radius The radius of the sphere to emit from
  15008. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15009. * @returns the emitter
  15010. */
  15011. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15012. /**
  15013. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15014. * @param radius The radius of the sphere to emit from
  15015. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15016. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15017. * @returns the emitter
  15018. */
  15019. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15020. /**
  15021. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15022. * @param radius The radius of the emission cylinder
  15023. * @param height The height of the emission cylinder
  15024. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15025. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15026. * @returns the emitter
  15027. */
  15028. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15029. /**
  15030. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15031. * @param radius The radius of the cylinder to emit from
  15032. * @param height The height of the emission cylinder
  15033. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15034. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15035. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15036. * @returns the emitter
  15037. */
  15038. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15039. /**
  15040. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15041. * @param radius The radius of the cone to emit from
  15042. * @param angle The base angle of the cone
  15043. * @returns the emitter
  15044. */
  15045. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15046. /**
  15047. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15048. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15049. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15050. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15051. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15052. * @returns the emitter
  15053. */
  15054. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15055. }
  15056. }
  15057. declare module "babylonjs/Particles/subEmitter" {
  15058. import { Scene } from "babylonjs/scene";
  15059. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15060. /**
  15061. * Type of sub emitter
  15062. */
  15063. export enum SubEmitterType {
  15064. /**
  15065. * Attached to the particle over it's lifetime
  15066. */
  15067. ATTACHED = 0,
  15068. /**
  15069. * Created when the particle dies
  15070. */
  15071. END = 1
  15072. }
  15073. /**
  15074. * Sub emitter class used to emit particles from an existing particle
  15075. */
  15076. export class SubEmitter {
  15077. /**
  15078. * the particle system to be used by the sub emitter
  15079. */
  15080. particleSystem: ParticleSystem;
  15081. /**
  15082. * Type of the submitter (Default: END)
  15083. */
  15084. type: SubEmitterType;
  15085. /**
  15086. * 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)
  15087. * Note: This only is supported when using an emitter of type Mesh
  15088. */
  15089. inheritDirection: boolean;
  15090. /**
  15091. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15092. */
  15093. inheritedVelocityAmount: number;
  15094. /**
  15095. * Creates a sub emitter
  15096. * @param particleSystem the particle system to be used by the sub emitter
  15097. */
  15098. constructor(
  15099. /**
  15100. * the particle system to be used by the sub emitter
  15101. */
  15102. particleSystem: ParticleSystem);
  15103. /**
  15104. * Clones the sub emitter
  15105. * @returns the cloned sub emitter
  15106. */
  15107. clone(): SubEmitter;
  15108. /**
  15109. * Serialize current object to a JSON object
  15110. * @returns the serialized object
  15111. */
  15112. serialize(): any;
  15113. /** @hidden */
  15114. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  15115. /**
  15116. * Creates a new SubEmitter from a serialized JSON version
  15117. * @param serializationObject defines the JSON object to read from
  15118. * @param scene defines the hosting scene
  15119. * @param rootUrl defines the rootUrl for data loading
  15120. * @returns a new SubEmitter
  15121. */
  15122. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  15123. /** Release associated resources */
  15124. dispose(): void;
  15125. }
  15126. }
  15127. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15128. /** @hidden */
  15129. export var clipPlaneFragmentDeclaration: {
  15130. name: string;
  15131. shader: string;
  15132. };
  15133. }
  15134. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15135. /** @hidden */
  15136. export var imageProcessingDeclaration: {
  15137. name: string;
  15138. shader: string;
  15139. };
  15140. }
  15141. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15142. /** @hidden */
  15143. export var imageProcessingFunctions: {
  15144. name: string;
  15145. shader: string;
  15146. };
  15147. }
  15148. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15149. /** @hidden */
  15150. export var clipPlaneFragment: {
  15151. name: string;
  15152. shader: string;
  15153. };
  15154. }
  15155. declare module "babylonjs/Shaders/particles.fragment" {
  15156. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15157. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15158. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15159. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15160. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15161. /** @hidden */
  15162. export var particlesPixelShader: {
  15163. name: string;
  15164. shader: string;
  15165. };
  15166. }
  15167. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15168. /** @hidden */
  15169. export var clipPlaneVertexDeclaration: {
  15170. name: string;
  15171. shader: string;
  15172. };
  15173. }
  15174. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15175. /** @hidden */
  15176. export var clipPlaneVertex: {
  15177. name: string;
  15178. shader: string;
  15179. };
  15180. }
  15181. declare module "babylonjs/Shaders/particles.vertex" {
  15182. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15183. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15184. /** @hidden */
  15185. export var particlesVertexShader: {
  15186. name: string;
  15187. shader: string;
  15188. };
  15189. }
  15190. declare module "babylonjs/Particles/particleSystem" {
  15191. import { Nullable } from "babylonjs/types";
  15192. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15193. import { Observable } from "babylonjs/Misc/observable";
  15194. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15195. import { Effect } from "babylonjs/Materials/effect";
  15196. import { Scene, IDisposable } from "babylonjs/scene";
  15197. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15198. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15199. import { Particle } from "babylonjs/Particles/particle";
  15200. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15201. import "babylonjs/Shaders/particles.fragment";
  15202. import "babylonjs/Shaders/particles.vertex";
  15203. /**
  15204. * This represents a particle system in Babylon.
  15205. * 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.
  15206. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15207. * @example https://doc.babylonjs.com/babylon101/particles
  15208. */
  15209. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15210. /**
  15211. * Billboard mode will only apply to Y axis
  15212. */
  15213. static readonly BILLBOARDMODE_Y: number;
  15214. /**
  15215. * Billboard mode will apply to all axes
  15216. */
  15217. static readonly BILLBOARDMODE_ALL: number;
  15218. /**
  15219. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15220. */
  15221. static readonly BILLBOARDMODE_STRETCHED: number;
  15222. /**
  15223. * This function can be defined to provide custom update for active particles.
  15224. * This function will be called instead of regular update (age, position, color, etc.).
  15225. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15226. */
  15227. updateFunction: (particles: Particle[]) => void;
  15228. private _emitterWorldMatrix;
  15229. /**
  15230. * This function can be defined to specify initial direction for every new particle.
  15231. * It by default use the emitterType defined function
  15232. */
  15233. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15234. /**
  15235. * This function can be defined to specify initial position for every new particle.
  15236. * It by default use the emitterType defined function
  15237. */
  15238. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15239. /**
  15240. * @hidden
  15241. */
  15242. _inheritedVelocityOffset: Vector3;
  15243. /**
  15244. * An event triggered when the system is disposed
  15245. */
  15246. onDisposeObservable: Observable<ParticleSystem>;
  15247. private _onDisposeObserver;
  15248. /**
  15249. * Sets a callback that will be triggered when the system is disposed
  15250. */
  15251. onDispose: () => void;
  15252. private _particles;
  15253. private _epsilon;
  15254. private _capacity;
  15255. private _stockParticles;
  15256. private _newPartsExcess;
  15257. private _vertexData;
  15258. private _vertexBuffer;
  15259. private _vertexBuffers;
  15260. private _spriteBuffer;
  15261. private _indexBuffer;
  15262. private _effect;
  15263. private _customEffect;
  15264. private _cachedDefines;
  15265. private _scaledColorStep;
  15266. private _colorDiff;
  15267. private _scaledDirection;
  15268. private _scaledGravity;
  15269. private _currentRenderId;
  15270. private _alive;
  15271. private _useInstancing;
  15272. private _started;
  15273. private _stopped;
  15274. private _actualFrame;
  15275. private _scaledUpdateSpeed;
  15276. private _vertexBufferSize;
  15277. /** @hidden */
  15278. _currentEmitRateGradient: Nullable<FactorGradient>;
  15279. /** @hidden */
  15280. _currentEmitRate1: number;
  15281. /** @hidden */
  15282. _currentEmitRate2: number;
  15283. /** @hidden */
  15284. _currentStartSizeGradient: Nullable<FactorGradient>;
  15285. /** @hidden */
  15286. _currentStartSize1: number;
  15287. /** @hidden */
  15288. _currentStartSize2: number;
  15289. private readonly _rawTextureWidth;
  15290. private _rampGradientsTexture;
  15291. private _useRampGradients;
  15292. /** Gets or sets a boolean indicating that ramp gradients must be used
  15293. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15294. */
  15295. useRampGradients: boolean;
  15296. /**
  15297. * 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.
  15298. * 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: [])
  15299. */
  15300. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15301. private _subEmitters;
  15302. /**
  15303. * @hidden
  15304. * If the particle systems emitter should be disposed when the particle system is disposed
  15305. */
  15306. _disposeEmitterOnDispose: boolean;
  15307. /**
  15308. * The current active Sub-systems, this property is used by the root particle system only.
  15309. */
  15310. activeSubSystems: Array<ParticleSystem>;
  15311. private _rootParticleSystem;
  15312. /**
  15313. * Gets the current list of active particles
  15314. */
  15315. readonly particles: Particle[];
  15316. /**
  15317. * Returns the string "ParticleSystem"
  15318. * @returns a string containing the class name
  15319. */
  15320. getClassName(): string;
  15321. /**
  15322. * Instantiates a particle system.
  15323. * 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.
  15324. * @param name The name of the particle system
  15325. * @param capacity The max number of particles alive at the same time
  15326. * @param scene The scene the particle system belongs to
  15327. * @param customEffect a custom effect used to change the way particles are rendered by default
  15328. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15329. * @param epsilon Offset used to render the particles
  15330. */
  15331. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15332. private _addFactorGradient;
  15333. private _removeFactorGradient;
  15334. /**
  15335. * Adds a new life time gradient
  15336. * @param gradient defines the gradient to use (between 0 and 1)
  15337. * @param factor defines the life time factor to affect to the specified gradient
  15338. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15339. * @returns the current particle system
  15340. */
  15341. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15342. /**
  15343. * Remove a specific life time gradient
  15344. * @param gradient defines the gradient to remove
  15345. * @returns the current particle system
  15346. */
  15347. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15348. /**
  15349. * Adds a new size gradient
  15350. * @param gradient defines the gradient to use (between 0 and 1)
  15351. * @param factor defines the size factor to affect to the specified gradient
  15352. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15353. * @returns the current particle system
  15354. */
  15355. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15356. /**
  15357. * Remove a specific size gradient
  15358. * @param gradient defines the gradient to remove
  15359. * @returns the current particle system
  15360. */
  15361. removeSizeGradient(gradient: number): IParticleSystem;
  15362. /**
  15363. * Adds a new color remap gradient
  15364. * @param gradient defines the gradient to use (between 0 and 1)
  15365. * @param min defines the color remap minimal range
  15366. * @param max defines the color remap maximal range
  15367. * @returns the current particle system
  15368. */
  15369. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15370. /**
  15371. * Remove a specific color remap gradient
  15372. * @param gradient defines the gradient to remove
  15373. * @returns the current particle system
  15374. */
  15375. removeColorRemapGradient(gradient: number): IParticleSystem;
  15376. /**
  15377. * Adds a new alpha remap gradient
  15378. * @param gradient defines the gradient to use (between 0 and 1)
  15379. * @param min defines the alpha remap minimal range
  15380. * @param max defines the alpha remap maximal range
  15381. * @returns the current particle system
  15382. */
  15383. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15384. /**
  15385. * Remove a specific alpha remap gradient
  15386. * @param gradient defines the gradient to remove
  15387. * @returns the current particle system
  15388. */
  15389. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15390. /**
  15391. * Adds a new angular speed gradient
  15392. * @param gradient defines the gradient to use (between 0 and 1)
  15393. * @param factor defines the angular speed to affect to the specified gradient
  15394. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15395. * @returns the current particle system
  15396. */
  15397. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15398. /**
  15399. * Remove a specific angular speed gradient
  15400. * @param gradient defines the gradient to remove
  15401. * @returns the current particle system
  15402. */
  15403. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15404. /**
  15405. * Adds a new velocity gradient
  15406. * @param gradient defines the gradient to use (between 0 and 1)
  15407. * @param factor defines the velocity to affect to the specified gradient
  15408. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15409. * @returns the current particle system
  15410. */
  15411. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15412. /**
  15413. * Remove a specific velocity gradient
  15414. * @param gradient defines the gradient to remove
  15415. * @returns the current particle system
  15416. */
  15417. removeVelocityGradient(gradient: number): IParticleSystem;
  15418. /**
  15419. * Adds a new limit velocity gradient
  15420. * @param gradient defines the gradient to use (between 0 and 1)
  15421. * @param factor defines the limit velocity value to affect to the specified gradient
  15422. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15423. * @returns the current particle system
  15424. */
  15425. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15426. /**
  15427. * Remove a specific limit velocity gradient
  15428. * @param gradient defines the gradient to remove
  15429. * @returns the current particle system
  15430. */
  15431. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15432. /**
  15433. * Adds a new drag gradient
  15434. * @param gradient defines the gradient to use (between 0 and 1)
  15435. * @param factor defines the drag value to affect to the specified gradient
  15436. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15437. * @returns the current particle system
  15438. */
  15439. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15440. /**
  15441. * Remove a specific drag gradient
  15442. * @param gradient defines the gradient to remove
  15443. * @returns the current particle system
  15444. */
  15445. removeDragGradient(gradient: number): IParticleSystem;
  15446. /**
  15447. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15448. * @param gradient defines the gradient to use (between 0 and 1)
  15449. * @param factor defines the emit rate value to affect to the specified gradient
  15450. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15451. * @returns the current particle system
  15452. */
  15453. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15454. /**
  15455. * Remove a specific emit rate gradient
  15456. * @param gradient defines the gradient to remove
  15457. * @returns the current particle system
  15458. */
  15459. removeEmitRateGradient(gradient: number): IParticleSystem;
  15460. /**
  15461. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15462. * @param gradient defines the gradient to use (between 0 and 1)
  15463. * @param factor defines the start size value to affect to the specified gradient
  15464. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15465. * @returns the current particle system
  15466. */
  15467. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15468. /**
  15469. * Remove a specific start size gradient
  15470. * @param gradient defines the gradient to remove
  15471. * @returns the current particle system
  15472. */
  15473. removeStartSizeGradient(gradient: number): IParticleSystem;
  15474. private _createRampGradientTexture;
  15475. /**
  15476. * Gets the current list of ramp gradients.
  15477. * You must use addRampGradient and removeRampGradient to udpate this list
  15478. * @returns the list of ramp gradients
  15479. */
  15480. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15481. /**
  15482. * Adds a new ramp gradient used to remap particle colors
  15483. * @param gradient defines the gradient to use (between 0 and 1)
  15484. * @param color defines the color to affect to the specified gradient
  15485. * @returns the current particle system
  15486. */
  15487. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15488. /**
  15489. * Remove a specific ramp gradient
  15490. * @param gradient defines the gradient to remove
  15491. * @returns the current particle system
  15492. */
  15493. removeRampGradient(gradient: number): ParticleSystem;
  15494. /**
  15495. * Adds a new color gradient
  15496. * @param gradient defines the gradient to use (between 0 and 1)
  15497. * @param color1 defines the color to affect to the specified gradient
  15498. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15499. * @returns this particle system
  15500. */
  15501. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15502. /**
  15503. * Remove a specific color gradient
  15504. * @param gradient defines the gradient to remove
  15505. * @returns this particle system
  15506. */
  15507. removeColorGradient(gradient: number): IParticleSystem;
  15508. private _fetchR;
  15509. protected _reset(): void;
  15510. private _resetEffect;
  15511. private _createVertexBuffers;
  15512. private _createIndexBuffer;
  15513. /**
  15514. * Gets the maximum number of particles active at the same time.
  15515. * @returns The max number of active particles.
  15516. */
  15517. getCapacity(): number;
  15518. /**
  15519. * Gets whether there are still active particles in the system.
  15520. * @returns True if it is alive, otherwise false.
  15521. */
  15522. isAlive(): boolean;
  15523. /**
  15524. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15525. * @returns True if it has been started, otherwise false.
  15526. */
  15527. isStarted(): boolean;
  15528. private _prepareSubEmitterInternalArray;
  15529. /**
  15530. * Starts the particle system and begins to emit
  15531. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15532. */
  15533. start(delay?: number): void;
  15534. /**
  15535. * Stops the particle system.
  15536. * @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.
  15537. */
  15538. stop(stopSubEmitters?: boolean): void;
  15539. /**
  15540. * Remove all active particles
  15541. */
  15542. reset(): void;
  15543. /**
  15544. * @hidden (for internal use only)
  15545. */
  15546. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15547. /**
  15548. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15549. * Its lifetime will start back at 0.
  15550. */
  15551. recycleParticle: (particle: Particle) => void;
  15552. private _stopSubEmitters;
  15553. private _createParticle;
  15554. private _removeFromRoot;
  15555. private _emitFromParticle;
  15556. private _update;
  15557. /** @hidden */
  15558. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15559. /** @hidden */
  15560. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15561. /** @hidden */
  15562. private _getEffect;
  15563. /**
  15564. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15565. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15566. */
  15567. animate(preWarmOnly?: boolean): void;
  15568. private _appendParticleVertices;
  15569. /**
  15570. * Rebuilds the particle system.
  15571. */
  15572. rebuild(): void;
  15573. /**
  15574. * Is this system ready to be used/rendered
  15575. * @return true if the system is ready
  15576. */
  15577. isReady(): boolean;
  15578. private _render;
  15579. /**
  15580. * Renders the particle system in its current state.
  15581. * @returns the current number of particles
  15582. */
  15583. render(): number;
  15584. /**
  15585. * Disposes the particle system and free the associated resources
  15586. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15587. */
  15588. dispose(disposeTexture?: boolean): void;
  15589. /**
  15590. * Clones the particle system.
  15591. * @param name The name of the cloned object
  15592. * @param newEmitter The new emitter to use
  15593. * @returns the cloned particle system
  15594. */
  15595. clone(name: string, newEmitter: any): ParticleSystem;
  15596. /**
  15597. * Serializes the particle system to a JSON object.
  15598. * @returns the JSON object
  15599. */
  15600. serialize(): any;
  15601. /** @hidden */
  15602. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15603. /** @hidden */
  15604. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15605. /**
  15606. * Parses a JSON object to create a particle system.
  15607. * @param parsedParticleSystem The JSON object to parse
  15608. * @param scene The scene to create the particle system in
  15609. * @param rootUrl The root url to use to load external dependencies like texture
  15610. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15611. * @returns the Parsed particle system
  15612. */
  15613. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15614. }
  15615. }
  15616. declare module "babylonjs/Particles/particle" {
  15617. import { Nullable } from "babylonjs/types";
  15618. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15619. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15620. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15621. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15622. /**
  15623. * A particle represents one of the element emitted by a particle system.
  15624. * This is mainly define by its coordinates, direction, velocity and age.
  15625. */
  15626. export class Particle {
  15627. /**
  15628. * The particle system the particle belongs to.
  15629. */
  15630. particleSystem: ParticleSystem;
  15631. private static _Count;
  15632. /**
  15633. * Unique ID of the particle
  15634. */
  15635. id: number;
  15636. /**
  15637. * The world position of the particle in the scene.
  15638. */
  15639. position: Vector3;
  15640. /**
  15641. * The world direction of the particle in the scene.
  15642. */
  15643. direction: Vector3;
  15644. /**
  15645. * The color of the particle.
  15646. */
  15647. color: Color4;
  15648. /**
  15649. * The color change of the particle per step.
  15650. */
  15651. colorStep: Color4;
  15652. /**
  15653. * Defines how long will the life of the particle be.
  15654. */
  15655. lifeTime: number;
  15656. /**
  15657. * The current age of the particle.
  15658. */
  15659. age: number;
  15660. /**
  15661. * The current size of the particle.
  15662. */
  15663. size: number;
  15664. /**
  15665. * The current scale of the particle.
  15666. */
  15667. scale: Vector2;
  15668. /**
  15669. * The current angle of the particle.
  15670. */
  15671. angle: number;
  15672. /**
  15673. * Defines how fast is the angle changing.
  15674. */
  15675. angularSpeed: number;
  15676. /**
  15677. * Defines the cell index used by the particle to be rendered from a sprite.
  15678. */
  15679. cellIndex: number;
  15680. /**
  15681. * The information required to support color remapping
  15682. */
  15683. remapData: Vector4;
  15684. /** @hidden */
  15685. _randomCellOffset?: number;
  15686. /** @hidden */
  15687. _initialDirection: Nullable<Vector3>;
  15688. /** @hidden */
  15689. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15690. /** @hidden */
  15691. _initialStartSpriteCellID: number;
  15692. /** @hidden */
  15693. _initialEndSpriteCellID: number;
  15694. /** @hidden */
  15695. _currentColorGradient: Nullable<ColorGradient>;
  15696. /** @hidden */
  15697. _currentColor1: Color4;
  15698. /** @hidden */
  15699. _currentColor2: Color4;
  15700. /** @hidden */
  15701. _currentSizeGradient: Nullable<FactorGradient>;
  15702. /** @hidden */
  15703. _currentSize1: number;
  15704. /** @hidden */
  15705. _currentSize2: number;
  15706. /** @hidden */
  15707. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15708. /** @hidden */
  15709. _currentAngularSpeed1: number;
  15710. /** @hidden */
  15711. _currentAngularSpeed2: number;
  15712. /** @hidden */
  15713. _currentVelocityGradient: Nullable<FactorGradient>;
  15714. /** @hidden */
  15715. _currentVelocity1: number;
  15716. /** @hidden */
  15717. _currentVelocity2: number;
  15718. /** @hidden */
  15719. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15720. /** @hidden */
  15721. _currentLimitVelocity1: number;
  15722. /** @hidden */
  15723. _currentLimitVelocity2: number;
  15724. /** @hidden */
  15725. _currentDragGradient: Nullable<FactorGradient>;
  15726. /** @hidden */
  15727. _currentDrag1: number;
  15728. /** @hidden */
  15729. _currentDrag2: number;
  15730. /** @hidden */
  15731. _randomNoiseCoordinates1: Vector3;
  15732. /** @hidden */
  15733. _randomNoiseCoordinates2: Vector3;
  15734. /**
  15735. * Creates a new instance Particle
  15736. * @param particleSystem the particle system the particle belongs to
  15737. */
  15738. constructor(
  15739. /**
  15740. * The particle system the particle belongs to.
  15741. */
  15742. particleSystem: ParticleSystem);
  15743. private updateCellInfoFromSystem;
  15744. /**
  15745. * Defines how the sprite cell index is updated for the particle
  15746. */
  15747. updateCellIndex(): void;
  15748. /** @hidden */
  15749. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15750. /** @hidden */
  15751. _inheritParticleInfoToSubEmitters(): void;
  15752. /** @hidden */
  15753. _reset(): void;
  15754. /**
  15755. * Copy the properties of particle to another one.
  15756. * @param other the particle to copy the information to.
  15757. */
  15758. copyTo(other: Particle): void;
  15759. }
  15760. }
  15761. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15762. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15763. import { Effect } from "babylonjs/Materials/effect";
  15764. import { Particle } from "babylonjs/Particles/particle";
  15765. /**
  15766. * Particle emitter represents a volume emitting particles.
  15767. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15768. */
  15769. export interface IParticleEmitterType {
  15770. /**
  15771. * Called by the particle System when the direction is computed for the created particle.
  15772. * @param worldMatrix is the world matrix of the particle system
  15773. * @param directionToUpdate is the direction vector to update with the result
  15774. * @param particle is the particle we are computed the direction for
  15775. */
  15776. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15777. /**
  15778. * Called by the particle System when the position is computed for the created particle.
  15779. * @param worldMatrix is the world matrix of the particle system
  15780. * @param positionToUpdate is the position vector to update with the result
  15781. * @param particle is the particle we are computed the position for
  15782. */
  15783. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15784. /**
  15785. * Clones the current emitter and returns a copy of it
  15786. * @returns the new emitter
  15787. */
  15788. clone(): IParticleEmitterType;
  15789. /**
  15790. * Called by the GPUParticleSystem to setup the update shader
  15791. * @param effect defines the update shader
  15792. */
  15793. applyToShader(effect: Effect): void;
  15794. /**
  15795. * Returns a string to use to update the GPU particles update shader
  15796. * @returns the effect defines string
  15797. */
  15798. getEffectDefines(): string;
  15799. /**
  15800. * Returns a string representing the class name
  15801. * @returns a string containing the class name
  15802. */
  15803. getClassName(): string;
  15804. /**
  15805. * Serializes the particle system to a JSON object.
  15806. * @returns the JSON object
  15807. */
  15808. serialize(): any;
  15809. /**
  15810. * Parse properties from a JSON object
  15811. * @param serializationObject defines the JSON object
  15812. */
  15813. parse(serializationObject: any): void;
  15814. }
  15815. }
  15816. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15817. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15818. import { Effect } from "babylonjs/Materials/effect";
  15819. import { Particle } from "babylonjs/Particles/particle";
  15820. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15821. /**
  15822. * Particle emitter emitting particles from the inside of a box.
  15823. * It emits the particles randomly between 2 given directions.
  15824. */
  15825. export class BoxParticleEmitter implements IParticleEmitterType {
  15826. /**
  15827. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15828. */
  15829. direction1: Vector3;
  15830. /**
  15831. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15832. */
  15833. direction2: Vector3;
  15834. /**
  15835. * 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.
  15836. */
  15837. minEmitBox: Vector3;
  15838. /**
  15839. * 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.
  15840. */
  15841. maxEmitBox: Vector3;
  15842. /**
  15843. * Creates a new instance BoxParticleEmitter
  15844. */
  15845. constructor();
  15846. /**
  15847. * Called by the particle System when the direction is computed for the created particle.
  15848. * @param worldMatrix is the world matrix of the particle system
  15849. * @param directionToUpdate is the direction vector to update with the result
  15850. * @param particle is the particle we are computed the direction for
  15851. */
  15852. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15853. /**
  15854. * Called by the particle System when the position is computed for the created particle.
  15855. * @param worldMatrix is the world matrix of the particle system
  15856. * @param positionToUpdate is the position vector to update with the result
  15857. * @param particle is the particle we are computed the position for
  15858. */
  15859. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15860. /**
  15861. * Clones the current emitter and returns a copy of it
  15862. * @returns the new emitter
  15863. */
  15864. clone(): BoxParticleEmitter;
  15865. /**
  15866. * Called by the GPUParticleSystem to setup the update shader
  15867. * @param effect defines the update shader
  15868. */
  15869. applyToShader(effect: Effect): void;
  15870. /**
  15871. * Returns a string to use to update the GPU particles update shader
  15872. * @returns a string containng the defines string
  15873. */
  15874. getEffectDefines(): string;
  15875. /**
  15876. * Returns the string "BoxParticleEmitter"
  15877. * @returns a string containing the class name
  15878. */
  15879. getClassName(): string;
  15880. /**
  15881. * Serializes the particle system to a JSON object.
  15882. * @returns the JSON object
  15883. */
  15884. serialize(): any;
  15885. /**
  15886. * Parse properties from a JSON object
  15887. * @param serializationObject defines the JSON object
  15888. */
  15889. parse(serializationObject: any): void;
  15890. }
  15891. }
  15892. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15893. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15894. import { Effect } from "babylonjs/Materials/effect";
  15895. import { Particle } from "babylonjs/Particles/particle";
  15896. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15897. /**
  15898. * Particle emitter emitting particles from the inside of a cone.
  15899. * It emits the particles alongside the cone volume from the base to the particle.
  15900. * The emission direction might be randomized.
  15901. */
  15902. export class ConeParticleEmitter implements IParticleEmitterType {
  15903. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15904. directionRandomizer: number;
  15905. private _radius;
  15906. private _angle;
  15907. private _height;
  15908. /**
  15909. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15910. */
  15911. radiusRange: number;
  15912. /**
  15913. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15914. */
  15915. heightRange: number;
  15916. /**
  15917. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15918. */
  15919. emitFromSpawnPointOnly: boolean;
  15920. /**
  15921. * Gets or sets the radius of the emission cone
  15922. */
  15923. radius: number;
  15924. /**
  15925. * Gets or sets the angle of the emission cone
  15926. */
  15927. angle: number;
  15928. private _buildHeight;
  15929. /**
  15930. * Creates a new instance ConeParticleEmitter
  15931. * @param radius the radius of the emission cone (1 by default)
  15932. * @param angle the cone base angle (PI by default)
  15933. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15934. */
  15935. constructor(radius?: number, angle?: number,
  15936. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15937. directionRandomizer?: number);
  15938. /**
  15939. * Called by the particle System when the direction is computed for the created particle.
  15940. * @param worldMatrix is the world matrix of the particle system
  15941. * @param directionToUpdate is the direction vector to update with the result
  15942. * @param particle is the particle we are computed the direction for
  15943. */
  15944. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15945. /**
  15946. * Called by the particle System when the position is computed for the created particle.
  15947. * @param worldMatrix is the world matrix of the particle system
  15948. * @param positionToUpdate is the position vector to update with the result
  15949. * @param particle is the particle we are computed the position for
  15950. */
  15951. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15952. /**
  15953. * Clones the current emitter and returns a copy of it
  15954. * @returns the new emitter
  15955. */
  15956. clone(): ConeParticleEmitter;
  15957. /**
  15958. * Called by the GPUParticleSystem to setup the update shader
  15959. * @param effect defines the update shader
  15960. */
  15961. applyToShader(effect: Effect): void;
  15962. /**
  15963. * Returns a string to use to update the GPU particles update shader
  15964. * @returns a string containng the defines string
  15965. */
  15966. getEffectDefines(): string;
  15967. /**
  15968. * Returns the string "ConeParticleEmitter"
  15969. * @returns a string containing the class name
  15970. */
  15971. getClassName(): string;
  15972. /**
  15973. * Serializes the particle system to a JSON object.
  15974. * @returns the JSON object
  15975. */
  15976. serialize(): any;
  15977. /**
  15978. * Parse properties from a JSON object
  15979. * @param serializationObject defines the JSON object
  15980. */
  15981. parse(serializationObject: any): void;
  15982. }
  15983. }
  15984. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15985. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15986. import { Effect } from "babylonjs/Materials/effect";
  15987. import { Particle } from "babylonjs/Particles/particle";
  15988. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15989. /**
  15990. * Particle emitter emitting particles from the inside of a cylinder.
  15991. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15992. */
  15993. export class CylinderParticleEmitter implements IParticleEmitterType {
  15994. /**
  15995. * The radius of the emission cylinder.
  15996. */
  15997. radius: number;
  15998. /**
  15999. * The height of the emission cylinder.
  16000. */
  16001. height: number;
  16002. /**
  16003. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16004. */
  16005. radiusRange: number;
  16006. /**
  16007. * How much to randomize the particle direction [0-1].
  16008. */
  16009. directionRandomizer: number;
  16010. /**
  16011. * Creates a new instance CylinderParticleEmitter
  16012. * @param radius the radius of the emission cylinder (1 by default)
  16013. * @param height the height of the emission cylinder (1 by default)
  16014. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16015. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16016. */
  16017. constructor(
  16018. /**
  16019. * The radius of the emission cylinder.
  16020. */
  16021. radius?: number,
  16022. /**
  16023. * The height of the emission cylinder.
  16024. */
  16025. height?: number,
  16026. /**
  16027. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16028. */
  16029. radiusRange?: number,
  16030. /**
  16031. * How much to randomize the particle direction [0-1].
  16032. */
  16033. directionRandomizer?: number);
  16034. /**
  16035. * Called by the particle System when the direction is computed for the created particle.
  16036. * @param worldMatrix is the world matrix of the particle system
  16037. * @param directionToUpdate is the direction vector to update with the result
  16038. * @param particle is the particle we are computed the direction for
  16039. */
  16040. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16041. /**
  16042. * Called by the particle System when the position is computed for the created particle.
  16043. * @param worldMatrix is the world matrix of the particle system
  16044. * @param positionToUpdate is the position vector to update with the result
  16045. * @param particle is the particle we are computed the position for
  16046. */
  16047. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16048. /**
  16049. * Clones the current emitter and returns a copy of it
  16050. * @returns the new emitter
  16051. */
  16052. clone(): CylinderParticleEmitter;
  16053. /**
  16054. * Called by the GPUParticleSystem to setup the update shader
  16055. * @param effect defines the update shader
  16056. */
  16057. applyToShader(effect: Effect): void;
  16058. /**
  16059. * Returns a string to use to update the GPU particles update shader
  16060. * @returns a string containng the defines string
  16061. */
  16062. getEffectDefines(): string;
  16063. /**
  16064. * Returns the string "CylinderParticleEmitter"
  16065. * @returns a string containing the class name
  16066. */
  16067. getClassName(): string;
  16068. /**
  16069. * Serializes the particle system to a JSON object.
  16070. * @returns the JSON object
  16071. */
  16072. serialize(): any;
  16073. /**
  16074. * Parse properties from a JSON object
  16075. * @param serializationObject defines the JSON object
  16076. */
  16077. parse(serializationObject: any): void;
  16078. }
  16079. /**
  16080. * Particle emitter emitting particles from the inside of a cylinder.
  16081. * It emits the particles randomly between two vectors.
  16082. */
  16083. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16084. /**
  16085. * The min limit of the emission direction.
  16086. */
  16087. direction1: Vector3;
  16088. /**
  16089. * The max limit of the emission direction.
  16090. */
  16091. direction2: Vector3;
  16092. /**
  16093. * Creates a new instance CylinderDirectedParticleEmitter
  16094. * @param radius the radius of the emission cylinder (1 by default)
  16095. * @param height the height of the emission cylinder (1 by default)
  16096. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16097. * @param direction1 the min limit of the emission direction (up vector by default)
  16098. * @param direction2 the max limit of the emission direction (up vector by default)
  16099. */
  16100. constructor(radius?: number, height?: number, radiusRange?: number,
  16101. /**
  16102. * The min limit of the emission direction.
  16103. */
  16104. direction1?: Vector3,
  16105. /**
  16106. * The max limit of the emission direction.
  16107. */
  16108. direction2?: Vector3);
  16109. /**
  16110. * Called by the particle System when the direction is computed for the created particle.
  16111. * @param worldMatrix is the world matrix of the particle system
  16112. * @param directionToUpdate is the direction vector to update with the result
  16113. * @param particle is the particle we are computed the direction for
  16114. */
  16115. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16116. /**
  16117. * Clones the current emitter and returns a copy of it
  16118. * @returns the new emitter
  16119. */
  16120. clone(): CylinderDirectedParticleEmitter;
  16121. /**
  16122. * Called by the GPUParticleSystem to setup the update shader
  16123. * @param effect defines the update shader
  16124. */
  16125. applyToShader(effect: Effect): void;
  16126. /**
  16127. * Returns a string to use to update the GPU particles update shader
  16128. * @returns a string containng the defines string
  16129. */
  16130. getEffectDefines(): string;
  16131. /**
  16132. * Returns the string "CylinderDirectedParticleEmitter"
  16133. * @returns a string containing the class name
  16134. */
  16135. getClassName(): string;
  16136. /**
  16137. * Serializes the particle system to a JSON object.
  16138. * @returns the JSON object
  16139. */
  16140. serialize(): any;
  16141. /**
  16142. * Parse properties from a JSON object
  16143. * @param serializationObject defines the JSON object
  16144. */
  16145. parse(serializationObject: any): void;
  16146. }
  16147. }
  16148. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  16149. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16150. import { Effect } from "babylonjs/Materials/effect";
  16151. import { Particle } from "babylonjs/Particles/particle";
  16152. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16153. /**
  16154. * Particle emitter emitting particles from the inside of a hemisphere.
  16155. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16156. */
  16157. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16158. /**
  16159. * The radius of the emission hemisphere.
  16160. */
  16161. radius: number;
  16162. /**
  16163. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16164. */
  16165. radiusRange: number;
  16166. /**
  16167. * How much to randomize the particle direction [0-1].
  16168. */
  16169. directionRandomizer: number;
  16170. /**
  16171. * Creates a new instance HemisphericParticleEmitter
  16172. * @param radius the radius of the emission hemisphere (1 by default)
  16173. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16174. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16175. */
  16176. constructor(
  16177. /**
  16178. * The radius of the emission hemisphere.
  16179. */
  16180. radius?: number,
  16181. /**
  16182. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16183. */
  16184. radiusRange?: number,
  16185. /**
  16186. * How much to randomize the particle direction [0-1].
  16187. */
  16188. directionRandomizer?: number);
  16189. /**
  16190. * Called by the particle System when the direction is computed for the created particle.
  16191. * @param worldMatrix is the world matrix of the particle system
  16192. * @param directionToUpdate is the direction vector to update with the result
  16193. * @param particle is the particle we are computed the direction for
  16194. */
  16195. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16196. /**
  16197. * Called by the particle System when the position is computed for the created particle.
  16198. * @param worldMatrix is the world matrix of the particle system
  16199. * @param positionToUpdate is the position vector to update with the result
  16200. * @param particle is the particle we are computed the position for
  16201. */
  16202. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16203. /**
  16204. * Clones the current emitter and returns a copy of it
  16205. * @returns the new emitter
  16206. */
  16207. clone(): HemisphericParticleEmitter;
  16208. /**
  16209. * Called by the GPUParticleSystem to setup the update shader
  16210. * @param effect defines the update shader
  16211. */
  16212. applyToShader(effect: Effect): void;
  16213. /**
  16214. * Returns a string to use to update the GPU particles update shader
  16215. * @returns a string containng the defines string
  16216. */
  16217. getEffectDefines(): string;
  16218. /**
  16219. * Returns the string "HemisphericParticleEmitter"
  16220. * @returns a string containing the class name
  16221. */
  16222. getClassName(): string;
  16223. /**
  16224. * Serializes the particle system to a JSON object.
  16225. * @returns the JSON object
  16226. */
  16227. serialize(): any;
  16228. /**
  16229. * Parse properties from a JSON object
  16230. * @param serializationObject defines the JSON object
  16231. */
  16232. parse(serializationObject: any): void;
  16233. }
  16234. }
  16235. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16236. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16237. import { Effect } from "babylonjs/Materials/effect";
  16238. import { Particle } from "babylonjs/Particles/particle";
  16239. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16240. /**
  16241. * Particle emitter emitting particles from a point.
  16242. * It emits the particles randomly between 2 given directions.
  16243. */
  16244. export class PointParticleEmitter implements IParticleEmitterType {
  16245. /**
  16246. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16247. */
  16248. direction1: Vector3;
  16249. /**
  16250. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16251. */
  16252. direction2: Vector3;
  16253. /**
  16254. * Creates a new instance PointParticleEmitter
  16255. */
  16256. constructor();
  16257. /**
  16258. * Called by the particle System when the direction is computed for the created particle.
  16259. * @param worldMatrix is the world matrix of the particle system
  16260. * @param directionToUpdate is the direction vector to update with the result
  16261. * @param particle is the particle we are computed the direction for
  16262. */
  16263. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16264. /**
  16265. * Called by the particle System when the position is computed for the created particle.
  16266. * @param worldMatrix is the world matrix of the particle system
  16267. * @param positionToUpdate is the position vector to update with the result
  16268. * @param particle is the particle we are computed the position for
  16269. */
  16270. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16271. /**
  16272. * Clones the current emitter and returns a copy of it
  16273. * @returns the new emitter
  16274. */
  16275. clone(): PointParticleEmitter;
  16276. /**
  16277. * Called by the GPUParticleSystem to setup the update shader
  16278. * @param effect defines the update shader
  16279. */
  16280. applyToShader(effect: Effect): void;
  16281. /**
  16282. * Returns a string to use to update the GPU particles update shader
  16283. * @returns a string containng the defines string
  16284. */
  16285. getEffectDefines(): string;
  16286. /**
  16287. * Returns the string "PointParticleEmitter"
  16288. * @returns a string containing the class name
  16289. */
  16290. getClassName(): string;
  16291. /**
  16292. * Serializes the particle system to a JSON object.
  16293. * @returns the JSON object
  16294. */
  16295. serialize(): any;
  16296. /**
  16297. * Parse properties from a JSON object
  16298. * @param serializationObject defines the JSON object
  16299. */
  16300. parse(serializationObject: any): void;
  16301. }
  16302. }
  16303. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16304. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16305. import { Effect } from "babylonjs/Materials/effect";
  16306. import { Particle } from "babylonjs/Particles/particle";
  16307. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16308. /**
  16309. * Particle emitter emitting particles from the inside of a sphere.
  16310. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16311. */
  16312. export class SphereParticleEmitter implements IParticleEmitterType {
  16313. /**
  16314. * The radius of the emission sphere.
  16315. */
  16316. radius: number;
  16317. /**
  16318. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16319. */
  16320. radiusRange: number;
  16321. /**
  16322. * How much to randomize the particle direction [0-1].
  16323. */
  16324. directionRandomizer: number;
  16325. /**
  16326. * Creates a new instance SphereParticleEmitter
  16327. * @param radius the radius of the emission sphere (1 by default)
  16328. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16329. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16330. */
  16331. constructor(
  16332. /**
  16333. * The radius of the emission sphere.
  16334. */
  16335. radius?: number,
  16336. /**
  16337. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16338. */
  16339. radiusRange?: number,
  16340. /**
  16341. * How much to randomize the particle direction [0-1].
  16342. */
  16343. directionRandomizer?: number);
  16344. /**
  16345. * Called by the particle System when the direction is computed for the created particle.
  16346. * @param worldMatrix is the world matrix of the particle system
  16347. * @param directionToUpdate is the direction vector to update with the result
  16348. * @param particle is the particle we are computed the direction for
  16349. */
  16350. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16351. /**
  16352. * Called by the particle System when the position is computed for the created particle.
  16353. * @param worldMatrix is the world matrix of the particle system
  16354. * @param positionToUpdate is the position vector to update with the result
  16355. * @param particle is the particle we are computed the position for
  16356. */
  16357. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16358. /**
  16359. * Clones the current emitter and returns a copy of it
  16360. * @returns the new emitter
  16361. */
  16362. clone(): SphereParticleEmitter;
  16363. /**
  16364. * Called by the GPUParticleSystem to setup the update shader
  16365. * @param effect defines the update shader
  16366. */
  16367. applyToShader(effect: Effect): void;
  16368. /**
  16369. * Returns a string to use to update the GPU particles update shader
  16370. * @returns a string containng the defines string
  16371. */
  16372. getEffectDefines(): string;
  16373. /**
  16374. * Returns the string "SphereParticleEmitter"
  16375. * @returns a string containing the class name
  16376. */
  16377. getClassName(): string;
  16378. /**
  16379. * Serializes the particle system to a JSON object.
  16380. * @returns the JSON object
  16381. */
  16382. serialize(): any;
  16383. /**
  16384. * Parse properties from a JSON object
  16385. * @param serializationObject defines the JSON object
  16386. */
  16387. parse(serializationObject: any): void;
  16388. }
  16389. /**
  16390. * Particle emitter emitting particles from the inside of a sphere.
  16391. * It emits the particles randomly between two vectors.
  16392. */
  16393. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16394. /**
  16395. * The min limit of the emission direction.
  16396. */
  16397. direction1: Vector3;
  16398. /**
  16399. * The max limit of the emission direction.
  16400. */
  16401. direction2: Vector3;
  16402. /**
  16403. * Creates a new instance SphereDirectedParticleEmitter
  16404. * @param radius the radius of the emission sphere (1 by default)
  16405. * @param direction1 the min limit of the emission direction (up vector by default)
  16406. * @param direction2 the max limit of the emission direction (up vector by default)
  16407. */
  16408. constructor(radius?: number,
  16409. /**
  16410. * The min limit of the emission direction.
  16411. */
  16412. direction1?: Vector3,
  16413. /**
  16414. * The max limit of the emission direction.
  16415. */
  16416. direction2?: Vector3);
  16417. /**
  16418. * Called by the particle System when the direction is computed for the created particle.
  16419. * @param worldMatrix is the world matrix of the particle system
  16420. * @param directionToUpdate is the direction vector to update with the result
  16421. * @param particle is the particle we are computed the direction for
  16422. */
  16423. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16424. /**
  16425. * Clones the current emitter and returns a copy of it
  16426. * @returns the new emitter
  16427. */
  16428. clone(): SphereDirectedParticleEmitter;
  16429. /**
  16430. * Called by the GPUParticleSystem to setup the update shader
  16431. * @param effect defines the update shader
  16432. */
  16433. applyToShader(effect: Effect): void;
  16434. /**
  16435. * Returns a string to use to update the GPU particles update shader
  16436. * @returns a string containng the defines string
  16437. */
  16438. getEffectDefines(): string;
  16439. /**
  16440. * Returns the string "SphereDirectedParticleEmitter"
  16441. * @returns a string containing the class name
  16442. */
  16443. getClassName(): string;
  16444. /**
  16445. * Serializes the particle system to a JSON object.
  16446. * @returns the JSON object
  16447. */
  16448. serialize(): any;
  16449. /**
  16450. * Parse properties from a JSON object
  16451. * @param serializationObject defines the JSON object
  16452. */
  16453. parse(serializationObject: any): void;
  16454. }
  16455. }
  16456. declare module "babylonjs/Particles/EmitterTypes/index" {
  16457. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16458. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16459. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16460. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16461. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16462. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16463. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16464. }
  16465. declare module "babylonjs/Particles/IParticleSystem" {
  16466. import { Nullable } from "babylonjs/types";
  16467. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16469. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16470. import { Texture } from "babylonjs/Materials/Textures/texture";
  16471. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16472. import { Scene } from "babylonjs/scene";
  16473. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16474. import { Animation } from "babylonjs/Animations/animation";
  16475. /**
  16476. * Interface representing a particle system in Babylon.js.
  16477. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16478. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16479. */
  16480. export interface IParticleSystem {
  16481. /**
  16482. * List of animations used by the particle system.
  16483. */
  16484. animations: Animation[];
  16485. /**
  16486. * The id of the Particle system.
  16487. */
  16488. id: string;
  16489. /**
  16490. * The name of the Particle system.
  16491. */
  16492. name: string;
  16493. /**
  16494. * The emitter represents the Mesh or position we are attaching the particle system to.
  16495. */
  16496. emitter: Nullable<AbstractMesh | Vector3>;
  16497. /**
  16498. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16499. */
  16500. isBillboardBased: boolean;
  16501. /**
  16502. * The rendering group used by the Particle system to chose when to render.
  16503. */
  16504. renderingGroupId: number;
  16505. /**
  16506. * The layer mask we are rendering the particles through.
  16507. */
  16508. layerMask: number;
  16509. /**
  16510. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16511. */
  16512. updateSpeed: number;
  16513. /**
  16514. * The amount of time the particle system is running (depends of the overall update speed).
  16515. */
  16516. targetStopDuration: number;
  16517. /**
  16518. * The texture used to render each particle. (this can be a spritesheet)
  16519. */
  16520. particleTexture: Nullable<Texture>;
  16521. /**
  16522. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16523. */
  16524. blendMode: number;
  16525. /**
  16526. * Minimum life time of emitting particles.
  16527. */
  16528. minLifeTime: number;
  16529. /**
  16530. * Maximum life time of emitting particles.
  16531. */
  16532. maxLifeTime: number;
  16533. /**
  16534. * Minimum Size of emitting particles.
  16535. */
  16536. minSize: number;
  16537. /**
  16538. * Maximum Size of emitting particles.
  16539. */
  16540. maxSize: number;
  16541. /**
  16542. * Minimum scale of emitting particles on X axis.
  16543. */
  16544. minScaleX: number;
  16545. /**
  16546. * Maximum scale of emitting particles on X axis.
  16547. */
  16548. maxScaleX: number;
  16549. /**
  16550. * Minimum scale of emitting particles on Y axis.
  16551. */
  16552. minScaleY: number;
  16553. /**
  16554. * Maximum scale of emitting particles on Y axis.
  16555. */
  16556. maxScaleY: number;
  16557. /**
  16558. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16559. */
  16560. color1: Color4;
  16561. /**
  16562. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16563. */
  16564. color2: Color4;
  16565. /**
  16566. * Color the particle will have at the end of its lifetime.
  16567. */
  16568. colorDead: Color4;
  16569. /**
  16570. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16571. */
  16572. emitRate: number;
  16573. /**
  16574. * You can use gravity if you want to give an orientation to your particles.
  16575. */
  16576. gravity: Vector3;
  16577. /**
  16578. * Minimum power of emitting particles.
  16579. */
  16580. minEmitPower: number;
  16581. /**
  16582. * Maximum power of emitting particles.
  16583. */
  16584. maxEmitPower: number;
  16585. /**
  16586. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16587. */
  16588. minAngularSpeed: number;
  16589. /**
  16590. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16591. */
  16592. maxAngularSpeed: number;
  16593. /**
  16594. * Gets or sets the minimal initial rotation in radians.
  16595. */
  16596. minInitialRotation: number;
  16597. /**
  16598. * Gets or sets the maximal initial rotation in radians.
  16599. */
  16600. maxInitialRotation: number;
  16601. /**
  16602. * The particle emitter type defines the emitter used by the particle system.
  16603. * It can be for example box, sphere, or cone...
  16604. */
  16605. particleEmitterType: Nullable<IParticleEmitterType>;
  16606. /**
  16607. * Defines the delay in milliseconds before starting the system (0 by default)
  16608. */
  16609. startDelay: number;
  16610. /**
  16611. * 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
  16612. */
  16613. preWarmCycles: number;
  16614. /**
  16615. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16616. */
  16617. preWarmStepOffset: number;
  16618. /**
  16619. * 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)
  16620. */
  16621. spriteCellChangeSpeed: number;
  16622. /**
  16623. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16624. */
  16625. startSpriteCellID: number;
  16626. /**
  16627. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16628. */
  16629. endSpriteCellID: number;
  16630. /**
  16631. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16632. */
  16633. spriteCellWidth: number;
  16634. /**
  16635. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16636. */
  16637. spriteCellHeight: number;
  16638. /**
  16639. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16640. */
  16641. spriteRandomStartCell: boolean;
  16642. /**
  16643. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16644. */
  16645. isAnimationSheetEnabled: boolean;
  16646. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16647. translationPivot: Vector2;
  16648. /**
  16649. * Gets or sets a texture used to add random noise to particle positions
  16650. */
  16651. noiseTexture: Nullable<BaseTexture>;
  16652. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16653. noiseStrength: Vector3;
  16654. /**
  16655. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16656. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16657. */
  16658. billboardMode: number;
  16659. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16660. limitVelocityDamping: number;
  16661. /**
  16662. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16663. */
  16664. beginAnimationOnStart: boolean;
  16665. /**
  16666. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16667. */
  16668. beginAnimationFrom: number;
  16669. /**
  16670. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16671. */
  16672. beginAnimationTo: number;
  16673. /**
  16674. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16675. */
  16676. beginAnimationLoop: boolean;
  16677. /**
  16678. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16679. */
  16680. disposeOnStop: boolean;
  16681. /**
  16682. * Gets the maximum number of particles active at the same time.
  16683. * @returns The max number of active particles.
  16684. */
  16685. getCapacity(): number;
  16686. /**
  16687. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16688. * @returns True if it has been started, otherwise false.
  16689. */
  16690. isStarted(): boolean;
  16691. /**
  16692. * Animates the particle system for this frame.
  16693. */
  16694. animate(): void;
  16695. /**
  16696. * Renders the particle system in its current state.
  16697. * @returns the current number of particles
  16698. */
  16699. render(): number;
  16700. /**
  16701. * Dispose the particle system and frees its associated resources.
  16702. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16703. */
  16704. dispose(disposeTexture?: boolean): void;
  16705. /**
  16706. * Clones the particle system.
  16707. * @param name The name of the cloned object
  16708. * @param newEmitter The new emitter to use
  16709. * @returns the cloned particle system
  16710. */
  16711. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16712. /**
  16713. * Serializes the particle system to a JSON object.
  16714. * @returns the JSON object
  16715. */
  16716. serialize(): any;
  16717. /**
  16718. * Rebuild the particle system
  16719. */
  16720. rebuild(): void;
  16721. /**
  16722. * Starts the particle system and begins to emit
  16723. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16724. */
  16725. start(delay?: number): void;
  16726. /**
  16727. * Stops the particle system.
  16728. */
  16729. stop(): void;
  16730. /**
  16731. * Remove all active particles
  16732. */
  16733. reset(): void;
  16734. /**
  16735. * Is this system ready to be used/rendered
  16736. * @return true if the system is ready
  16737. */
  16738. isReady(): boolean;
  16739. /**
  16740. * Adds a new color gradient
  16741. * @param gradient defines the gradient to use (between 0 and 1)
  16742. * @param color1 defines the color to affect to the specified gradient
  16743. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16744. * @returns the current particle system
  16745. */
  16746. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16747. /**
  16748. * Remove a specific color gradient
  16749. * @param gradient defines the gradient to remove
  16750. * @returns the current particle system
  16751. */
  16752. removeColorGradient(gradient: number): IParticleSystem;
  16753. /**
  16754. * Adds a new size gradient
  16755. * @param gradient defines the gradient to use (between 0 and 1)
  16756. * @param factor defines the size factor to affect to the specified gradient
  16757. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16758. * @returns the current particle system
  16759. */
  16760. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16761. /**
  16762. * Remove a specific size gradient
  16763. * @param gradient defines the gradient to remove
  16764. * @returns the current particle system
  16765. */
  16766. removeSizeGradient(gradient: number): IParticleSystem;
  16767. /**
  16768. * Gets the current list of color gradients.
  16769. * You must use addColorGradient and removeColorGradient to udpate this list
  16770. * @returns the list of color gradients
  16771. */
  16772. getColorGradients(): Nullable<Array<ColorGradient>>;
  16773. /**
  16774. * Gets the current list of size gradients.
  16775. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16776. * @returns the list of size gradients
  16777. */
  16778. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16779. /**
  16780. * Gets the current list of angular speed gradients.
  16781. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16782. * @returns the list of angular speed gradients
  16783. */
  16784. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16785. /**
  16786. * Adds a new angular speed gradient
  16787. * @param gradient defines the gradient to use (between 0 and 1)
  16788. * @param factor defines the angular speed to affect to the specified gradient
  16789. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16790. * @returns the current particle system
  16791. */
  16792. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16793. /**
  16794. * Remove a specific angular speed gradient
  16795. * @param gradient defines the gradient to remove
  16796. * @returns the current particle system
  16797. */
  16798. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16799. /**
  16800. * Gets the current list of velocity gradients.
  16801. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16802. * @returns the list of velocity gradients
  16803. */
  16804. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16805. /**
  16806. * Adds a new velocity gradient
  16807. * @param gradient defines the gradient to use (between 0 and 1)
  16808. * @param factor defines the velocity to affect to the specified gradient
  16809. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16810. * @returns the current particle system
  16811. */
  16812. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16813. /**
  16814. * Remove a specific velocity gradient
  16815. * @param gradient defines the gradient to remove
  16816. * @returns the current particle system
  16817. */
  16818. removeVelocityGradient(gradient: number): IParticleSystem;
  16819. /**
  16820. * Gets the current list of limit velocity gradients.
  16821. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16822. * @returns the list of limit velocity gradients
  16823. */
  16824. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16825. /**
  16826. * Adds a new limit velocity gradient
  16827. * @param gradient defines the gradient to use (between 0 and 1)
  16828. * @param factor defines the limit velocity to affect to the specified gradient
  16829. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16830. * @returns the current particle system
  16831. */
  16832. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16833. /**
  16834. * Remove a specific limit velocity gradient
  16835. * @param gradient defines the gradient to remove
  16836. * @returns the current particle system
  16837. */
  16838. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16839. /**
  16840. * Adds a new drag gradient
  16841. * @param gradient defines the gradient to use (between 0 and 1)
  16842. * @param factor defines the drag to affect to the specified gradient
  16843. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16844. * @returns the current particle system
  16845. */
  16846. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16847. /**
  16848. * Remove a specific drag gradient
  16849. * @param gradient defines the gradient to remove
  16850. * @returns the current particle system
  16851. */
  16852. removeDragGradient(gradient: number): IParticleSystem;
  16853. /**
  16854. * Gets the current list of drag gradients.
  16855. * You must use addDragGradient and removeDragGradient to udpate this list
  16856. * @returns the list of drag gradients
  16857. */
  16858. getDragGradients(): Nullable<Array<FactorGradient>>;
  16859. /**
  16860. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16861. * @param gradient defines the gradient to use (between 0 and 1)
  16862. * @param factor defines the emit rate to affect to the specified gradient
  16863. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16864. * @returns the current particle system
  16865. */
  16866. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16867. /**
  16868. * Remove a specific emit rate gradient
  16869. * @param gradient defines the gradient to remove
  16870. * @returns the current particle system
  16871. */
  16872. removeEmitRateGradient(gradient: number): IParticleSystem;
  16873. /**
  16874. * Gets the current list of emit rate gradients.
  16875. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16876. * @returns the list of emit rate gradients
  16877. */
  16878. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16879. /**
  16880. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16881. * @param gradient defines the gradient to use (between 0 and 1)
  16882. * @param factor defines the start size to affect to the specified gradient
  16883. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16884. * @returns the current particle system
  16885. */
  16886. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16887. /**
  16888. * Remove a specific start size gradient
  16889. * @param gradient defines the gradient to remove
  16890. * @returns the current particle system
  16891. */
  16892. removeStartSizeGradient(gradient: number): IParticleSystem;
  16893. /**
  16894. * Gets the current list of start size gradients.
  16895. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16896. * @returns the list of start size gradients
  16897. */
  16898. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16899. /**
  16900. * Adds a new life time gradient
  16901. * @param gradient defines the gradient to use (between 0 and 1)
  16902. * @param factor defines the life time factor to affect to the specified gradient
  16903. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16904. * @returns the current particle system
  16905. */
  16906. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16907. /**
  16908. * Remove a specific life time gradient
  16909. * @param gradient defines the gradient to remove
  16910. * @returns the current particle system
  16911. */
  16912. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16913. /**
  16914. * Gets the current list of life time gradients.
  16915. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16916. * @returns the list of life time gradients
  16917. */
  16918. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16919. /**
  16920. * Gets the current list of color gradients.
  16921. * You must use addColorGradient and removeColorGradient to udpate this list
  16922. * @returns the list of color gradients
  16923. */
  16924. getColorGradients(): Nullable<Array<ColorGradient>>;
  16925. /**
  16926. * Adds a new ramp gradient used to remap particle colors
  16927. * @param gradient defines the gradient to use (between 0 and 1)
  16928. * @param color defines the color to affect to the specified gradient
  16929. * @returns the current particle system
  16930. */
  16931. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16932. /**
  16933. * Gets the current list of ramp gradients.
  16934. * You must use addRampGradient and removeRampGradient to udpate this list
  16935. * @returns the list of ramp gradients
  16936. */
  16937. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16938. /** Gets or sets a boolean indicating that ramp gradients must be used
  16939. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16940. */
  16941. useRampGradients: boolean;
  16942. /**
  16943. * Adds a new color remap gradient
  16944. * @param gradient defines the gradient to use (between 0 and 1)
  16945. * @param min defines the color remap minimal range
  16946. * @param max defines the color remap maximal range
  16947. * @returns the current particle system
  16948. */
  16949. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16950. /**
  16951. * Gets the current list of color remap gradients.
  16952. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16953. * @returns the list of color remap gradients
  16954. */
  16955. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16956. /**
  16957. * Adds a new alpha remap gradient
  16958. * @param gradient defines the gradient to use (between 0 and 1)
  16959. * @param min defines the alpha remap minimal range
  16960. * @param max defines the alpha remap maximal range
  16961. * @returns the current particle system
  16962. */
  16963. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16964. /**
  16965. * Gets the current list of alpha remap gradients.
  16966. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16967. * @returns the list of alpha remap gradients
  16968. */
  16969. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16970. /**
  16971. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16972. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16973. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16974. * @returns the emitter
  16975. */
  16976. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16977. /**
  16978. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16979. * @param radius The radius of the hemisphere to emit from
  16980. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16981. * @returns the emitter
  16982. */
  16983. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16984. /**
  16985. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16986. * @param radius The radius of the sphere to emit from
  16987. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16988. * @returns the emitter
  16989. */
  16990. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16991. /**
  16992. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16993. * @param radius The radius of the sphere to emit from
  16994. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16995. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16996. * @returns the emitter
  16997. */
  16998. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16999. /**
  17000. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17001. * @param radius The radius of the emission cylinder
  17002. * @param height The height of the emission cylinder
  17003. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17004. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17005. * @returns the emitter
  17006. */
  17007. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17008. /**
  17009. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17010. * @param radius The radius of the cylinder to emit from
  17011. * @param height The height of the emission cylinder
  17012. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17013. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17014. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17015. * @returns the emitter
  17016. */
  17017. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17018. /**
  17019. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17020. * @param radius The radius of the cone to emit from
  17021. * @param angle The base angle of the cone
  17022. * @returns the emitter
  17023. */
  17024. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17025. /**
  17026. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17027. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17028. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17029. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17030. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17031. * @returns the emitter
  17032. */
  17033. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17034. /**
  17035. * Get hosting scene
  17036. * @returns the scene
  17037. */
  17038. getScene(): Scene;
  17039. }
  17040. }
  17041. declare module "babylonjs/Meshes/instancedMesh" {
  17042. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  17043. import { Vector3, Matrix } from "babylonjs/Maths/math";
  17044. import { Camera } from "babylonjs/Cameras/camera";
  17045. import { Node } from "babylonjs/node";
  17046. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17047. import { Mesh } from "babylonjs/Meshes/mesh";
  17048. import { Material } from "babylonjs/Materials/material";
  17049. import { Skeleton } from "babylonjs/Bones/skeleton";
  17050. /**
  17051. * Creates an instance based on a source mesh.
  17052. */
  17053. export class InstancedMesh extends AbstractMesh {
  17054. private _sourceMesh;
  17055. private _currentLOD;
  17056. /** @hidden */
  17057. _indexInSourceMeshInstanceArray: number;
  17058. constructor(name: string, source: Mesh);
  17059. /**
  17060. * Returns the string "InstancedMesh".
  17061. */
  17062. getClassName(): string;
  17063. /**
  17064. * If the source mesh receives shadows
  17065. */
  17066. readonly receiveShadows: boolean;
  17067. /**
  17068. * The material of the source mesh
  17069. */
  17070. readonly material: Nullable<Material>;
  17071. /**
  17072. * Visibility of the source mesh
  17073. */
  17074. readonly visibility: number;
  17075. /**
  17076. * Skeleton of the source mesh
  17077. */
  17078. readonly skeleton: Nullable<Skeleton>;
  17079. /**
  17080. * Rendering ground id of the source mesh
  17081. */
  17082. renderingGroupId: number;
  17083. /**
  17084. * Returns the total number of vertices (integer).
  17085. */
  17086. getTotalVertices(): number;
  17087. /**
  17088. * Returns a positive integer : the total number of indices in this mesh geometry.
  17089. * @returns the numner of indices or zero if the mesh has no geometry.
  17090. */
  17091. getTotalIndices(): number;
  17092. /**
  17093. * The source mesh of the instance
  17094. */
  17095. readonly sourceMesh: Mesh;
  17096. /**
  17097. * Is this node ready to be used/rendered
  17098. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  17099. * @return {boolean} is it ready
  17100. */
  17101. isReady(completeCheck?: boolean): boolean;
  17102. /**
  17103. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  17104. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  17105. * @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.
  17106. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  17107. */
  17108. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  17109. /**
  17110. * Sets the vertex data of the mesh geometry for the requested `kind`.
  17111. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  17112. * The `data` are either a numeric array either a Float32Array.
  17113. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  17114. * 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).
  17115. * Note that a new underlying VertexBuffer object is created each call.
  17116. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  17117. *
  17118. * Possible `kind` values :
  17119. * - VertexBuffer.PositionKind
  17120. * - VertexBuffer.UVKind
  17121. * - VertexBuffer.UV2Kind
  17122. * - VertexBuffer.UV3Kind
  17123. * - VertexBuffer.UV4Kind
  17124. * - VertexBuffer.UV5Kind
  17125. * - VertexBuffer.UV6Kind
  17126. * - VertexBuffer.ColorKind
  17127. * - VertexBuffer.MatricesIndicesKind
  17128. * - VertexBuffer.MatricesIndicesExtraKind
  17129. * - VertexBuffer.MatricesWeightsKind
  17130. * - VertexBuffer.MatricesWeightsExtraKind
  17131. *
  17132. * Returns the Mesh.
  17133. */
  17134. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  17135. /**
  17136. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  17137. * If the mesh has no geometry, it is simply returned as it is.
  17138. * The `data` are either a numeric array either a Float32Array.
  17139. * No new underlying VertexBuffer object is created.
  17140. * 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.
  17141. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  17142. *
  17143. * Possible `kind` values :
  17144. * - VertexBuffer.PositionKind
  17145. * - VertexBuffer.UVKind
  17146. * - VertexBuffer.UV2Kind
  17147. * - VertexBuffer.UV3Kind
  17148. * - VertexBuffer.UV4Kind
  17149. * - VertexBuffer.UV5Kind
  17150. * - VertexBuffer.UV6Kind
  17151. * - VertexBuffer.ColorKind
  17152. * - VertexBuffer.MatricesIndicesKind
  17153. * - VertexBuffer.MatricesIndicesExtraKind
  17154. * - VertexBuffer.MatricesWeightsKind
  17155. * - VertexBuffer.MatricesWeightsExtraKind
  17156. *
  17157. * Returns the Mesh.
  17158. */
  17159. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  17160. /**
  17161. * Sets the mesh indices.
  17162. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  17163. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  17164. * This method creates a new index buffer each call.
  17165. * Returns the Mesh.
  17166. */
  17167. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  17168. /**
  17169. * Boolean : True if the mesh owns the requested kind of data.
  17170. */
  17171. isVerticesDataPresent(kind: string): boolean;
  17172. /**
  17173. * Returns an array of indices (IndicesArray).
  17174. */
  17175. getIndices(): Nullable<IndicesArray>;
  17176. readonly _positions: Nullable<Vector3[]>;
  17177. /**
  17178. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  17179. * This means the mesh underlying bounding box and sphere are recomputed.
  17180. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  17181. * @returns the current mesh
  17182. */
  17183. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  17184. /** @hidden */
  17185. _preActivate(): InstancedMesh;
  17186. /** @hidden */
  17187. _activate(renderId: number): boolean;
  17188. getWorldMatrix(): Matrix;
  17189. /**
  17190. * Returns the current associated LOD AbstractMesh.
  17191. */
  17192. getLOD(camera: Camera): AbstractMesh;
  17193. /** @hidden */
  17194. _syncSubMeshes(): InstancedMesh;
  17195. /** @hidden */
  17196. _generatePointsArray(): boolean;
  17197. /**
  17198. * Creates a new InstancedMesh from the current mesh.
  17199. * - name (string) : the cloned mesh name
  17200. * - newParent (optional Node) : the optional Node to parent the clone to.
  17201. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17202. *
  17203. * Returns the clone.
  17204. */
  17205. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17206. /**
  17207. * Disposes the InstancedMesh.
  17208. * Returns nothing.
  17209. */
  17210. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17211. }
  17212. }
  17213. declare module "babylonjs/Materials/shaderMaterial" {
  17214. import { Scene } from "babylonjs/scene";
  17215. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17216. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17217. import { Mesh } from "babylonjs/Meshes/mesh";
  17218. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17219. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17220. import { Texture } from "babylonjs/Materials/Textures/texture";
  17221. import { Material } from "babylonjs/Materials/material";
  17222. /**
  17223. * Defines the options associated with the creation of a shader material.
  17224. */
  17225. export interface IShaderMaterialOptions {
  17226. /**
  17227. * Does the material work in alpha blend mode
  17228. */
  17229. needAlphaBlending: boolean;
  17230. /**
  17231. * Does the material work in alpha test mode
  17232. */
  17233. needAlphaTesting: boolean;
  17234. /**
  17235. * The list of attribute names used in the shader
  17236. */
  17237. attributes: string[];
  17238. /**
  17239. * The list of unifrom names used in the shader
  17240. */
  17241. uniforms: string[];
  17242. /**
  17243. * The list of UBO names used in the shader
  17244. */
  17245. uniformBuffers: string[];
  17246. /**
  17247. * The list of sampler names used in the shader
  17248. */
  17249. samplers: string[];
  17250. /**
  17251. * The list of defines used in the shader
  17252. */
  17253. defines: string[];
  17254. }
  17255. /**
  17256. * 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.
  17257. *
  17258. * This returned material effects how the mesh will look based on the code in the shaders.
  17259. *
  17260. * @see http://doc.babylonjs.com/how_to/shader_material
  17261. */
  17262. export class ShaderMaterial extends Material {
  17263. private _shaderPath;
  17264. private _options;
  17265. private _textures;
  17266. private _textureArrays;
  17267. private _floats;
  17268. private _ints;
  17269. private _floatsArrays;
  17270. private _colors3;
  17271. private _colors3Arrays;
  17272. private _colors4;
  17273. private _vectors2;
  17274. private _vectors3;
  17275. private _vectors4;
  17276. private _matrices;
  17277. private _matrices3x3;
  17278. private _matrices2x2;
  17279. private _vectors2Arrays;
  17280. private _vectors3Arrays;
  17281. private _cachedWorldViewMatrix;
  17282. private _renderId;
  17283. /**
  17284. * Instantiate a new shader material.
  17285. * 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.
  17286. * This returned material effects how the mesh will look based on the code in the shaders.
  17287. * @see http://doc.babylonjs.com/how_to/shader_material
  17288. * @param name Define the name of the material in the scene
  17289. * @param scene Define the scene the material belongs to
  17290. * @param shaderPath Defines the route to the shader code in one of three ways:
  17291. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17292. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17293. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17294. * @param options Define the options used to create the shader
  17295. */
  17296. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17297. /**
  17298. * Gets the options used to compile the shader.
  17299. * They can be modified to trigger a new compilation
  17300. */
  17301. readonly options: IShaderMaterialOptions;
  17302. /**
  17303. * Gets the current class name of the material e.g. "ShaderMaterial"
  17304. * Mainly use in serialization.
  17305. * @returns the class name
  17306. */
  17307. getClassName(): string;
  17308. /**
  17309. * Specifies if the material will require alpha blending
  17310. * @returns a boolean specifying if alpha blending is needed
  17311. */
  17312. needAlphaBlending(): boolean;
  17313. /**
  17314. * Specifies if this material should be rendered in alpha test mode
  17315. * @returns a boolean specifying if an alpha test is needed.
  17316. */
  17317. needAlphaTesting(): boolean;
  17318. private _checkUniform;
  17319. /**
  17320. * Set a texture in the shader.
  17321. * @param name Define the name of the uniform samplers as defined in the shader
  17322. * @param texture Define the texture to bind to this sampler
  17323. * @return the material itself allowing "fluent" like uniform updates
  17324. */
  17325. setTexture(name: string, texture: Texture): ShaderMaterial;
  17326. /**
  17327. * Set a texture array in the shader.
  17328. * @param name Define the name of the uniform sampler array as defined in the shader
  17329. * @param textures Define the list of textures to bind to this sampler
  17330. * @return the material itself allowing "fluent" like uniform updates
  17331. */
  17332. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17333. /**
  17334. * Set a float in the shader.
  17335. * @param name Define the name of the uniform as defined in the shader
  17336. * @param value Define the value to give to the uniform
  17337. * @return the material itself allowing "fluent" like uniform updates
  17338. */
  17339. setFloat(name: string, value: number): ShaderMaterial;
  17340. /**
  17341. * Set a int in the shader.
  17342. * @param name Define the name of the uniform as defined in the shader
  17343. * @param value Define the value to give to the uniform
  17344. * @return the material itself allowing "fluent" like uniform updates
  17345. */
  17346. setInt(name: string, value: number): ShaderMaterial;
  17347. /**
  17348. * Set an array of floats in the shader.
  17349. * @param name Define the name of the uniform as defined in the shader
  17350. * @param value Define the value to give to the uniform
  17351. * @return the material itself allowing "fluent" like uniform updates
  17352. */
  17353. setFloats(name: string, value: number[]): ShaderMaterial;
  17354. /**
  17355. * Set a vec3 in the shader from a Color3.
  17356. * @param name Define the name of the uniform as defined in the shader
  17357. * @param value Define the value to give to the uniform
  17358. * @return the material itself allowing "fluent" like uniform updates
  17359. */
  17360. setColor3(name: string, value: Color3): ShaderMaterial;
  17361. /**
  17362. * Set a vec3 array in the shader from a Color3 array.
  17363. * @param name Define the name of the uniform as defined in the shader
  17364. * @param value Define the value to give to the uniform
  17365. * @return the material itself allowing "fluent" like uniform updates
  17366. */
  17367. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17368. /**
  17369. * Set a vec4 in the shader from a Color4.
  17370. * @param name Define the name of the uniform as defined in the shader
  17371. * @param value Define the value to give to the uniform
  17372. * @return the material itself allowing "fluent" like uniform updates
  17373. */
  17374. setColor4(name: string, value: Color4): ShaderMaterial;
  17375. /**
  17376. * Set a vec2 in the shader from a Vector2.
  17377. * @param name Define the name of the uniform as defined in the shader
  17378. * @param value Define the value to give to the uniform
  17379. * @return the material itself allowing "fluent" like uniform updates
  17380. */
  17381. setVector2(name: string, value: Vector2): ShaderMaterial;
  17382. /**
  17383. * Set a vec3 in the shader from a Vector3.
  17384. * @param name Define the name of the uniform as defined in the shader
  17385. * @param value Define the value to give to the uniform
  17386. * @return the material itself allowing "fluent" like uniform updates
  17387. */
  17388. setVector3(name: string, value: Vector3): ShaderMaterial;
  17389. /**
  17390. * Set a vec4 in the shader from a Vector4.
  17391. * @param name Define the name of the uniform as defined in the shader
  17392. * @param value Define the value to give to the uniform
  17393. * @return the material itself allowing "fluent" like uniform updates
  17394. */
  17395. setVector4(name: string, value: Vector4): ShaderMaterial;
  17396. /**
  17397. * Set a mat4 in the shader from a Matrix.
  17398. * @param name Define the name of the uniform as defined in the shader
  17399. * @param value Define the value to give to the uniform
  17400. * @return the material itself allowing "fluent" like uniform updates
  17401. */
  17402. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17403. /**
  17404. * Set a mat3 in the shader from a Float32Array.
  17405. * @param name Define the name of the uniform as defined in the shader
  17406. * @param value Define the value to give to the uniform
  17407. * @return the material itself allowing "fluent" like uniform updates
  17408. */
  17409. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17410. /**
  17411. * Set a mat2 in the shader from a Float32Array.
  17412. * @param name Define the name of the uniform as defined in the shader
  17413. * @param value Define the value to give to the uniform
  17414. * @return the material itself allowing "fluent" like uniform updates
  17415. */
  17416. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17417. /**
  17418. * Set a vec2 array in the shader from a number array.
  17419. * @param name Define the name of the uniform as defined in the shader
  17420. * @param value Define the value to give to the uniform
  17421. * @return the material itself allowing "fluent" like uniform updates
  17422. */
  17423. setArray2(name: string, value: number[]): ShaderMaterial;
  17424. /**
  17425. * Set a vec3 array in the shader from a number array.
  17426. * @param name Define the name of the uniform as defined in the shader
  17427. * @param value Define the value to give to the uniform
  17428. * @return the material itself allowing "fluent" like uniform updates
  17429. */
  17430. setArray3(name: string, value: number[]): ShaderMaterial;
  17431. private _checkCache;
  17432. /**
  17433. * Specifies that the submesh is ready to be used
  17434. * @param mesh defines the mesh to check
  17435. * @param subMesh defines which submesh to check
  17436. * @param useInstances specifies that instances should be used
  17437. * @returns a boolean indicating that the submesh is ready or not
  17438. */
  17439. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17440. /**
  17441. * Checks if the material is ready to render the requested mesh
  17442. * @param mesh Define the mesh to render
  17443. * @param useInstances Define whether or not the material is used with instances
  17444. * @returns true if ready, otherwise false
  17445. */
  17446. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17447. /**
  17448. * Binds the world matrix to the material
  17449. * @param world defines the world transformation matrix
  17450. */
  17451. bindOnlyWorldMatrix(world: Matrix): void;
  17452. /**
  17453. * Binds the material to the mesh
  17454. * @param world defines the world transformation matrix
  17455. * @param mesh defines the mesh to bind the material to
  17456. */
  17457. bind(world: Matrix, mesh?: Mesh): void;
  17458. /**
  17459. * Gets the active textures from the material
  17460. * @returns an array of textures
  17461. */
  17462. getActiveTextures(): BaseTexture[];
  17463. /**
  17464. * Specifies if the material uses a texture
  17465. * @param texture defines the texture to check against the material
  17466. * @returns a boolean specifying if the material uses the texture
  17467. */
  17468. hasTexture(texture: BaseTexture): boolean;
  17469. /**
  17470. * Makes a duplicate of the material, and gives it a new name
  17471. * @param name defines the new name for the duplicated material
  17472. * @returns the cloned material
  17473. */
  17474. clone(name: string): ShaderMaterial;
  17475. /**
  17476. * Disposes the material
  17477. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17478. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17479. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17480. */
  17481. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17482. /**
  17483. * Serializes this material in a JSON representation
  17484. * @returns the serialized material object
  17485. */
  17486. serialize(): any;
  17487. /**
  17488. * Creates a shader material from parsed shader material data
  17489. * @param source defines the JSON represnetation of the material
  17490. * @param scene defines the hosting scene
  17491. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17492. * @returns a new material
  17493. */
  17494. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17495. }
  17496. }
  17497. declare module "babylonjs/Shaders/color.fragment" {
  17498. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17499. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17500. /** @hidden */
  17501. export var colorPixelShader: {
  17502. name: string;
  17503. shader: string;
  17504. };
  17505. }
  17506. declare module "babylonjs/Shaders/color.vertex" {
  17507. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17508. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17509. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17510. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17511. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17512. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17513. /** @hidden */
  17514. export var colorVertexShader: {
  17515. name: string;
  17516. shader: string;
  17517. };
  17518. }
  17519. declare module "babylonjs/Meshes/linesMesh" {
  17520. import { Nullable } from "babylonjs/types";
  17521. import { Scene } from "babylonjs/scene";
  17522. import { Color3 } from "babylonjs/Maths/math";
  17523. import { Node } from "babylonjs/node";
  17524. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17525. import { Mesh } from "babylonjs/Meshes/mesh";
  17526. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17527. import { Effect } from "babylonjs/Materials/effect";
  17528. import { Material } from "babylonjs/Materials/material";
  17529. import "babylonjs/Shaders/color.fragment";
  17530. import "babylonjs/Shaders/color.vertex";
  17531. /**
  17532. * Line mesh
  17533. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17534. */
  17535. export class LinesMesh extends Mesh {
  17536. /**
  17537. * If vertex color should be applied to the mesh
  17538. */
  17539. useVertexColor?: boolean | undefined;
  17540. /**
  17541. * If vertex alpha should be applied to the mesh
  17542. */
  17543. useVertexAlpha?: boolean | undefined;
  17544. /**
  17545. * Color of the line (Default: White)
  17546. */
  17547. color: Color3;
  17548. /**
  17549. * Alpha of the line (Default: 1)
  17550. */
  17551. alpha: number;
  17552. /**
  17553. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17554. * This margin is expressed in world space coordinates, so its value may vary.
  17555. * Default value is 0.1
  17556. */
  17557. intersectionThreshold: number;
  17558. private _colorShader;
  17559. /**
  17560. * Creates a new LinesMesh
  17561. * @param name defines the name
  17562. * @param scene defines the hosting scene
  17563. * @param parent defines the parent mesh if any
  17564. * @param source defines the optional source LinesMesh used to clone data from
  17565. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17566. * When false, achieved by calling a clone(), also passing False.
  17567. * This will make creation of children, recursive.
  17568. * @param useVertexColor defines if this LinesMesh supports vertex color
  17569. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17570. */
  17571. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17572. /**
  17573. * If vertex color should be applied to the mesh
  17574. */
  17575. useVertexColor?: boolean | undefined,
  17576. /**
  17577. * If vertex alpha should be applied to the mesh
  17578. */
  17579. useVertexAlpha?: boolean | undefined);
  17580. private _addClipPlaneDefine;
  17581. private _removeClipPlaneDefine;
  17582. isReady(): boolean;
  17583. /**
  17584. * Returns the string "LineMesh"
  17585. */
  17586. getClassName(): string;
  17587. /**
  17588. * @hidden
  17589. */
  17590. /**
  17591. * @hidden
  17592. */
  17593. material: Material;
  17594. /**
  17595. * @hidden
  17596. */
  17597. readonly checkCollisions: boolean;
  17598. /** @hidden */
  17599. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17600. /** @hidden */
  17601. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17602. /**
  17603. * Disposes of the line mesh
  17604. * @param doNotRecurse If children should be disposed
  17605. */
  17606. dispose(doNotRecurse?: boolean): void;
  17607. /**
  17608. * Returns a new LineMesh object cloned from the current one.
  17609. */
  17610. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17611. /**
  17612. * Creates a new InstancedLinesMesh object from the mesh model.
  17613. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17614. * @param name defines the name of the new instance
  17615. * @returns a new InstancedLinesMesh
  17616. */
  17617. createInstance(name: string): InstancedLinesMesh;
  17618. }
  17619. /**
  17620. * Creates an instance based on a source LinesMesh
  17621. */
  17622. export class InstancedLinesMesh extends InstancedMesh {
  17623. /**
  17624. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17625. * This margin is expressed in world space coordinates, so its value may vary.
  17626. * Initilized with the intersectionThreshold value of the source LinesMesh
  17627. */
  17628. intersectionThreshold: number;
  17629. constructor(name: string, source: LinesMesh);
  17630. /**
  17631. * Returns the string "InstancedLinesMesh".
  17632. */
  17633. getClassName(): string;
  17634. }
  17635. }
  17636. declare module "babylonjs/Shaders/line.fragment" {
  17637. /** @hidden */
  17638. export var linePixelShader: {
  17639. name: string;
  17640. shader: string;
  17641. };
  17642. }
  17643. declare module "babylonjs/Shaders/line.vertex" {
  17644. /** @hidden */
  17645. export var lineVertexShader: {
  17646. name: string;
  17647. shader: string;
  17648. };
  17649. }
  17650. declare module "babylonjs/Rendering/edgesRenderer" {
  17651. import { Nullable } from "babylonjs/types";
  17652. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17654. import { Vector3 } from "babylonjs/Maths/math";
  17655. import { IDisposable } from "babylonjs/scene";
  17656. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17657. import "babylonjs/Shaders/line.fragment";
  17658. import "babylonjs/Shaders/line.vertex";
  17659. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17660. module "babylonjs/Meshes/abstractMesh" {
  17661. interface AbstractMesh {
  17662. /**
  17663. * Disables the mesh edge rendering mode
  17664. * @returns the currentAbstractMesh
  17665. */
  17666. disableEdgesRendering(): AbstractMesh;
  17667. /**
  17668. * Enables the edge rendering mode on the mesh.
  17669. * This mode makes the mesh edges visible
  17670. * @param epsilon defines the maximal distance between two angles to detect a face
  17671. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17672. * @returns the currentAbstractMesh
  17673. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17674. */
  17675. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17676. /**
  17677. * Gets the edgesRenderer associated with the mesh
  17678. */
  17679. edgesRenderer: Nullable<EdgesRenderer>;
  17680. }
  17681. }
  17682. module "babylonjs/Meshes/linesMesh" {
  17683. interface LinesMesh {
  17684. /**
  17685. * Enables the edge rendering mode on the mesh.
  17686. * This mode makes the mesh edges visible
  17687. * @param epsilon defines the maximal distance between two angles to detect a face
  17688. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17689. * @returns the currentAbstractMesh
  17690. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17691. */
  17692. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17693. }
  17694. }
  17695. module "babylonjs/Meshes/linesMesh" {
  17696. interface InstancedLinesMesh {
  17697. /**
  17698. * Enables the edge rendering mode on the mesh.
  17699. * This mode makes the mesh edges visible
  17700. * @param epsilon defines the maximal distance between two angles to detect a face
  17701. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17702. * @returns the current InstancedLinesMesh
  17703. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17704. */
  17705. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17706. }
  17707. }
  17708. /**
  17709. * Defines the minimum contract an Edges renderer should follow.
  17710. */
  17711. export interface IEdgesRenderer extends IDisposable {
  17712. /**
  17713. * Gets or sets a boolean indicating if the edgesRenderer is active
  17714. */
  17715. isEnabled: boolean;
  17716. /**
  17717. * Renders the edges of the attached mesh,
  17718. */
  17719. render(): void;
  17720. /**
  17721. * Checks wether or not the edges renderer is ready to render.
  17722. * @return true if ready, otherwise false.
  17723. */
  17724. isReady(): boolean;
  17725. }
  17726. /**
  17727. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17728. */
  17729. export class EdgesRenderer implements IEdgesRenderer {
  17730. /**
  17731. * Define the size of the edges with an orthographic camera
  17732. */
  17733. edgesWidthScalerForOrthographic: number;
  17734. /**
  17735. * Define the size of the edges with a perspective camera
  17736. */
  17737. edgesWidthScalerForPerspective: number;
  17738. protected _source: AbstractMesh;
  17739. protected _linesPositions: number[];
  17740. protected _linesNormals: number[];
  17741. protected _linesIndices: number[];
  17742. protected _epsilon: number;
  17743. protected _indicesCount: number;
  17744. protected _lineShader: ShaderMaterial;
  17745. protected _ib: DataBuffer;
  17746. protected _buffers: {
  17747. [key: string]: Nullable<VertexBuffer>;
  17748. };
  17749. protected _checkVerticesInsteadOfIndices: boolean;
  17750. private _meshRebuildObserver;
  17751. private _meshDisposeObserver;
  17752. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17753. isEnabled: boolean;
  17754. /**
  17755. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17756. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17757. * @param source Mesh used to create edges
  17758. * @param epsilon sum of angles in adjacency to check for edge
  17759. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17760. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17761. */
  17762. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17763. protected _prepareRessources(): void;
  17764. /** @hidden */
  17765. _rebuild(): void;
  17766. /**
  17767. * Releases the required resources for the edges renderer
  17768. */
  17769. dispose(): void;
  17770. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17771. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17772. /**
  17773. * Checks if the pair of p0 and p1 is en edge
  17774. * @param faceIndex
  17775. * @param edge
  17776. * @param faceNormals
  17777. * @param p0
  17778. * @param p1
  17779. * @private
  17780. */
  17781. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17782. /**
  17783. * push line into the position, normal and index buffer
  17784. * @protected
  17785. */
  17786. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17787. /**
  17788. * Generates lines edges from adjacencjes
  17789. * @private
  17790. */
  17791. _generateEdgesLines(): void;
  17792. /**
  17793. * Checks wether or not the edges renderer is ready to render.
  17794. * @return true if ready, otherwise false.
  17795. */
  17796. isReady(): boolean;
  17797. /**
  17798. * Renders the edges of the attached mesh,
  17799. */
  17800. render(): void;
  17801. }
  17802. /**
  17803. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17804. */
  17805. export class LineEdgesRenderer extends EdgesRenderer {
  17806. /**
  17807. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17808. * @param source LineMesh used to generate edges
  17809. * @param epsilon not important (specified angle for edge detection)
  17810. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17811. */
  17812. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17813. /**
  17814. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17815. */
  17816. _generateEdgesLines(): void;
  17817. }
  17818. }
  17819. declare module "babylonjs/Rendering/renderingGroup" {
  17820. import { SmartArray } from "babylonjs/Misc/smartArray";
  17821. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17822. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17823. import { Nullable } from "babylonjs/types";
  17824. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17825. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17826. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17827. import { Material } from "babylonjs/Materials/material";
  17828. import { Scene } from "babylonjs/scene";
  17829. /**
  17830. * This represents the object necessary to create a rendering group.
  17831. * This is exclusively used and created by the rendering manager.
  17832. * To modify the behavior, you use the available helpers in your scene or meshes.
  17833. * @hidden
  17834. */
  17835. export class RenderingGroup {
  17836. index: number;
  17837. private _scene;
  17838. private _opaqueSubMeshes;
  17839. private _transparentSubMeshes;
  17840. private _alphaTestSubMeshes;
  17841. private _depthOnlySubMeshes;
  17842. private _particleSystems;
  17843. private _spriteManagers;
  17844. private _opaqueSortCompareFn;
  17845. private _alphaTestSortCompareFn;
  17846. private _transparentSortCompareFn;
  17847. private _renderOpaque;
  17848. private _renderAlphaTest;
  17849. private _renderTransparent;
  17850. /** @hidden */
  17851. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17852. onBeforeTransparentRendering: () => void;
  17853. /**
  17854. * Set the opaque sort comparison function.
  17855. * If null the sub meshes will be render in the order they were created
  17856. */
  17857. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17858. /**
  17859. * Set the alpha test sort comparison function.
  17860. * If null the sub meshes will be render in the order they were created
  17861. */
  17862. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17863. /**
  17864. * Set the transparent sort comparison function.
  17865. * If null the sub meshes will be render in the order they were created
  17866. */
  17867. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17868. /**
  17869. * Creates a new rendering group.
  17870. * @param index The rendering group index
  17871. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17872. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17873. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17874. */
  17875. 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>);
  17876. /**
  17877. * Render all the sub meshes contained in the group.
  17878. * @param customRenderFunction Used to override the default render behaviour of the group.
  17879. * @returns true if rendered some submeshes.
  17880. */
  17881. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17882. /**
  17883. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17884. * @param subMeshes The submeshes to render
  17885. */
  17886. private renderOpaqueSorted;
  17887. /**
  17888. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17889. * @param subMeshes The submeshes to render
  17890. */
  17891. private renderAlphaTestSorted;
  17892. /**
  17893. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17894. * @param subMeshes The submeshes to render
  17895. */
  17896. private renderTransparentSorted;
  17897. /**
  17898. * Renders the submeshes in a specified order.
  17899. * @param subMeshes The submeshes to sort before render
  17900. * @param sortCompareFn The comparison function use to sort
  17901. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17902. * @param transparent Specifies to activate blending if true
  17903. */
  17904. private static renderSorted;
  17905. /**
  17906. * Renders the submeshes in the order they were dispatched (no sort applied).
  17907. * @param subMeshes The submeshes to render
  17908. */
  17909. private static renderUnsorted;
  17910. /**
  17911. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17912. * are rendered back to front if in the same alpha index.
  17913. *
  17914. * @param a The first submesh
  17915. * @param b The second submesh
  17916. * @returns The result of the comparison
  17917. */
  17918. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17919. /**
  17920. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17921. * are rendered back to front.
  17922. *
  17923. * @param a The first submesh
  17924. * @param b The second submesh
  17925. * @returns The result of the comparison
  17926. */
  17927. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17928. /**
  17929. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17930. * are rendered front to back (prevent overdraw).
  17931. *
  17932. * @param a The first submesh
  17933. * @param b The second submesh
  17934. * @returns The result of the comparison
  17935. */
  17936. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17937. /**
  17938. * Resets the different lists of submeshes to prepare a new frame.
  17939. */
  17940. prepare(): void;
  17941. dispose(): void;
  17942. /**
  17943. * Inserts the submesh in its correct queue depending on its material.
  17944. * @param subMesh The submesh to dispatch
  17945. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17946. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17947. */
  17948. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17949. dispatchSprites(spriteManager: ISpriteManager): void;
  17950. dispatchParticles(particleSystem: IParticleSystem): void;
  17951. private _renderParticles;
  17952. private _renderSprites;
  17953. }
  17954. }
  17955. declare module "babylonjs/Rendering/renderingManager" {
  17956. import { Nullable } from "babylonjs/types";
  17957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17958. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17959. import { SmartArray } from "babylonjs/Misc/smartArray";
  17960. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17961. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17962. import { Material } from "babylonjs/Materials/material";
  17963. import { Scene } from "babylonjs/scene";
  17964. import { Camera } from "babylonjs/Cameras/camera";
  17965. /**
  17966. * Interface describing the different options available in the rendering manager
  17967. * regarding Auto Clear between groups.
  17968. */
  17969. export interface IRenderingManagerAutoClearSetup {
  17970. /**
  17971. * Defines whether or not autoclear is enable.
  17972. */
  17973. autoClear: boolean;
  17974. /**
  17975. * Defines whether or not to autoclear the depth buffer.
  17976. */
  17977. depth: boolean;
  17978. /**
  17979. * Defines whether or not to autoclear the stencil buffer.
  17980. */
  17981. stencil: boolean;
  17982. }
  17983. /**
  17984. * This class is used by the onRenderingGroupObservable
  17985. */
  17986. export class RenderingGroupInfo {
  17987. /**
  17988. * The Scene that being rendered
  17989. */
  17990. scene: Scene;
  17991. /**
  17992. * The camera currently used for the rendering pass
  17993. */
  17994. camera: Nullable<Camera>;
  17995. /**
  17996. * The ID of the renderingGroup being processed
  17997. */
  17998. renderingGroupId: number;
  17999. }
  18000. /**
  18001. * This is the manager responsible of all the rendering for meshes sprites and particles.
  18002. * It is enable to manage the different groups as well as the different necessary sort functions.
  18003. * This should not be used directly aside of the few static configurations
  18004. */
  18005. export class RenderingManager {
  18006. /**
  18007. * The max id used for rendering groups (not included)
  18008. */
  18009. static MAX_RENDERINGGROUPS: number;
  18010. /**
  18011. * The min id used for rendering groups (included)
  18012. */
  18013. static MIN_RENDERINGGROUPS: number;
  18014. /**
  18015. * Used to globally prevent autoclearing scenes.
  18016. */
  18017. static AUTOCLEAR: boolean;
  18018. /**
  18019. * @hidden
  18020. */
  18021. _useSceneAutoClearSetup: boolean;
  18022. private _scene;
  18023. private _renderingGroups;
  18024. private _depthStencilBufferAlreadyCleaned;
  18025. private _autoClearDepthStencil;
  18026. private _customOpaqueSortCompareFn;
  18027. private _customAlphaTestSortCompareFn;
  18028. private _customTransparentSortCompareFn;
  18029. private _renderingGroupInfo;
  18030. /**
  18031. * Instantiates a new rendering group for a particular scene
  18032. * @param scene Defines the scene the groups belongs to
  18033. */
  18034. constructor(scene: Scene);
  18035. private _clearDepthStencilBuffer;
  18036. /**
  18037. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  18038. * @hidden
  18039. */
  18040. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  18041. /**
  18042. * Resets the different information of the group to prepare a new frame
  18043. * @hidden
  18044. */
  18045. reset(): void;
  18046. /**
  18047. * Dispose and release the group and its associated resources.
  18048. * @hidden
  18049. */
  18050. dispose(): void;
  18051. /**
  18052. * Clear the info related to rendering groups preventing retention points during dispose.
  18053. */
  18054. freeRenderingGroups(): void;
  18055. private _prepareRenderingGroup;
  18056. /**
  18057. * Add a sprite manager to the rendering manager in order to render it this frame.
  18058. * @param spriteManager Define the sprite manager to render
  18059. */
  18060. dispatchSprites(spriteManager: ISpriteManager): void;
  18061. /**
  18062. * Add a particle system to the rendering manager in order to render it this frame.
  18063. * @param particleSystem Define the particle system to render
  18064. */
  18065. dispatchParticles(particleSystem: IParticleSystem): void;
  18066. /**
  18067. * Add a submesh to the manager in order to render it this frame
  18068. * @param subMesh The submesh to dispatch
  18069. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18070. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18071. */
  18072. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18073. /**
  18074. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18075. * This allowed control for front to back rendering or reversly depending of the special needs.
  18076. *
  18077. * @param renderingGroupId The rendering group id corresponding to its index
  18078. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18079. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18080. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18081. */
  18082. 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;
  18083. /**
  18084. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18085. *
  18086. * @param renderingGroupId The rendering group id corresponding to its index
  18087. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18088. * @param depth Automatically clears depth between groups if true and autoClear is true.
  18089. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  18090. */
  18091. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  18092. /**
  18093. * Gets the current auto clear configuration for one rendering group of the rendering
  18094. * manager.
  18095. * @param index the rendering group index to get the information for
  18096. * @returns The auto clear setup for the requested rendering group
  18097. */
  18098. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18099. }
  18100. }
  18101. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  18102. import { Observable } from "babylonjs/Misc/observable";
  18103. import { SmartArray } from "babylonjs/Misc/smartArray";
  18104. import { Nullable } from "babylonjs/types";
  18105. import { Camera } from "babylonjs/Cameras/camera";
  18106. import { Scene } from "babylonjs/scene";
  18107. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  18108. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  18109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18110. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18111. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18112. import { Texture } from "babylonjs/Materials/Textures/texture";
  18113. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18114. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  18115. import "babylonjs/Engines/Extensions/engine.renderTarget";
  18116. import { Engine } from "babylonjs/Engines/engine";
  18117. /**
  18118. * This Helps creating a texture that will be created from a camera in your scene.
  18119. * It is basically a dynamic texture that could be used to create special effects for instance.
  18120. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  18121. */
  18122. export class RenderTargetTexture extends Texture {
  18123. isCube: boolean;
  18124. /**
  18125. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  18126. */
  18127. static readonly REFRESHRATE_RENDER_ONCE: number;
  18128. /**
  18129. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  18130. */
  18131. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  18132. /**
  18133. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  18134. * the central point of your effect and can save a lot of performances.
  18135. */
  18136. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  18137. /**
  18138. * Use this predicate to dynamically define the list of mesh you want to render.
  18139. * If set, the renderList property will be overwritten.
  18140. */
  18141. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  18142. private _renderList;
  18143. /**
  18144. * Use this list to define the list of mesh you want to render.
  18145. */
  18146. renderList: Nullable<Array<AbstractMesh>>;
  18147. private _hookArray;
  18148. /**
  18149. * Define if particles should be rendered in your texture.
  18150. */
  18151. renderParticles: boolean;
  18152. /**
  18153. * Define if sprites should be rendered in your texture.
  18154. */
  18155. renderSprites: boolean;
  18156. /**
  18157. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  18158. */
  18159. coordinatesMode: number;
  18160. /**
  18161. * Define the camera used to render the texture.
  18162. */
  18163. activeCamera: Nullable<Camera>;
  18164. /**
  18165. * Override the render function of the texture with your own one.
  18166. */
  18167. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  18168. /**
  18169. * Define if camera post processes should be use while rendering the texture.
  18170. */
  18171. useCameraPostProcesses: boolean;
  18172. /**
  18173. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  18174. */
  18175. ignoreCameraViewport: boolean;
  18176. private _postProcessManager;
  18177. private _postProcesses;
  18178. private _resizeObserver;
  18179. /**
  18180. * An event triggered when the texture is unbind.
  18181. */
  18182. onBeforeBindObservable: Observable<RenderTargetTexture>;
  18183. /**
  18184. * An event triggered when the texture is unbind.
  18185. */
  18186. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  18187. private _onAfterUnbindObserver;
  18188. /**
  18189. * Set a after unbind callback in the texture.
  18190. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  18191. */
  18192. onAfterUnbind: () => void;
  18193. /**
  18194. * An event triggered before rendering the texture
  18195. */
  18196. onBeforeRenderObservable: Observable<number>;
  18197. private _onBeforeRenderObserver;
  18198. /**
  18199. * Set a before render callback in the texture.
  18200. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18201. */
  18202. onBeforeRender: (faceIndex: number) => void;
  18203. /**
  18204. * An event triggered after rendering the texture
  18205. */
  18206. onAfterRenderObservable: Observable<number>;
  18207. private _onAfterRenderObserver;
  18208. /**
  18209. * Set a after render callback in the texture.
  18210. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18211. */
  18212. onAfterRender: (faceIndex: number) => void;
  18213. /**
  18214. * An event triggered after the texture clear
  18215. */
  18216. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18217. private _onClearObserver;
  18218. /**
  18219. * Set a clear callback in the texture.
  18220. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18221. */
  18222. onClear: (Engine: Engine) => void;
  18223. /**
  18224. * Define the clear color of the Render Target if it should be different from the scene.
  18225. */
  18226. clearColor: Color4;
  18227. protected _size: number | {
  18228. width: number;
  18229. height: number;
  18230. };
  18231. protected _initialSizeParameter: number | {
  18232. width: number;
  18233. height: number;
  18234. } | {
  18235. ratio: number;
  18236. };
  18237. protected _sizeRatio: Nullable<number>;
  18238. /** @hidden */
  18239. _generateMipMaps: boolean;
  18240. protected _renderingManager: RenderingManager;
  18241. /** @hidden */
  18242. _waitingRenderList: string[];
  18243. protected _doNotChangeAspectRatio: boolean;
  18244. protected _currentRefreshId: number;
  18245. protected _refreshRate: number;
  18246. protected _textureMatrix: Matrix;
  18247. protected _samples: number;
  18248. protected _renderTargetOptions: RenderTargetCreationOptions;
  18249. /**
  18250. * Gets render target creation options that were used.
  18251. */
  18252. readonly renderTargetOptions: RenderTargetCreationOptions;
  18253. protected _engine: Engine;
  18254. protected _onRatioRescale(): void;
  18255. /**
  18256. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18257. * It must define where the camera used to render the texture is set
  18258. */
  18259. boundingBoxPosition: Vector3;
  18260. private _boundingBoxSize;
  18261. /**
  18262. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18263. * When defined, the cubemap will switch to local mode
  18264. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18265. * @example https://www.babylonjs-playground.com/#RNASML
  18266. */
  18267. boundingBoxSize: Vector3;
  18268. /**
  18269. * In case the RTT has been created with a depth texture, get the associated
  18270. * depth texture.
  18271. * Otherwise, return null.
  18272. */
  18273. depthStencilTexture: Nullable<InternalTexture>;
  18274. /**
  18275. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18276. * or used a shadow, depth texture...
  18277. * @param name The friendly name of the texture
  18278. * @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)
  18279. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18280. * @param generateMipMaps True if mip maps need to be generated after render.
  18281. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18282. * @param type The type of the buffer in the RTT (int, half float, float...)
  18283. * @param isCube True if a cube texture needs to be created
  18284. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18285. * @param generateDepthBuffer True to generate a depth buffer
  18286. * @param generateStencilBuffer True to generate a stencil buffer
  18287. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18288. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18289. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18290. */
  18291. constructor(name: string, size: number | {
  18292. width: number;
  18293. height: number;
  18294. } | {
  18295. ratio: number;
  18296. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18297. /**
  18298. * Creates a depth stencil texture.
  18299. * This is only available in WebGL 2 or with the depth texture extension available.
  18300. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18301. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18302. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18303. */
  18304. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18305. private _processSizeParameter;
  18306. /**
  18307. * Define the number of samples to use in case of MSAA.
  18308. * It defaults to one meaning no MSAA has been enabled.
  18309. */
  18310. samples: number;
  18311. /**
  18312. * Resets the refresh counter of the texture and start bak from scratch.
  18313. * Could be useful to regenerate the texture if it is setup to render only once.
  18314. */
  18315. resetRefreshCounter(): void;
  18316. /**
  18317. * Define the refresh rate of the texture or the rendering frequency.
  18318. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18319. */
  18320. refreshRate: number;
  18321. /**
  18322. * Adds a post process to the render target rendering passes.
  18323. * @param postProcess define the post process to add
  18324. */
  18325. addPostProcess(postProcess: PostProcess): void;
  18326. /**
  18327. * Clear all the post processes attached to the render target
  18328. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18329. */
  18330. clearPostProcesses(dispose?: boolean): void;
  18331. /**
  18332. * Remove one of the post process from the list of attached post processes to the texture
  18333. * @param postProcess define the post process to remove from the list
  18334. */
  18335. removePostProcess(postProcess: PostProcess): void;
  18336. /** @hidden */
  18337. _shouldRender(): boolean;
  18338. /**
  18339. * Gets the actual render size of the texture.
  18340. * @returns the width of the render size
  18341. */
  18342. getRenderSize(): number;
  18343. /**
  18344. * Gets the actual render width of the texture.
  18345. * @returns the width of the render size
  18346. */
  18347. getRenderWidth(): number;
  18348. /**
  18349. * Gets the actual render height of the texture.
  18350. * @returns the height of the render size
  18351. */
  18352. getRenderHeight(): number;
  18353. /**
  18354. * Get if the texture can be rescaled or not.
  18355. */
  18356. readonly canRescale: boolean;
  18357. /**
  18358. * Resize the texture using a ratio.
  18359. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18360. */
  18361. scale(ratio: number): void;
  18362. /**
  18363. * Get the texture reflection matrix used to rotate/transform the reflection.
  18364. * @returns the reflection matrix
  18365. */
  18366. getReflectionTextureMatrix(): Matrix;
  18367. /**
  18368. * Resize the texture to a new desired size.
  18369. * Be carrefull as it will recreate all the data in the new texture.
  18370. * @param size Define the new size. It can be:
  18371. * - a number for squared texture,
  18372. * - an object containing { width: number, height: number }
  18373. * - or an object containing a ratio { ratio: number }
  18374. */
  18375. resize(size: number | {
  18376. width: number;
  18377. height: number;
  18378. } | {
  18379. ratio: number;
  18380. }): void;
  18381. /**
  18382. * Renders all the objects from the render list into the texture.
  18383. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18384. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18385. */
  18386. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18387. private _bestReflectionRenderTargetDimension;
  18388. /**
  18389. * @hidden
  18390. * @param faceIndex face index to bind to if this is a cubetexture
  18391. */
  18392. _bindFrameBuffer(faceIndex?: number): void;
  18393. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18394. private renderToTarget;
  18395. /**
  18396. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18397. * This allowed control for front to back rendering or reversly depending of the special needs.
  18398. *
  18399. * @param renderingGroupId The rendering group id corresponding to its index
  18400. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18401. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18402. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18403. */
  18404. 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;
  18405. /**
  18406. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18407. *
  18408. * @param renderingGroupId The rendering group id corresponding to its index
  18409. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18410. */
  18411. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18412. /**
  18413. * Clones the texture.
  18414. * @returns the cloned texture
  18415. */
  18416. clone(): RenderTargetTexture;
  18417. /**
  18418. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18419. * @returns The JSON representation of the texture
  18420. */
  18421. serialize(): any;
  18422. /**
  18423. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18424. */
  18425. disposeFramebufferObjects(): void;
  18426. /**
  18427. * Dispose the texture and release its associated resources.
  18428. */
  18429. dispose(): void;
  18430. /** @hidden */
  18431. _rebuild(): void;
  18432. /**
  18433. * Clear the info related to rendering groups preventing retention point in material dispose.
  18434. */
  18435. freeRenderingGroups(): void;
  18436. /**
  18437. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18438. * @returns the view count
  18439. */
  18440. getViewCount(): number;
  18441. }
  18442. }
  18443. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18444. import { Scene } from "babylonjs/scene";
  18445. import { Plane } from "babylonjs/Maths/math";
  18446. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18447. /**
  18448. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18449. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18450. * You can then easily use it as a reflectionTexture on a flat surface.
  18451. * In case the surface is not a plane, please consider relying on reflection probes.
  18452. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18453. */
  18454. export class MirrorTexture extends RenderTargetTexture {
  18455. private scene;
  18456. /**
  18457. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18458. * 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.
  18459. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18460. */
  18461. mirrorPlane: Plane;
  18462. /**
  18463. * Define the blur ratio used to blur the reflection if needed.
  18464. */
  18465. blurRatio: number;
  18466. /**
  18467. * Define the adaptive blur kernel used to blur the reflection if needed.
  18468. * This will autocompute the closest best match for the `blurKernel`
  18469. */
  18470. adaptiveBlurKernel: number;
  18471. /**
  18472. * Define the blur kernel used to blur the reflection if needed.
  18473. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18474. */
  18475. blurKernel: number;
  18476. /**
  18477. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18478. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18479. */
  18480. blurKernelX: number;
  18481. /**
  18482. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18483. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18484. */
  18485. blurKernelY: number;
  18486. private _autoComputeBlurKernel;
  18487. protected _onRatioRescale(): void;
  18488. private _updateGammaSpace;
  18489. private _imageProcessingConfigChangeObserver;
  18490. private _transformMatrix;
  18491. private _mirrorMatrix;
  18492. private _savedViewMatrix;
  18493. private _blurX;
  18494. private _blurY;
  18495. private _adaptiveBlurKernel;
  18496. private _blurKernelX;
  18497. private _blurKernelY;
  18498. private _blurRatio;
  18499. /**
  18500. * Instantiates a Mirror Texture.
  18501. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18502. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18503. * You can then easily use it as a reflectionTexture on a flat surface.
  18504. * In case the surface is not a plane, please consider relying on reflection probes.
  18505. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18506. * @param name
  18507. * @param size
  18508. * @param scene
  18509. * @param generateMipMaps
  18510. * @param type
  18511. * @param samplingMode
  18512. * @param generateDepthBuffer
  18513. */
  18514. constructor(name: string, size: number | {
  18515. width: number;
  18516. height: number;
  18517. } | {
  18518. ratio: number;
  18519. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18520. private _preparePostProcesses;
  18521. /**
  18522. * Clone the mirror texture.
  18523. * @returns the cloned texture
  18524. */
  18525. clone(): MirrorTexture;
  18526. /**
  18527. * Serialize the texture to a JSON representation you could use in Parse later on
  18528. * @returns the serialized JSON representation
  18529. */
  18530. serialize(): any;
  18531. /**
  18532. * Dispose the texture and release its associated resources.
  18533. */
  18534. dispose(): void;
  18535. }
  18536. }
  18537. declare module "babylonjs/Materials/Textures/texture" {
  18538. import { Observable } from "babylonjs/Misc/observable";
  18539. import { Nullable } from "babylonjs/types";
  18540. import { Scene } from "babylonjs/scene";
  18541. import { Matrix } from "babylonjs/Maths/math";
  18542. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18543. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18544. /**
  18545. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18546. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18547. */
  18548. export class Texture extends BaseTexture {
  18549. /** @hidden */
  18550. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18551. /** @hidden */
  18552. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18553. /** @hidden */
  18554. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18555. /** nearest is mag = nearest and min = nearest and mip = linear */
  18556. static readonly NEAREST_SAMPLINGMODE: number;
  18557. /** nearest is mag = nearest and min = nearest and mip = linear */
  18558. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18559. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18560. static readonly BILINEAR_SAMPLINGMODE: number;
  18561. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18562. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18563. /** Trilinear is mag = linear and min = linear and mip = linear */
  18564. static readonly TRILINEAR_SAMPLINGMODE: number;
  18565. /** Trilinear is mag = linear and min = linear and mip = linear */
  18566. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18567. /** mag = nearest and min = nearest and mip = nearest */
  18568. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18569. /** mag = nearest and min = linear and mip = nearest */
  18570. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18571. /** mag = nearest and min = linear and mip = linear */
  18572. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18573. /** mag = nearest and min = linear and mip = none */
  18574. static readonly NEAREST_LINEAR: number;
  18575. /** mag = nearest and min = nearest and mip = none */
  18576. static readonly NEAREST_NEAREST: number;
  18577. /** mag = linear and min = nearest and mip = nearest */
  18578. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18579. /** mag = linear and min = nearest and mip = linear */
  18580. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18581. /** mag = linear and min = linear and mip = none */
  18582. static readonly LINEAR_LINEAR: number;
  18583. /** mag = linear and min = nearest and mip = none */
  18584. static readonly LINEAR_NEAREST: number;
  18585. /** Explicit coordinates mode */
  18586. static readonly EXPLICIT_MODE: number;
  18587. /** Spherical coordinates mode */
  18588. static readonly SPHERICAL_MODE: number;
  18589. /** Planar coordinates mode */
  18590. static readonly PLANAR_MODE: number;
  18591. /** Cubic coordinates mode */
  18592. static readonly CUBIC_MODE: number;
  18593. /** Projection coordinates mode */
  18594. static readonly PROJECTION_MODE: number;
  18595. /** Inverse Cubic coordinates mode */
  18596. static readonly SKYBOX_MODE: number;
  18597. /** Inverse Cubic coordinates mode */
  18598. static readonly INVCUBIC_MODE: number;
  18599. /** Equirectangular coordinates mode */
  18600. static readonly EQUIRECTANGULAR_MODE: number;
  18601. /** Equirectangular Fixed coordinates mode */
  18602. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18603. /** Equirectangular Fixed Mirrored coordinates mode */
  18604. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18605. /** Texture is not repeating outside of 0..1 UVs */
  18606. static readonly CLAMP_ADDRESSMODE: number;
  18607. /** Texture is repeating outside of 0..1 UVs */
  18608. static readonly WRAP_ADDRESSMODE: number;
  18609. /** Texture is repeating and mirrored */
  18610. static readonly MIRROR_ADDRESSMODE: number;
  18611. /**
  18612. * 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
  18613. */
  18614. static UseSerializedUrlIfAny: boolean;
  18615. /**
  18616. * Define the url of the texture.
  18617. */
  18618. url: Nullable<string>;
  18619. /**
  18620. * Define an offset on the texture to offset the u coordinates of the UVs
  18621. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18622. */
  18623. uOffset: number;
  18624. /**
  18625. * Define an offset on the texture to offset the v coordinates of the UVs
  18626. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18627. */
  18628. vOffset: number;
  18629. /**
  18630. * Define an offset on the texture to scale the u coordinates of the UVs
  18631. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18632. */
  18633. uScale: number;
  18634. /**
  18635. * Define an offset on the texture to scale the v coordinates of the UVs
  18636. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18637. */
  18638. vScale: number;
  18639. /**
  18640. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18641. * @see http://doc.babylonjs.com/how_to/more_materials
  18642. */
  18643. uAng: number;
  18644. /**
  18645. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18646. * @see http://doc.babylonjs.com/how_to/more_materials
  18647. */
  18648. vAng: number;
  18649. /**
  18650. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18651. * @see http://doc.babylonjs.com/how_to/more_materials
  18652. */
  18653. wAng: number;
  18654. /**
  18655. * Defines the center of rotation (U)
  18656. */
  18657. uRotationCenter: number;
  18658. /**
  18659. * Defines the center of rotation (V)
  18660. */
  18661. vRotationCenter: number;
  18662. /**
  18663. * Defines the center of rotation (W)
  18664. */
  18665. wRotationCenter: number;
  18666. /**
  18667. * Are mip maps generated for this texture or not.
  18668. */
  18669. readonly noMipmap: boolean;
  18670. /**
  18671. * List of inspectable custom properties (used by the Inspector)
  18672. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18673. */
  18674. inspectableCustomProperties: Nullable<IInspectable[]>;
  18675. private _noMipmap;
  18676. /** @hidden */
  18677. _invertY: boolean;
  18678. private _rowGenerationMatrix;
  18679. private _cachedTextureMatrix;
  18680. private _projectionModeMatrix;
  18681. private _t0;
  18682. private _t1;
  18683. private _t2;
  18684. private _cachedUOffset;
  18685. private _cachedVOffset;
  18686. private _cachedUScale;
  18687. private _cachedVScale;
  18688. private _cachedUAng;
  18689. private _cachedVAng;
  18690. private _cachedWAng;
  18691. private _cachedProjectionMatrixId;
  18692. private _cachedCoordinatesMode;
  18693. /** @hidden */
  18694. protected _initialSamplingMode: number;
  18695. /** @hidden */
  18696. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18697. private _deleteBuffer;
  18698. protected _format: Nullable<number>;
  18699. private _delayedOnLoad;
  18700. private _delayedOnError;
  18701. /**
  18702. * Observable triggered once the texture has been loaded.
  18703. */
  18704. onLoadObservable: Observable<Texture>;
  18705. protected _isBlocking: boolean;
  18706. /**
  18707. * Is the texture preventing material to render while loading.
  18708. * If false, a default texture will be used instead of the loading one during the preparation step.
  18709. */
  18710. isBlocking: boolean;
  18711. /**
  18712. * Get the current sampling mode associated with the texture.
  18713. */
  18714. readonly samplingMode: number;
  18715. /**
  18716. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18717. */
  18718. readonly invertY: boolean;
  18719. /**
  18720. * Instantiates a new texture.
  18721. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18722. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18723. * @param url define the url of the picture to load as a texture
  18724. * @param scene define the scene the texture will belong to
  18725. * @param noMipmap define if the texture will require mip maps or not
  18726. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18727. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18728. * @param onLoad define a callback triggered when the texture has been loaded
  18729. * @param onError define a callback triggered when an error occurred during the loading session
  18730. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18731. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18732. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18733. */
  18734. constructor(url: Nullable<string>, scene: Nullable<Scene>, 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);
  18735. /**
  18736. * Update the url (and optional buffer) of this texture if url was null during construction.
  18737. * @param url the url of the texture
  18738. * @param buffer the buffer of the texture (defaults to null)
  18739. * @param onLoad callback called when the texture is loaded (defaults to null)
  18740. */
  18741. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18742. /**
  18743. * Finish the loading sequence of a texture flagged as delayed load.
  18744. * @hidden
  18745. */
  18746. delayLoad(): void;
  18747. private _prepareRowForTextureGeneration;
  18748. /**
  18749. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18750. * @returns the transform matrix of the texture.
  18751. */
  18752. getTextureMatrix(): Matrix;
  18753. /**
  18754. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18755. * @returns The reflection texture transform
  18756. */
  18757. getReflectionTextureMatrix(): Matrix;
  18758. /**
  18759. * Clones the texture.
  18760. * @returns the cloned texture
  18761. */
  18762. clone(): Texture;
  18763. /**
  18764. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18765. * @returns The JSON representation of the texture
  18766. */
  18767. serialize(): any;
  18768. /**
  18769. * Get the current class name of the texture useful for serialization or dynamic coding.
  18770. * @returns "Texture"
  18771. */
  18772. getClassName(): string;
  18773. /**
  18774. * Dispose the texture and release its associated resources.
  18775. */
  18776. dispose(): void;
  18777. /**
  18778. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18779. * @param parsedTexture Define the JSON representation of the texture
  18780. * @param scene Define the scene the parsed texture should be instantiated in
  18781. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18782. * @returns The parsed texture if successful
  18783. */
  18784. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18785. /**
  18786. * Creates a texture from its base 64 representation.
  18787. * @param data Define the base64 payload without the data: prefix
  18788. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18789. * @param scene Define the scene the texture should belong to
  18790. * @param noMipmap Forces the texture to not create mip map information if true
  18791. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18792. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18793. * @param onLoad define a callback triggered when the texture has been loaded
  18794. * @param onError define a callback triggered when an error occurred during the loading session
  18795. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18796. * @returns the created texture
  18797. */
  18798. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18799. /**
  18800. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18801. * @param data Define the base64 payload without the data: prefix
  18802. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18803. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18804. * @param scene Define the scene the texture should belong to
  18805. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18806. * @param noMipmap Forces the texture to not create mip map information if true
  18807. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18808. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18809. * @param onLoad define a callback triggered when the texture has been loaded
  18810. * @param onError define a callback triggered when an error occurred during the loading session
  18811. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18812. * @returns the created texture
  18813. */
  18814. 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;
  18815. }
  18816. }
  18817. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  18818. import { Nullable } from "babylonjs/types";
  18819. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18820. import { Scene } from "babylonjs/scene";
  18821. module "babylonjs/Engines/engine" {
  18822. interface Engine {
  18823. /**
  18824. * Creates a raw texture
  18825. * @param data defines the data to store in the texture
  18826. * @param width defines the width of the texture
  18827. * @param height defines the height of the texture
  18828. * @param format defines the format of the data
  18829. * @param generateMipMaps defines if the engine should generate the mip levels
  18830. * @param invertY defines if data must be stored with Y axis inverted
  18831. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18832. * @param compression defines the compression used (null by default)
  18833. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18834. * @returns the raw texture inside an InternalTexture
  18835. */
  18836. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18837. /**
  18838. * Update a raw texture
  18839. * @param texture defines the texture to update
  18840. * @param data defines the data to store in the texture
  18841. * @param format defines the format of the data
  18842. * @param invertY defines if data must be stored with Y axis inverted
  18843. */
  18844. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18845. /**
  18846. * Update a raw texture
  18847. * @param texture defines the texture to update
  18848. * @param data defines the data to store in the texture
  18849. * @param format defines the format of the data
  18850. * @param invertY defines if data must be stored with Y axis inverted
  18851. * @param compression defines the compression used (null by default)
  18852. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18853. */
  18854. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18855. /**
  18856. * Creates a new raw cube texture
  18857. * @param data defines the array of data to use to create each face
  18858. * @param size defines the size of the textures
  18859. * @param format defines the format of the data
  18860. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18861. * @param generateMipMaps defines if the engine should generate the mip levels
  18862. * @param invertY defines if data must be stored with Y axis inverted
  18863. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18864. * @param compression defines the compression used (null by default)
  18865. * @returns the cube texture as an InternalTexture
  18866. */
  18867. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18868. /**
  18869. * Update a raw cube texture
  18870. * @param texture defines the texture to udpdate
  18871. * @param data defines the data to store
  18872. * @param format defines the data format
  18873. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18874. * @param invertY defines if data must be stored with Y axis inverted
  18875. */
  18876. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18877. /**
  18878. * Update a raw cube texture
  18879. * @param texture defines the texture to udpdate
  18880. * @param data defines the data to store
  18881. * @param format defines the data format
  18882. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18883. * @param invertY defines if data must be stored with Y axis inverted
  18884. * @param compression defines the compression used (null by default)
  18885. */
  18886. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18887. /**
  18888. * Update a raw cube texture
  18889. * @param texture defines the texture to udpdate
  18890. * @param data defines the data to store
  18891. * @param format defines the data format
  18892. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18893. * @param invertY defines if data must be stored with Y axis inverted
  18894. * @param compression defines the compression used (null by default)
  18895. * @param level defines which level of the texture to update
  18896. */
  18897. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  18898. /**
  18899. * Creates a new raw cube texture from a specified url
  18900. * @param url defines the url where the data is located
  18901. * @param scene defines the current scene
  18902. * @param size defines the size of the textures
  18903. * @param format defines the format of the data
  18904. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18905. * @param noMipmap defines if the engine should avoid generating the mip levels
  18906. * @param callback defines a callback used to extract texture data from loaded data
  18907. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18908. * @param onLoad defines a callback called when texture is loaded
  18909. * @param onError defines a callback called if there is an error
  18910. * @returns the cube texture as an InternalTexture
  18911. */
  18912. 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;
  18913. /**
  18914. * Creates a new raw cube texture from a specified url
  18915. * @param url defines the url where the data is located
  18916. * @param scene defines the current scene
  18917. * @param size defines the size of the textures
  18918. * @param format defines the format of the data
  18919. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18920. * @param noMipmap defines if the engine should avoid generating the mip levels
  18921. * @param callback defines a callback used to extract texture data from loaded data
  18922. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18923. * @param onLoad defines a callback called when texture is loaded
  18924. * @param onError defines a callback called if there is an error
  18925. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18926. * @param invertY defines if data must be stored with Y axis inverted
  18927. * @returns the cube texture as an InternalTexture
  18928. */
  18929. 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;
  18930. /**
  18931. * Creates a new raw 3D texture
  18932. * @param data defines the data used to create the texture
  18933. * @param width defines the width of the texture
  18934. * @param height defines the height of the texture
  18935. * @param depth defines the depth of the texture
  18936. * @param format defines the format of the texture
  18937. * @param generateMipMaps defines if the engine must generate mip levels
  18938. * @param invertY defines if data must be stored with Y axis inverted
  18939. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18940. * @param compression defines the compressed used (can be null)
  18941. * @param textureType defines the compressed used (can be null)
  18942. * @returns a new raw 3D texture (stored in an InternalTexture)
  18943. */
  18944. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  18945. /**
  18946. * Update a raw 3D texture
  18947. * @param texture defines the texture to update
  18948. * @param data defines the data to store
  18949. * @param format defines the data format
  18950. * @param invertY defines if data must be stored with Y axis inverted
  18951. */
  18952. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18953. /**
  18954. * Update a raw 3D texture
  18955. * @param texture defines the texture to update
  18956. * @param data defines the data to store
  18957. * @param format defines the data format
  18958. * @param invertY defines if data must be stored with Y axis inverted
  18959. * @param compression defines the used compression (can be null)
  18960. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  18961. */
  18962. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  18963. }
  18964. }
  18965. }
  18966. declare module "babylonjs/Materials/Textures/rawTexture" {
  18967. import { Scene } from "babylonjs/scene";
  18968. import { Texture } from "babylonjs/Materials/Textures/texture";
  18969. import "babylonjs/Engines/Extensions/engine.rawTexture";
  18970. /**
  18971. * Raw texture can help creating a texture directly from an array of data.
  18972. * This can be super useful if you either get the data from an uncompressed source or
  18973. * if you wish to create your texture pixel by pixel.
  18974. */
  18975. export class RawTexture extends Texture {
  18976. /**
  18977. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18978. */
  18979. format: number;
  18980. private _engine;
  18981. /**
  18982. * Instantiates a new RawTexture.
  18983. * Raw texture can help creating a texture directly from an array of data.
  18984. * This can be super useful if you either get the data from an uncompressed source or
  18985. * if you wish to create your texture pixel by pixel.
  18986. * @param data define the array of data to use to create the texture
  18987. * @param width define the width of the texture
  18988. * @param height define the height of the texture
  18989. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18990. * @param scene define the scene the texture belongs to
  18991. * @param generateMipMaps define whether mip maps should be generated or not
  18992. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18993. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18994. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18995. */
  18996. constructor(data: ArrayBufferView, width: number, height: number,
  18997. /**
  18998. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18999. */
  19000. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  19001. /**
  19002. * Updates the texture underlying data.
  19003. * @param data Define the new data of the texture
  19004. */
  19005. update(data: ArrayBufferView): void;
  19006. /**
  19007. * Creates a luminance texture from some data.
  19008. * @param data Define the texture data
  19009. * @param width Define the width of the texture
  19010. * @param height Define the height of the texture
  19011. * @param scene Define the scene the texture belongs to
  19012. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19013. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19014. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19015. * @returns the luminance texture
  19016. */
  19017. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19018. /**
  19019. * Creates a luminance alpha texture from some data.
  19020. * @param data Define the texture data
  19021. * @param width Define the width of the texture
  19022. * @param height Define the height of the texture
  19023. * @param scene Define the scene the texture belongs to
  19024. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19025. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19026. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19027. * @returns the luminance alpha texture
  19028. */
  19029. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19030. /**
  19031. * Creates an alpha texture from some data.
  19032. * @param data Define the texture data
  19033. * @param width Define the width of the texture
  19034. * @param height Define the height of the texture
  19035. * @param scene Define the scene the texture belongs to
  19036. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19037. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19038. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19039. * @returns the alpha texture
  19040. */
  19041. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19042. /**
  19043. * Creates a RGB texture from some data.
  19044. * @param data Define the texture data
  19045. * @param width Define the width of the texture
  19046. * @param height Define the height of the texture
  19047. * @param scene Define the scene the texture belongs to
  19048. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19049. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19050. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19051. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19052. * @returns the RGB alpha texture
  19053. */
  19054. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19055. /**
  19056. * Creates a RGBA texture from some data.
  19057. * @param data Define the texture data
  19058. * @param width Define the width of the texture
  19059. * @param height Define the height of the texture
  19060. * @param scene Define the scene the texture belongs to
  19061. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19062. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19063. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19064. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19065. * @returns the RGBA texture
  19066. */
  19067. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19068. /**
  19069. * Creates a R texture from some data.
  19070. * @param data Define the texture data
  19071. * @param width Define the width of the texture
  19072. * @param height Define the height of the texture
  19073. * @param scene Define the scene the texture belongs to
  19074. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19075. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19076. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19077. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19078. * @returns the R texture
  19079. */
  19080. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19081. }
  19082. }
  19083. declare module "babylonjs/Animations/runtimeAnimation" {
  19084. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  19085. import { Animatable } from "babylonjs/Animations/animatable";
  19086. import { Scene } from "babylonjs/scene";
  19087. /**
  19088. * Defines a runtime animation
  19089. */
  19090. export class RuntimeAnimation {
  19091. private _events;
  19092. /**
  19093. * The current frame of the runtime animation
  19094. */
  19095. private _currentFrame;
  19096. /**
  19097. * The animation used by the runtime animation
  19098. */
  19099. private _animation;
  19100. /**
  19101. * The target of the runtime animation
  19102. */
  19103. private _target;
  19104. /**
  19105. * The initiating animatable
  19106. */
  19107. private _host;
  19108. /**
  19109. * The original value of the runtime animation
  19110. */
  19111. private _originalValue;
  19112. /**
  19113. * The original blend value of the runtime animation
  19114. */
  19115. private _originalBlendValue;
  19116. /**
  19117. * The offsets cache of the runtime animation
  19118. */
  19119. private _offsetsCache;
  19120. /**
  19121. * The high limits cache of the runtime animation
  19122. */
  19123. private _highLimitsCache;
  19124. /**
  19125. * Specifies if the runtime animation has been stopped
  19126. */
  19127. private _stopped;
  19128. /**
  19129. * The blending factor of the runtime animation
  19130. */
  19131. private _blendingFactor;
  19132. /**
  19133. * The BabylonJS scene
  19134. */
  19135. private _scene;
  19136. /**
  19137. * The current value of the runtime animation
  19138. */
  19139. private _currentValue;
  19140. /** @hidden */
  19141. _animationState: _IAnimationState;
  19142. /**
  19143. * The active target of the runtime animation
  19144. */
  19145. private _activeTargets;
  19146. private _currentActiveTarget;
  19147. private _directTarget;
  19148. /**
  19149. * The target path of the runtime animation
  19150. */
  19151. private _targetPath;
  19152. /**
  19153. * The weight of the runtime animation
  19154. */
  19155. private _weight;
  19156. /**
  19157. * The ratio offset of the runtime animation
  19158. */
  19159. private _ratioOffset;
  19160. /**
  19161. * The previous delay of the runtime animation
  19162. */
  19163. private _previousDelay;
  19164. /**
  19165. * The previous ratio of the runtime animation
  19166. */
  19167. private _previousRatio;
  19168. private _enableBlending;
  19169. private _keys;
  19170. private _minFrame;
  19171. private _maxFrame;
  19172. private _minValue;
  19173. private _maxValue;
  19174. private _targetIsArray;
  19175. /**
  19176. * Gets the current frame of the runtime animation
  19177. */
  19178. readonly currentFrame: number;
  19179. /**
  19180. * Gets the weight of the runtime animation
  19181. */
  19182. readonly weight: number;
  19183. /**
  19184. * Gets the current value of the runtime animation
  19185. */
  19186. readonly currentValue: any;
  19187. /**
  19188. * Gets the target path of the runtime animation
  19189. */
  19190. readonly targetPath: string;
  19191. /**
  19192. * Gets the actual target of the runtime animation
  19193. */
  19194. readonly target: any;
  19195. /** @hidden */
  19196. _onLoop: () => void;
  19197. /**
  19198. * Create a new RuntimeAnimation object
  19199. * @param target defines the target of the animation
  19200. * @param animation defines the source animation object
  19201. * @param scene defines the hosting scene
  19202. * @param host defines the initiating Animatable
  19203. */
  19204. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  19205. private _preparePath;
  19206. /**
  19207. * Gets the animation from the runtime animation
  19208. */
  19209. readonly animation: Animation;
  19210. /**
  19211. * Resets the runtime animation to the beginning
  19212. * @param restoreOriginal defines whether to restore the target property to the original value
  19213. */
  19214. reset(restoreOriginal?: boolean): void;
  19215. /**
  19216. * Specifies if the runtime animation is stopped
  19217. * @returns Boolean specifying if the runtime animation is stopped
  19218. */
  19219. isStopped(): boolean;
  19220. /**
  19221. * Disposes of the runtime animation
  19222. */
  19223. dispose(): void;
  19224. /**
  19225. * Apply the interpolated value to the target
  19226. * @param currentValue defines the value computed by the animation
  19227. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  19228. */
  19229. setValue(currentValue: any, weight: number): void;
  19230. private _getOriginalValues;
  19231. private _setValue;
  19232. /**
  19233. * Gets the loop pmode of the runtime animation
  19234. * @returns Loop Mode
  19235. */
  19236. private _getCorrectLoopMode;
  19237. /**
  19238. * Move the current animation to a given frame
  19239. * @param frame defines the frame to move to
  19240. */
  19241. goToFrame(frame: number): void;
  19242. /**
  19243. * @hidden Internal use only
  19244. */
  19245. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  19246. /**
  19247. * Execute the current animation
  19248. * @param delay defines the delay to add to the current frame
  19249. * @param from defines the lower bound of the animation range
  19250. * @param to defines the upper bound of the animation range
  19251. * @param loop defines if the current animation must loop
  19252. * @param speedRatio defines the current speed ratio
  19253. * @param weight defines the weight of the animation (default is -1 so no weight)
  19254. * @param onLoop optional callback called when animation loops
  19255. * @returns a boolean indicating if the animation is running
  19256. */
  19257. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  19258. }
  19259. }
  19260. declare module "babylonjs/Animations/animatable" {
  19261. import { Animation } from "babylonjs/Animations/animation";
  19262. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  19263. import { Nullable } from "babylonjs/types";
  19264. import { Observable } from "babylonjs/Misc/observable";
  19265. import { Scene } from "babylonjs/scene";
  19266. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  19267. import { Node } from "babylonjs/node";
  19268. /**
  19269. * Class used to store an actual running animation
  19270. */
  19271. export class Animatable {
  19272. /** defines the target object */
  19273. target: any;
  19274. /** defines the starting frame number (default is 0) */
  19275. fromFrame: number;
  19276. /** defines the ending frame number (default is 100) */
  19277. toFrame: number;
  19278. /** defines if the animation must loop (default is false) */
  19279. loopAnimation: boolean;
  19280. /** defines a callback to call when animation ends if it is not looping */
  19281. onAnimationEnd?: (() => void) | null | undefined;
  19282. /** defines a callback to call when animation loops */
  19283. onAnimationLoop?: (() => void) | null | undefined;
  19284. private _localDelayOffset;
  19285. private _pausedDelay;
  19286. private _runtimeAnimations;
  19287. private _paused;
  19288. private _scene;
  19289. private _speedRatio;
  19290. private _weight;
  19291. private _syncRoot;
  19292. /**
  19293. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  19294. * This will only apply for non looping animation (default is true)
  19295. */
  19296. disposeOnEnd: boolean;
  19297. /**
  19298. * Gets a boolean indicating if the animation has started
  19299. */
  19300. animationStarted: boolean;
  19301. /**
  19302. * Observer raised when the animation ends
  19303. */
  19304. onAnimationEndObservable: Observable<Animatable>;
  19305. /**
  19306. * Observer raised when the animation loops
  19307. */
  19308. onAnimationLoopObservable: Observable<Animatable>;
  19309. /**
  19310. * Gets the root Animatable used to synchronize and normalize animations
  19311. */
  19312. readonly syncRoot: Nullable<Animatable>;
  19313. /**
  19314. * Gets the current frame of the first RuntimeAnimation
  19315. * Used to synchronize Animatables
  19316. */
  19317. readonly masterFrame: number;
  19318. /**
  19319. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  19320. */
  19321. weight: number;
  19322. /**
  19323. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  19324. */
  19325. speedRatio: number;
  19326. /**
  19327. * Creates a new Animatable
  19328. * @param scene defines the hosting scene
  19329. * @param target defines the target object
  19330. * @param fromFrame defines the starting frame number (default is 0)
  19331. * @param toFrame defines the ending frame number (default is 100)
  19332. * @param loopAnimation defines if the animation must loop (default is false)
  19333. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  19334. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  19335. * @param animations defines a group of animation to add to the new Animatable
  19336. * @param onAnimationLoop defines a callback to call when animation loops
  19337. */
  19338. constructor(scene: Scene,
  19339. /** defines the target object */
  19340. target: any,
  19341. /** defines the starting frame number (default is 0) */
  19342. fromFrame?: number,
  19343. /** defines the ending frame number (default is 100) */
  19344. toFrame?: number,
  19345. /** defines if the animation must loop (default is false) */
  19346. loopAnimation?: boolean, speedRatio?: number,
  19347. /** defines a callback to call when animation ends if it is not looping */
  19348. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  19349. /** defines a callback to call when animation loops */
  19350. onAnimationLoop?: (() => void) | null | undefined);
  19351. /**
  19352. * Synchronize and normalize current Animatable with a source Animatable
  19353. * This is useful when using animation weights and when animations are not of the same length
  19354. * @param root defines the root Animatable to synchronize with
  19355. * @returns the current Animatable
  19356. */
  19357. syncWith(root: Animatable): Animatable;
  19358. /**
  19359. * Gets the list of runtime animations
  19360. * @returns an array of RuntimeAnimation
  19361. */
  19362. getAnimations(): RuntimeAnimation[];
  19363. /**
  19364. * Adds more animations to the current animatable
  19365. * @param target defines the target of the animations
  19366. * @param animations defines the new animations to add
  19367. */
  19368. appendAnimations(target: any, animations: Animation[]): void;
  19369. /**
  19370. * Gets the source animation for a specific property
  19371. * @param property defines the propertyu to look for
  19372. * @returns null or the source animation for the given property
  19373. */
  19374. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19375. /**
  19376. * Gets the runtime animation for a specific property
  19377. * @param property defines the propertyu to look for
  19378. * @returns null or the runtime animation for the given property
  19379. */
  19380. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19381. /**
  19382. * Resets the animatable to its original state
  19383. */
  19384. reset(): void;
  19385. /**
  19386. * Allows the animatable to blend with current running animations
  19387. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19388. * @param blendingSpeed defines the blending speed to use
  19389. */
  19390. enableBlending(blendingSpeed: number): void;
  19391. /**
  19392. * Disable animation blending
  19393. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19394. */
  19395. disableBlending(): void;
  19396. /**
  19397. * Jump directly to a given frame
  19398. * @param frame defines the frame to jump to
  19399. */
  19400. goToFrame(frame: number): void;
  19401. /**
  19402. * Pause the animation
  19403. */
  19404. pause(): void;
  19405. /**
  19406. * Restart the animation
  19407. */
  19408. restart(): void;
  19409. private _raiseOnAnimationEnd;
  19410. /**
  19411. * Stop and delete the current animation
  19412. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19413. * @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)
  19414. */
  19415. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19416. /**
  19417. * Wait asynchronously for the animation to end
  19418. * @returns a promise which will be fullfilled when the animation ends
  19419. */
  19420. waitAsync(): Promise<Animatable>;
  19421. /** @hidden */
  19422. _animate(delay: number): boolean;
  19423. }
  19424. module "babylonjs/scene" {
  19425. interface Scene {
  19426. /** @hidden */
  19427. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19428. /** @hidden */
  19429. _processLateAnimationBindingsForMatrices(holder: {
  19430. totalWeight: number;
  19431. animations: RuntimeAnimation[];
  19432. originalValue: Matrix;
  19433. }): any;
  19434. /** @hidden */
  19435. _processLateAnimationBindingsForQuaternions(holder: {
  19436. totalWeight: number;
  19437. animations: RuntimeAnimation[];
  19438. originalValue: Quaternion;
  19439. }, refQuaternion: Quaternion): Quaternion;
  19440. /** @hidden */
  19441. _processLateAnimationBindings(): void;
  19442. /**
  19443. * Will start the animation sequence of a given target
  19444. * @param target defines the target
  19445. * @param from defines from which frame should animation start
  19446. * @param to defines until which frame should animation run.
  19447. * @param weight defines the weight to apply to the animation (1.0 by default)
  19448. * @param loop defines if the animation loops
  19449. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19450. * @param onAnimationEnd defines the function to be executed when the animation ends
  19451. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19452. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19453. * @param onAnimationLoop defines the callback to call when an animation loops
  19454. * @returns the animatable object created for this animation
  19455. */
  19456. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19457. /**
  19458. * Will start the animation sequence of a given target
  19459. * @param target defines the target
  19460. * @param from defines from which frame should animation start
  19461. * @param to defines until which frame should animation run.
  19462. * @param loop defines if the animation loops
  19463. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19464. * @param onAnimationEnd defines the function to be executed when the animation ends
  19465. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19466. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19467. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19468. * @param onAnimationLoop defines the callback to call when an animation loops
  19469. * @returns the animatable object created for this animation
  19470. */
  19471. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19472. /**
  19473. * Will start the animation sequence of a given target and its hierarchy
  19474. * @param target defines the target
  19475. * @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.
  19476. * @param from defines from which frame should animation start
  19477. * @param to defines until which frame should animation run.
  19478. * @param loop defines if the animation loops
  19479. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19480. * @param onAnimationEnd defines the function to be executed when the animation ends
  19481. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19482. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19483. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19484. * @param onAnimationLoop defines the callback to call when an animation loops
  19485. * @returns the list of created animatables
  19486. */
  19487. 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[];
  19488. /**
  19489. * Begin a new animation on a given node
  19490. * @param target defines the target where the animation will take place
  19491. * @param animations defines the list of animations to start
  19492. * @param from defines the initial value
  19493. * @param to defines the final value
  19494. * @param loop defines if you want animation to loop (off by default)
  19495. * @param speedRatio defines the speed ratio to apply to all animations
  19496. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19497. * @param onAnimationLoop defines the callback to call when an animation loops
  19498. * @returns the list of created animatables
  19499. */
  19500. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19501. /**
  19502. * Begin a new animation on a given node and its hierarchy
  19503. * @param target defines the root node where the animation will take place
  19504. * @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.
  19505. * @param animations defines the list of animations to start
  19506. * @param from defines the initial value
  19507. * @param to defines the final value
  19508. * @param loop defines if you want animation to loop (off by default)
  19509. * @param speedRatio defines the speed ratio to apply to all animations
  19510. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19511. * @param onAnimationLoop defines the callback to call when an animation loops
  19512. * @returns the list of animatables created for all nodes
  19513. */
  19514. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19515. /**
  19516. * Gets the animatable associated with a specific target
  19517. * @param target defines the target of the animatable
  19518. * @returns the required animatable if found
  19519. */
  19520. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19521. /**
  19522. * Gets all animatables associated with a given target
  19523. * @param target defines the target to look animatables for
  19524. * @returns an array of Animatables
  19525. */
  19526. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19527. /**
  19528. * Will stop the animation of the given target
  19529. * @param target - the target
  19530. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  19531. * @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)
  19532. */
  19533. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  19534. /**
  19535. * Stops and removes all animations that have been applied to the scene
  19536. */
  19537. stopAllAnimations(): void;
  19538. }
  19539. }
  19540. module "babylonjs/Bones/bone" {
  19541. interface Bone {
  19542. /**
  19543. * Copy an animation range from another bone
  19544. * @param source defines the source bone
  19545. * @param rangeName defines the range name to copy
  19546. * @param frameOffset defines the frame offset
  19547. * @param rescaleAsRequired defines if rescaling must be applied if required
  19548. * @param skelDimensionsRatio defines the scaling ratio
  19549. * @returns true if operation was successful
  19550. */
  19551. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19552. }
  19553. }
  19554. }
  19555. declare module "babylonjs/Bones/skeleton" {
  19556. import { Bone } from "babylonjs/Bones/bone";
  19557. import { IAnimatable } from "babylonjs/Misc/tools";
  19558. import { Observable } from "babylonjs/Misc/observable";
  19559. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19560. import { Scene } from "babylonjs/scene";
  19561. import { Nullable } from "babylonjs/types";
  19562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19563. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19564. import { Animatable } from "babylonjs/Animations/animatable";
  19565. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19566. import { Animation } from "babylonjs/Animations/animation";
  19567. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19568. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19569. /**
  19570. * Class used to handle skinning animations
  19571. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19572. */
  19573. export class Skeleton implements IAnimatable {
  19574. /** defines the skeleton name */
  19575. name: string;
  19576. /** defines the skeleton Id */
  19577. id: string;
  19578. /**
  19579. * Defines the list of child bones
  19580. */
  19581. bones: Bone[];
  19582. /**
  19583. * Defines an estimate of the dimension of the skeleton at rest
  19584. */
  19585. dimensionsAtRest: Vector3;
  19586. /**
  19587. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19588. */
  19589. needInitialSkinMatrix: boolean;
  19590. /**
  19591. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19592. */
  19593. overrideMesh: Nullable<AbstractMesh>;
  19594. /**
  19595. * Gets the list of animations attached to this skeleton
  19596. */
  19597. animations: Array<Animation>;
  19598. private _scene;
  19599. private _isDirty;
  19600. private _transformMatrices;
  19601. private _transformMatrixTexture;
  19602. private _meshesWithPoseMatrix;
  19603. private _animatables;
  19604. private _identity;
  19605. private _synchronizedWithMesh;
  19606. private _ranges;
  19607. private _lastAbsoluteTransformsUpdateId;
  19608. private _canUseTextureForBones;
  19609. private _uniqueId;
  19610. /** @hidden */
  19611. _numBonesWithLinkedTransformNode: number;
  19612. /**
  19613. * Specifies if the skeleton should be serialized
  19614. */
  19615. doNotSerialize: boolean;
  19616. private _useTextureToStoreBoneMatrices;
  19617. /**
  19618. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19619. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19620. */
  19621. useTextureToStoreBoneMatrices: boolean;
  19622. private _animationPropertiesOverride;
  19623. /**
  19624. * Gets or sets the animation properties override
  19625. */
  19626. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19627. /**
  19628. * List of inspectable custom properties (used by the Inspector)
  19629. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19630. */
  19631. inspectableCustomProperties: IInspectable[];
  19632. /**
  19633. * An observable triggered before computing the skeleton's matrices
  19634. */
  19635. onBeforeComputeObservable: Observable<Skeleton>;
  19636. /**
  19637. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19638. */
  19639. readonly isUsingTextureForMatrices: boolean;
  19640. /**
  19641. * Gets the unique ID of this skeleton
  19642. */
  19643. readonly uniqueId: number;
  19644. /**
  19645. * Creates a new skeleton
  19646. * @param name defines the skeleton name
  19647. * @param id defines the skeleton Id
  19648. * @param scene defines the hosting scene
  19649. */
  19650. constructor(
  19651. /** defines the skeleton name */
  19652. name: string,
  19653. /** defines the skeleton Id */
  19654. id: string, scene: Scene);
  19655. /**
  19656. * Gets the current object class name.
  19657. * @return the class name
  19658. */
  19659. getClassName(): string;
  19660. /**
  19661. * Returns an array containing the root bones
  19662. * @returns an array containing the root bones
  19663. */
  19664. getChildren(): Array<Bone>;
  19665. /**
  19666. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19667. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19668. * @returns a Float32Array containing matrices data
  19669. */
  19670. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19671. /**
  19672. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19673. * @returns a raw texture containing the data
  19674. */
  19675. getTransformMatrixTexture(): Nullable<RawTexture>;
  19676. /**
  19677. * Gets the current hosting scene
  19678. * @returns a scene object
  19679. */
  19680. getScene(): Scene;
  19681. /**
  19682. * Gets a string representing the current skeleton data
  19683. * @param fullDetails defines a boolean indicating if we want a verbose version
  19684. * @returns a string representing the current skeleton data
  19685. */
  19686. toString(fullDetails?: boolean): string;
  19687. /**
  19688. * Get bone's index searching by name
  19689. * @param name defines bone's name to search for
  19690. * @return the indice of the bone. Returns -1 if not found
  19691. */
  19692. getBoneIndexByName(name: string): number;
  19693. /**
  19694. * Creater a new animation range
  19695. * @param name defines the name of the range
  19696. * @param from defines the start key
  19697. * @param to defines the end key
  19698. */
  19699. createAnimationRange(name: string, from: number, to: number): void;
  19700. /**
  19701. * Delete a specific animation range
  19702. * @param name defines the name of the range
  19703. * @param deleteFrames defines if frames must be removed as well
  19704. */
  19705. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19706. /**
  19707. * Gets a specific animation range
  19708. * @param name defines the name of the range to look for
  19709. * @returns the requested animation range or null if not found
  19710. */
  19711. getAnimationRange(name: string): Nullable<AnimationRange>;
  19712. /**
  19713. * Gets the list of all animation ranges defined on this skeleton
  19714. * @returns an array
  19715. */
  19716. getAnimationRanges(): Nullable<AnimationRange>[];
  19717. /**
  19718. * Copy animation range from a source skeleton.
  19719. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19720. * @param source defines the source skeleton
  19721. * @param name defines the name of the range to copy
  19722. * @param rescaleAsRequired defines if rescaling must be applied if required
  19723. * @returns true if operation was successful
  19724. */
  19725. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19726. /**
  19727. * Forces the skeleton to go to rest pose
  19728. */
  19729. returnToRest(): void;
  19730. private _getHighestAnimationFrame;
  19731. /**
  19732. * Begin a specific animation range
  19733. * @param name defines the name of the range to start
  19734. * @param loop defines if looping must be turned on (false by default)
  19735. * @param speedRatio defines the speed ratio to apply (1 by default)
  19736. * @param onAnimationEnd defines a callback which will be called when animation will end
  19737. * @returns a new animatable
  19738. */
  19739. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19740. /** @hidden */
  19741. _markAsDirty(): void;
  19742. /** @hidden */
  19743. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19744. /** @hidden */
  19745. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19746. private _computeTransformMatrices;
  19747. /**
  19748. * Build all resources required to render a skeleton
  19749. */
  19750. prepare(): void;
  19751. /**
  19752. * Gets the list of animatables currently running for this skeleton
  19753. * @returns an array of animatables
  19754. */
  19755. getAnimatables(): IAnimatable[];
  19756. /**
  19757. * Clone the current skeleton
  19758. * @param name defines the name of the new skeleton
  19759. * @param id defines the id of the new skeleton
  19760. * @returns the new skeleton
  19761. */
  19762. clone(name: string, id: string): Skeleton;
  19763. /**
  19764. * Enable animation blending for this skeleton
  19765. * @param blendingSpeed defines the blending speed to apply
  19766. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19767. */
  19768. enableBlending(blendingSpeed?: number): void;
  19769. /**
  19770. * Releases all resources associated with the current skeleton
  19771. */
  19772. dispose(): void;
  19773. /**
  19774. * Serialize the skeleton in a JSON object
  19775. * @returns a JSON object
  19776. */
  19777. serialize(): any;
  19778. /**
  19779. * Creates a new skeleton from serialized data
  19780. * @param parsedSkeleton defines the serialized data
  19781. * @param scene defines the hosting scene
  19782. * @returns a new skeleton
  19783. */
  19784. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19785. /**
  19786. * Compute all node absolute transforms
  19787. * @param forceUpdate defines if computation must be done even if cache is up to date
  19788. */
  19789. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19790. /**
  19791. * Gets the root pose matrix
  19792. * @returns a matrix
  19793. */
  19794. getPoseMatrix(): Nullable<Matrix>;
  19795. /**
  19796. * Sorts bones per internal index
  19797. */
  19798. sortBones(): void;
  19799. private _sortBones;
  19800. }
  19801. }
  19802. declare module "babylonjs/Morph/morphTarget" {
  19803. import { IAnimatable } from "babylonjs/Misc/tools";
  19804. import { Observable } from "babylonjs/Misc/observable";
  19805. import { Nullable, FloatArray } from "babylonjs/types";
  19806. import { Scene } from "babylonjs/scene";
  19807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19808. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19809. /**
  19810. * Defines a target to use with MorphTargetManager
  19811. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19812. */
  19813. export class MorphTarget implements IAnimatable {
  19814. /** defines the name of the target */
  19815. name: string;
  19816. /**
  19817. * Gets or sets the list of animations
  19818. */
  19819. animations: import("babylonjs/Animations/animation").Animation[];
  19820. private _scene;
  19821. private _positions;
  19822. private _normals;
  19823. private _tangents;
  19824. private _influence;
  19825. /**
  19826. * Observable raised when the influence changes
  19827. */
  19828. onInfluenceChanged: Observable<boolean>;
  19829. /** @hidden */
  19830. _onDataLayoutChanged: Observable<void>;
  19831. /**
  19832. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19833. */
  19834. influence: number;
  19835. /**
  19836. * Gets or sets the id of the morph Target
  19837. */
  19838. id: string;
  19839. private _animationPropertiesOverride;
  19840. /**
  19841. * Gets or sets the animation properties override
  19842. */
  19843. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19844. /**
  19845. * Creates a new MorphTarget
  19846. * @param name defines the name of the target
  19847. * @param influence defines the influence to use
  19848. * @param scene defines the scene the morphtarget belongs to
  19849. */
  19850. constructor(
  19851. /** defines the name of the target */
  19852. name: string, influence?: number, scene?: Nullable<Scene>);
  19853. /**
  19854. * Gets a boolean defining if the target contains position data
  19855. */
  19856. readonly hasPositions: boolean;
  19857. /**
  19858. * Gets a boolean defining if the target contains normal data
  19859. */
  19860. readonly hasNormals: boolean;
  19861. /**
  19862. * Gets a boolean defining if the target contains tangent data
  19863. */
  19864. readonly hasTangents: boolean;
  19865. /**
  19866. * Affects position data to this target
  19867. * @param data defines the position data to use
  19868. */
  19869. setPositions(data: Nullable<FloatArray>): void;
  19870. /**
  19871. * Gets the position data stored in this target
  19872. * @returns a FloatArray containing the position data (or null if not present)
  19873. */
  19874. getPositions(): Nullable<FloatArray>;
  19875. /**
  19876. * Affects normal data to this target
  19877. * @param data defines the normal data to use
  19878. */
  19879. setNormals(data: Nullable<FloatArray>): void;
  19880. /**
  19881. * Gets the normal data stored in this target
  19882. * @returns a FloatArray containing the normal data (or null if not present)
  19883. */
  19884. getNormals(): Nullable<FloatArray>;
  19885. /**
  19886. * Affects tangent data to this target
  19887. * @param data defines the tangent data to use
  19888. */
  19889. setTangents(data: Nullable<FloatArray>): void;
  19890. /**
  19891. * Gets the tangent data stored in this target
  19892. * @returns a FloatArray containing the tangent data (or null if not present)
  19893. */
  19894. getTangents(): Nullable<FloatArray>;
  19895. /**
  19896. * Serializes the current target into a Serialization object
  19897. * @returns the serialized object
  19898. */
  19899. serialize(): any;
  19900. /**
  19901. * Returns the string "MorphTarget"
  19902. * @returns "MorphTarget"
  19903. */
  19904. getClassName(): string;
  19905. /**
  19906. * Creates a new target from serialized data
  19907. * @param serializationObject defines the serialized data to use
  19908. * @returns a new MorphTarget
  19909. */
  19910. static Parse(serializationObject: any): MorphTarget;
  19911. /**
  19912. * Creates a MorphTarget from mesh data
  19913. * @param mesh defines the source mesh
  19914. * @param name defines the name to use for the new target
  19915. * @param influence defines the influence to attach to the target
  19916. * @returns a new MorphTarget
  19917. */
  19918. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19919. }
  19920. }
  19921. declare module "babylonjs/Morph/morphTargetManager" {
  19922. import { Nullable } from "babylonjs/types";
  19923. import { Scene } from "babylonjs/scene";
  19924. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19925. /**
  19926. * This class is used to deform meshes using morphing between different targets
  19927. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19928. */
  19929. export class MorphTargetManager {
  19930. private _targets;
  19931. private _targetInfluenceChangedObservers;
  19932. private _targetDataLayoutChangedObservers;
  19933. private _activeTargets;
  19934. private _scene;
  19935. private _influences;
  19936. private _supportsNormals;
  19937. private _supportsTangents;
  19938. private _vertexCount;
  19939. private _uniqueId;
  19940. private _tempInfluences;
  19941. /**
  19942. * Creates a new MorphTargetManager
  19943. * @param scene defines the current scene
  19944. */
  19945. constructor(scene?: Nullable<Scene>);
  19946. /**
  19947. * Gets the unique ID of this manager
  19948. */
  19949. readonly uniqueId: number;
  19950. /**
  19951. * Gets the number of vertices handled by this manager
  19952. */
  19953. readonly vertexCount: number;
  19954. /**
  19955. * Gets a boolean indicating if this manager supports morphing of normals
  19956. */
  19957. readonly supportsNormals: boolean;
  19958. /**
  19959. * Gets a boolean indicating if this manager supports morphing of tangents
  19960. */
  19961. readonly supportsTangents: boolean;
  19962. /**
  19963. * Gets the number of targets stored in this manager
  19964. */
  19965. readonly numTargets: number;
  19966. /**
  19967. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19968. */
  19969. readonly numInfluencers: number;
  19970. /**
  19971. * Gets the list of influences (one per target)
  19972. */
  19973. readonly influences: Float32Array;
  19974. /**
  19975. * Gets the active target at specified index. An active target is a target with an influence > 0
  19976. * @param index defines the index to check
  19977. * @returns the requested target
  19978. */
  19979. getActiveTarget(index: number): MorphTarget;
  19980. /**
  19981. * Gets the target at specified index
  19982. * @param index defines the index to check
  19983. * @returns the requested target
  19984. */
  19985. getTarget(index: number): MorphTarget;
  19986. /**
  19987. * Add a new target to this manager
  19988. * @param target defines the target to add
  19989. */
  19990. addTarget(target: MorphTarget): void;
  19991. /**
  19992. * Removes a target from the manager
  19993. * @param target defines the target to remove
  19994. */
  19995. removeTarget(target: MorphTarget): void;
  19996. /**
  19997. * Serializes the current manager into a Serialization object
  19998. * @returns the serialized object
  19999. */
  20000. serialize(): any;
  20001. private _syncActiveTargets;
  20002. /**
  20003. * Syncrhonize the targets with all the meshes using this morph target manager
  20004. */
  20005. synchronize(): void;
  20006. /**
  20007. * Creates a new MorphTargetManager from serialized data
  20008. * @param serializationObject defines the serialized data
  20009. * @param scene defines the hosting scene
  20010. * @returns the new MorphTargetManager
  20011. */
  20012. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  20013. }
  20014. }
  20015. declare module "babylonjs/Meshes/meshLODLevel" {
  20016. import { Mesh } from "babylonjs/Meshes/mesh";
  20017. import { Nullable } from "babylonjs/types";
  20018. /**
  20019. * Class used to represent a specific level of detail of a mesh
  20020. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20021. */
  20022. export class MeshLODLevel {
  20023. /** Defines the distance where this level should star being displayed */
  20024. distance: number;
  20025. /** Defines the mesh to use to render this level */
  20026. mesh: Nullable<Mesh>;
  20027. /**
  20028. * Creates a new LOD level
  20029. * @param distance defines the distance where this level should star being displayed
  20030. * @param mesh defines the mesh to use to render this level
  20031. */
  20032. constructor(
  20033. /** Defines the distance where this level should star being displayed */
  20034. distance: number,
  20035. /** Defines the mesh to use to render this level */
  20036. mesh: Nullable<Mesh>);
  20037. }
  20038. }
  20039. declare module "babylonjs/Meshes/groundMesh" {
  20040. import { Scene } from "babylonjs/scene";
  20041. import { Vector3 } from "babylonjs/Maths/math";
  20042. import { Mesh } from "babylonjs/Meshes/mesh";
  20043. /**
  20044. * Mesh representing the gorund
  20045. */
  20046. export class GroundMesh extends Mesh {
  20047. /** If octree should be generated */
  20048. generateOctree: boolean;
  20049. private _heightQuads;
  20050. /** @hidden */
  20051. _subdivisionsX: number;
  20052. /** @hidden */
  20053. _subdivisionsY: number;
  20054. /** @hidden */
  20055. _width: number;
  20056. /** @hidden */
  20057. _height: number;
  20058. /** @hidden */
  20059. _minX: number;
  20060. /** @hidden */
  20061. _maxX: number;
  20062. /** @hidden */
  20063. _minZ: number;
  20064. /** @hidden */
  20065. _maxZ: number;
  20066. constructor(name: string, scene: Scene);
  20067. /**
  20068. * "GroundMesh"
  20069. * @returns "GroundMesh"
  20070. */
  20071. getClassName(): string;
  20072. /**
  20073. * The minimum of x and y subdivisions
  20074. */
  20075. readonly subdivisions: number;
  20076. /**
  20077. * X subdivisions
  20078. */
  20079. readonly subdivisionsX: number;
  20080. /**
  20081. * Y subdivisions
  20082. */
  20083. readonly subdivisionsY: number;
  20084. /**
  20085. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  20086. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  20087. * @param chunksCount the number of subdivisions for x and y
  20088. * @param octreeBlocksSize (Default: 32)
  20089. */
  20090. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20091. /**
  20092. * Returns a height (y) value in the Worl system :
  20093. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20094. * @param x x coordinate
  20095. * @param z z coordinate
  20096. * @returns the ground y position if (x, z) are outside the ground surface.
  20097. */
  20098. getHeightAtCoordinates(x: number, z: number): number;
  20099. /**
  20100. * Returns a normalized vector (Vector3) orthogonal to the ground
  20101. * at the ground coordinates (x, z) expressed in the World system.
  20102. * @param x x coordinate
  20103. * @param z z coordinate
  20104. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20105. */
  20106. getNormalAtCoordinates(x: number, z: number): Vector3;
  20107. /**
  20108. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20109. * at the ground coordinates (x, z) expressed in the World system.
  20110. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20111. * @param x x coordinate
  20112. * @param z z coordinate
  20113. * @param ref vector to store the result
  20114. * @returns the GroundMesh.
  20115. */
  20116. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20117. /**
  20118. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20119. * if the ground has been updated.
  20120. * This can be used in the render loop.
  20121. * @returns the GroundMesh.
  20122. */
  20123. updateCoordinateHeights(): GroundMesh;
  20124. private _getFacetAt;
  20125. private _initHeightQuads;
  20126. private _computeHeightQuads;
  20127. /**
  20128. * Serializes this ground mesh
  20129. * @param serializationObject object to write serialization to
  20130. */
  20131. serialize(serializationObject: any): void;
  20132. /**
  20133. * Parses a serialized ground mesh
  20134. * @param parsedMesh the serialized mesh
  20135. * @param scene the scene to create the ground mesh in
  20136. * @returns the created ground mesh
  20137. */
  20138. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20139. }
  20140. }
  20141. declare module "babylonjs/Physics/physicsJoint" {
  20142. import { Vector3 } from "babylonjs/Maths/math";
  20143. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  20144. /**
  20145. * Interface for Physics-Joint data
  20146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20147. */
  20148. export interface PhysicsJointData {
  20149. /**
  20150. * The main pivot of the joint
  20151. */
  20152. mainPivot?: Vector3;
  20153. /**
  20154. * The connected pivot of the joint
  20155. */
  20156. connectedPivot?: Vector3;
  20157. /**
  20158. * The main axis of the joint
  20159. */
  20160. mainAxis?: Vector3;
  20161. /**
  20162. * The connected axis of the joint
  20163. */
  20164. connectedAxis?: Vector3;
  20165. /**
  20166. * The collision of the joint
  20167. */
  20168. collision?: boolean;
  20169. /**
  20170. * Native Oimo/Cannon/Energy data
  20171. */
  20172. nativeParams?: any;
  20173. }
  20174. /**
  20175. * This is a holder class for the physics joint created by the physics plugin
  20176. * It holds a set of functions to control the underlying joint
  20177. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20178. */
  20179. export class PhysicsJoint {
  20180. /**
  20181. * The type of the physics joint
  20182. */
  20183. type: number;
  20184. /**
  20185. * The data for the physics joint
  20186. */
  20187. jointData: PhysicsJointData;
  20188. private _physicsJoint;
  20189. protected _physicsPlugin: IPhysicsEnginePlugin;
  20190. /**
  20191. * Initializes the physics joint
  20192. * @param type The type of the physics joint
  20193. * @param jointData The data for the physics joint
  20194. */
  20195. constructor(
  20196. /**
  20197. * The type of the physics joint
  20198. */
  20199. type: number,
  20200. /**
  20201. * The data for the physics joint
  20202. */
  20203. jointData: PhysicsJointData);
  20204. /**
  20205. * Gets the physics joint
  20206. */
  20207. /**
  20208. * Sets the physics joint
  20209. */
  20210. physicsJoint: any;
  20211. /**
  20212. * Sets the physics plugin
  20213. */
  20214. physicsPlugin: IPhysicsEnginePlugin;
  20215. /**
  20216. * Execute a function that is physics-plugin specific.
  20217. * @param {Function} func the function that will be executed.
  20218. * It accepts two parameters: the physics world and the physics joint
  20219. */
  20220. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  20221. /**
  20222. * Distance-Joint type
  20223. */
  20224. static DistanceJoint: number;
  20225. /**
  20226. * Hinge-Joint type
  20227. */
  20228. static HingeJoint: number;
  20229. /**
  20230. * Ball-and-Socket joint type
  20231. */
  20232. static BallAndSocketJoint: number;
  20233. /**
  20234. * Wheel-Joint type
  20235. */
  20236. static WheelJoint: number;
  20237. /**
  20238. * Slider-Joint type
  20239. */
  20240. static SliderJoint: number;
  20241. /**
  20242. * Prismatic-Joint type
  20243. */
  20244. static PrismaticJoint: number;
  20245. /**
  20246. * Universal-Joint type
  20247. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  20248. */
  20249. static UniversalJoint: number;
  20250. /**
  20251. * Hinge-Joint 2 type
  20252. */
  20253. static Hinge2Joint: number;
  20254. /**
  20255. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  20256. */
  20257. static PointToPointJoint: number;
  20258. /**
  20259. * Spring-Joint type
  20260. */
  20261. static SpringJoint: number;
  20262. /**
  20263. * Lock-Joint type
  20264. */
  20265. static LockJoint: number;
  20266. }
  20267. /**
  20268. * A class representing a physics distance joint
  20269. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20270. */
  20271. export class DistanceJoint extends PhysicsJoint {
  20272. /**
  20273. *
  20274. * @param jointData The data for the Distance-Joint
  20275. */
  20276. constructor(jointData: DistanceJointData);
  20277. /**
  20278. * Update the predefined distance.
  20279. * @param maxDistance The maximum preferred distance
  20280. * @param minDistance The minimum preferred distance
  20281. */
  20282. updateDistance(maxDistance: number, minDistance?: number): void;
  20283. }
  20284. /**
  20285. * Represents a Motor-Enabled Joint
  20286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20287. */
  20288. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  20289. /**
  20290. * Initializes the Motor-Enabled Joint
  20291. * @param type The type of the joint
  20292. * @param jointData The physica joint data for the joint
  20293. */
  20294. constructor(type: number, jointData: PhysicsJointData);
  20295. /**
  20296. * Set the motor values.
  20297. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20298. * @param force the force to apply
  20299. * @param maxForce max force for this motor.
  20300. */
  20301. setMotor(force?: number, maxForce?: number): void;
  20302. /**
  20303. * Set the motor's limits.
  20304. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20305. * @param upperLimit The upper limit of the motor
  20306. * @param lowerLimit The lower limit of the motor
  20307. */
  20308. setLimit(upperLimit: number, lowerLimit?: number): void;
  20309. }
  20310. /**
  20311. * This class represents a single physics Hinge-Joint
  20312. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20313. */
  20314. export class HingeJoint extends MotorEnabledJoint {
  20315. /**
  20316. * Initializes the Hinge-Joint
  20317. * @param jointData The joint data for the Hinge-Joint
  20318. */
  20319. constructor(jointData: PhysicsJointData);
  20320. /**
  20321. * Set the motor values.
  20322. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20323. * @param {number} force the force to apply
  20324. * @param {number} maxForce max force for this motor.
  20325. */
  20326. setMotor(force?: number, maxForce?: number): void;
  20327. /**
  20328. * Set the motor's limits.
  20329. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20330. * @param upperLimit The upper limit of the motor
  20331. * @param lowerLimit The lower limit of the motor
  20332. */
  20333. setLimit(upperLimit: number, lowerLimit?: number): void;
  20334. }
  20335. /**
  20336. * This class represents a dual hinge physics joint (same as wheel joint)
  20337. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20338. */
  20339. export class Hinge2Joint extends MotorEnabledJoint {
  20340. /**
  20341. * Initializes the Hinge2-Joint
  20342. * @param jointData The joint data for the Hinge2-Joint
  20343. */
  20344. constructor(jointData: PhysicsJointData);
  20345. /**
  20346. * Set the motor values.
  20347. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20348. * @param {number} targetSpeed the speed the motor is to reach
  20349. * @param {number} maxForce max force for this motor.
  20350. * @param {motorIndex} the motor's index, 0 or 1.
  20351. */
  20352. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  20353. /**
  20354. * Set the motor limits.
  20355. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20356. * @param {number} upperLimit the upper limit
  20357. * @param {number} lowerLimit lower limit
  20358. * @param {motorIndex} the motor's index, 0 or 1.
  20359. */
  20360. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20361. }
  20362. /**
  20363. * Interface for a motor enabled joint
  20364. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20365. */
  20366. export interface IMotorEnabledJoint {
  20367. /**
  20368. * Physics joint
  20369. */
  20370. physicsJoint: any;
  20371. /**
  20372. * Sets the motor of the motor-enabled joint
  20373. * @param force The force of the motor
  20374. * @param maxForce The maximum force of the motor
  20375. * @param motorIndex The index of the motor
  20376. */
  20377. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20378. /**
  20379. * Sets the limit of the motor
  20380. * @param upperLimit The upper limit of the motor
  20381. * @param lowerLimit The lower limit of the motor
  20382. * @param motorIndex The index of the motor
  20383. */
  20384. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20385. }
  20386. /**
  20387. * Joint data for a Distance-Joint
  20388. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20389. */
  20390. export interface DistanceJointData extends PhysicsJointData {
  20391. /**
  20392. * Max distance the 2 joint objects can be apart
  20393. */
  20394. maxDistance: number;
  20395. }
  20396. /**
  20397. * Joint data from a spring joint
  20398. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20399. */
  20400. export interface SpringJointData extends PhysicsJointData {
  20401. /**
  20402. * Length of the spring
  20403. */
  20404. length: number;
  20405. /**
  20406. * Stiffness of the spring
  20407. */
  20408. stiffness: number;
  20409. /**
  20410. * Damping of the spring
  20411. */
  20412. damping: number;
  20413. /** this callback will be called when applying the force to the impostors. */
  20414. forceApplicationCallback: () => void;
  20415. }
  20416. }
  20417. declare module "babylonjs/Physics/physicsRaycastResult" {
  20418. import { Vector3 } from "babylonjs/Maths/math";
  20419. /**
  20420. * Holds the data for the raycast result
  20421. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20422. */
  20423. export class PhysicsRaycastResult {
  20424. private _hasHit;
  20425. private _hitDistance;
  20426. private _hitNormalWorld;
  20427. private _hitPointWorld;
  20428. private _rayFromWorld;
  20429. private _rayToWorld;
  20430. /**
  20431. * Gets if there was a hit
  20432. */
  20433. readonly hasHit: boolean;
  20434. /**
  20435. * Gets the distance from the hit
  20436. */
  20437. readonly hitDistance: number;
  20438. /**
  20439. * Gets the hit normal/direction in the world
  20440. */
  20441. readonly hitNormalWorld: Vector3;
  20442. /**
  20443. * Gets the hit point in the world
  20444. */
  20445. readonly hitPointWorld: Vector3;
  20446. /**
  20447. * Gets the ray "start point" of the ray in the world
  20448. */
  20449. readonly rayFromWorld: Vector3;
  20450. /**
  20451. * Gets the ray "end point" of the ray in the world
  20452. */
  20453. readonly rayToWorld: Vector3;
  20454. /**
  20455. * Sets the hit data (normal & point in world space)
  20456. * @param hitNormalWorld defines the normal in world space
  20457. * @param hitPointWorld defines the point in world space
  20458. */
  20459. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20460. /**
  20461. * Sets the distance from the start point to the hit point
  20462. * @param distance
  20463. */
  20464. setHitDistance(distance: number): void;
  20465. /**
  20466. * Calculates the distance manually
  20467. */
  20468. calculateHitDistance(): void;
  20469. /**
  20470. * Resets all the values to default
  20471. * @param from The from point on world space
  20472. * @param to The to point on world space
  20473. */
  20474. reset(from?: Vector3, to?: Vector3): void;
  20475. }
  20476. /**
  20477. * Interface for the size containing width and height
  20478. */
  20479. interface IXYZ {
  20480. /**
  20481. * X
  20482. */
  20483. x: number;
  20484. /**
  20485. * Y
  20486. */
  20487. y: number;
  20488. /**
  20489. * Z
  20490. */
  20491. z: number;
  20492. }
  20493. }
  20494. declare module "babylonjs/Physics/IPhysicsEngine" {
  20495. import { Nullable } from "babylonjs/types";
  20496. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20498. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20499. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20500. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20501. /**
  20502. * Interface used to describe a physics joint
  20503. */
  20504. export interface PhysicsImpostorJoint {
  20505. /** Defines the main impostor to which the joint is linked */
  20506. mainImpostor: PhysicsImpostor;
  20507. /** Defines the impostor that is connected to the main impostor using this joint */
  20508. connectedImpostor: PhysicsImpostor;
  20509. /** Defines the joint itself */
  20510. joint: PhysicsJoint;
  20511. }
  20512. /** @hidden */
  20513. export interface IPhysicsEnginePlugin {
  20514. world: any;
  20515. name: string;
  20516. setGravity(gravity: Vector3): void;
  20517. setTimeStep(timeStep: number): void;
  20518. getTimeStep(): number;
  20519. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20520. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20521. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20522. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20523. removePhysicsBody(impostor: PhysicsImpostor): void;
  20524. generateJoint(joint: PhysicsImpostorJoint): void;
  20525. removeJoint(joint: PhysicsImpostorJoint): void;
  20526. isSupported(): boolean;
  20527. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20528. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20529. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20530. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20531. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20532. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20533. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20534. getBodyMass(impostor: PhysicsImpostor): number;
  20535. getBodyFriction(impostor: PhysicsImpostor): number;
  20536. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20537. getBodyRestitution(impostor: PhysicsImpostor): number;
  20538. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20539. getBodyPressure?(impostor: PhysicsImpostor): number;
  20540. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20541. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20542. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20543. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20544. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20545. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20546. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20547. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20548. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20549. sleepBody(impostor: PhysicsImpostor): void;
  20550. wakeUpBody(impostor: PhysicsImpostor): void;
  20551. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20552. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20553. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20554. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20555. getRadius(impostor: PhysicsImpostor): number;
  20556. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20557. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20558. dispose(): void;
  20559. }
  20560. /**
  20561. * Interface used to define a physics engine
  20562. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20563. */
  20564. export interface IPhysicsEngine {
  20565. /**
  20566. * Gets the gravity vector used by the simulation
  20567. */
  20568. gravity: Vector3;
  20569. /**
  20570. * Sets the gravity vector used by the simulation
  20571. * @param gravity defines the gravity vector to use
  20572. */
  20573. setGravity(gravity: Vector3): void;
  20574. /**
  20575. * Set the time step of the physics engine.
  20576. * Default is 1/60.
  20577. * To slow it down, enter 1/600 for example.
  20578. * To speed it up, 1/30
  20579. * @param newTimeStep the new timestep to apply to this world.
  20580. */
  20581. setTimeStep(newTimeStep: number): void;
  20582. /**
  20583. * Get the time step of the physics engine.
  20584. * @returns the current time step
  20585. */
  20586. getTimeStep(): number;
  20587. /**
  20588. * Release all resources
  20589. */
  20590. dispose(): void;
  20591. /**
  20592. * Gets the name of the current physics plugin
  20593. * @returns the name of the plugin
  20594. */
  20595. getPhysicsPluginName(): string;
  20596. /**
  20597. * Adding a new impostor for the impostor tracking.
  20598. * This will be done by the impostor itself.
  20599. * @param impostor the impostor to add
  20600. */
  20601. addImpostor(impostor: PhysicsImpostor): void;
  20602. /**
  20603. * Remove an impostor from the engine.
  20604. * This impostor and its mesh will not longer be updated by the physics engine.
  20605. * @param impostor the impostor to remove
  20606. */
  20607. removeImpostor(impostor: PhysicsImpostor): void;
  20608. /**
  20609. * Add a joint to the physics engine
  20610. * @param mainImpostor defines the main impostor to which the joint is added.
  20611. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20612. * @param joint defines the joint that will connect both impostors.
  20613. */
  20614. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20615. /**
  20616. * Removes a joint from the simulation
  20617. * @param mainImpostor defines the impostor used with the joint
  20618. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20619. * @param joint defines the joint to remove
  20620. */
  20621. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20622. /**
  20623. * Gets the current plugin used to run the simulation
  20624. * @returns current plugin
  20625. */
  20626. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20627. /**
  20628. * Gets the list of physic impostors
  20629. * @returns an array of PhysicsImpostor
  20630. */
  20631. getImpostors(): Array<PhysicsImpostor>;
  20632. /**
  20633. * Gets the impostor for a physics enabled object
  20634. * @param object defines the object impersonated by the impostor
  20635. * @returns the PhysicsImpostor or null if not found
  20636. */
  20637. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20638. /**
  20639. * Gets the impostor for a physics body object
  20640. * @param body defines physics body used by the impostor
  20641. * @returns the PhysicsImpostor or null if not found
  20642. */
  20643. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20644. /**
  20645. * Does a raycast in the physics world
  20646. * @param from when should the ray start?
  20647. * @param to when should the ray end?
  20648. * @returns PhysicsRaycastResult
  20649. */
  20650. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20651. /**
  20652. * Called by the scene. No need to call it.
  20653. * @param delta defines the timespam between frames
  20654. */
  20655. _step(delta: number): void;
  20656. }
  20657. }
  20658. declare module "babylonjs/Physics/physicsImpostor" {
  20659. import { Nullable, IndicesArray } from "babylonjs/types";
  20660. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20661. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20663. import { Scene } from "babylonjs/scene";
  20664. import { Bone } from "babylonjs/Bones/bone";
  20665. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20666. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20667. /**
  20668. * The interface for the physics imposter parameters
  20669. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20670. */
  20671. export interface PhysicsImpostorParameters {
  20672. /**
  20673. * The mass of the physics imposter
  20674. */
  20675. mass: number;
  20676. /**
  20677. * The friction of the physics imposter
  20678. */
  20679. friction?: number;
  20680. /**
  20681. * The coefficient of restitution of the physics imposter
  20682. */
  20683. restitution?: number;
  20684. /**
  20685. * The native options of the physics imposter
  20686. */
  20687. nativeOptions?: any;
  20688. /**
  20689. * Specifies if the parent should be ignored
  20690. */
  20691. ignoreParent?: boolean;
  20692. /**
  20693. * Specifies if bi-directional transformations should be disabled
  20694. */
  20695. disableBidirectionalTransformation?: boolean;
  20696. /**
  20697. * The pressure inside the physics imposter, soft object only
  20698. */
  20699. pressure?: number;
  20700. /**
  20701. * The stiffness the physics imposter, soft object only
  20702. */
  20703. stiffness?: number;
  20704. /**
  20705. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20706. */
  20707. velocityIterations?: number;
  20708. /**
  20709. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20710. */
  20711. positionIterations?: number;
  20712. /**
  20713. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20714. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20715. * Add to fix multiple points
  20716. */
  20717. fixedPoints?: number;
  20718. /**
  20719. * The collision margin around a soft object
  20720. */
  20721. margin?: number;
  20722. /**
  20723. * The collision margin around a soft object
  20724. */
  20725. damping?: number;
  20726. /**
  20727. * The path for a rope based on an extrusion
  20728. */
  20729. path?: any;
  20730. /**
  20731. * The shape of an extrusion used for a rope based on an extrusion
  20732. */
  20733. shape?: any;
  20734. }
  20735. /**
  20736. * Interface for a physics-enabled object
  20737. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20738. */
  20739. export interface IPhysicsEnabledObject {
  20740. /**
  20741. * The position of the physics-enabled object
  20742. */
  20743. position: Vector3;
  20744. /**
  20745. * The rotation of the physics-enabled object
  20746. */
  20747. rotationQuaternion: Nullable<Quaternion>;
  20748. /**
  20749. * The scale of the physics-enabled object
  20750. */
  20751. scaling: Vector3;
  20752. /**
  20753. * The rotation of the physics-enabled object
  20754. */
  20755. rotation?: Vector3;
  20756. /**
  20757. * The parent of the physics-enabled object
  20758. */
  20759. parent?: any;
  20760. /**
  20761. * The bounding info of the physics-enabled object
  20762. * @returns The bounding info of the physics-enabled object
  20763. */
  20764. getBoundingInfo(): BoundingInfo;
  20765. /**
  20766. * Computes the world matrix
  20767. * @param force Specifies if the world matrix should be computed by force
  20768. * @returns A world matrix
  20769. */
  20770. computeWorldMatrix(force: boolean): Matrix;
  20771. /**
  20772. * Gets the world matrix
  20773. * @returns A world matrix
  20774. */
  20775. getWorldMatrix?(): Matrix;
  20776. /**
  20777. * Gets the child meshes
  20778. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20779. * @returns An array of abstract meshes
  20780. */
  20781. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20782. /**
  20783. * Gets the vertex data
  20784. * @param kind The type of vertex data
  20785. * @returns A nullable array of numbers, or a float32 array
  20786. */
  20787. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20788. /**
  20789. * Gets the indices from the mesh
  20790. * @returns A nullable array of index arrays
  20791. */
  20792. getIndices?(): Nullable<IndicesArray>;
  20793. /**
  20794. * Gets the scene from the mesh
  20795. * @returns the indices array or null
  20796. */
  20797. getScene?(): Scene;
  20798. /**
  20799. * Gets the absolute position from the mesh
  20800. * @returns the absolute position
  20801. */
  20802. getAbsolutePosition(): Vector3;
  20803. /**
  20804. * Gets the absolute pivot point from the mesh
  20805. * @returns the absolute pivot point
  20806. */
  20807. getAbsolutePivotPoint(): Vector3;
  20808. /**
  20809. * Rotates the mesh
  20810. * @param axis The axis of rotation
  20811. * @param amount The amount of rotation
  20812. * @param space The space of the rotation
  20813. * @returns The rotation transform node
  20814. */
  20815. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20816. /**
  20817. * Translates the mesh
  20818. * @param axis The axis of translation
  20819. * @param distance The distance of translation
  20820. * @param space The space of the translation
  20821. * @returns The transform node
  20822. */
  20823. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20824. /**
  20825. * Sets the absolute position of the mesh
  20826. * @param absolutePosition The absolute position of the mesh
  20827. * @returns The transform node
  20828. */
  20829. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20830. /**
  20831. * Gets the class name of the mesh
  20832. * @returns The class name
  20833. */
  20834. getClassName(): string;
  20835. }
  20836. /**
  20837. * Represents a physics imposter
  20838. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20839. */
  20840. export class PhysicsImpostor {
  20841. /**
  20842. * The physics-enabled object used as the physics imposter
  20843. */
  20844. object: IPhysicsEnabledObject;
  20845. /**
  20846. * The type of the physics imposter
  20847. */
  20848. type: number;
  20849. private _options;
  20850. private _scene?;
  20851. /**
  20852. * The default object size of the imposter
  20853. */
  20854. static DEFAULT_OBJECT_SIZE: Vector3;
  20855. /**
  20856. * The identity quaternion of the imposter
  20857. */
  20858. static IDENTITY_QUATERNION: Quaternion;
  20859. /** @hidden */
  20860. _pluginData: any;
  20861. private _physicsEngine;
  20862. private _physicsBody;
  20863. private _bodyUpdateRequired;
  20864. private _onBeforePhysicsStepCallbacks;
  20865. private _onAfterPhysicsStepCallbacks;
  20866. /** @hidden */
  20867. _onPhysicsCollideCallbacks: Array<{
  20868. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20869. otherImpostors: Array<PhysicsImpostor>;
  20870. }>;
  20871. private _deltaPosition;
  20872. private _deltaRotation;
  20873. private _deltaRotationConjugated;
  20874. /** hidden */
  20875. _isFromLine: boolean;
  20876. private _parent;
  20877. private _isDisposed;
  20878. private static _tmpVecs;
  20879. private static _tmpQuat;
  20880. /**
  20881. * Specifies if the physics imposter is disposed
  20882. */
  20883. readonly isDisposed: boolean;
  20884. /**
  20885. * Gets the mass of the physics imposter
  20886. */
  20887. mass: number;
  20888. /**
  20889. * Gets the coefficient of friction
  20890. */
  20891. /**
  20892. * Sets the coefficient of friction
  20893. */
  20894. friction: number;
  20895. /**
  20896. * Gets the coefficient of restitution
  20897. */
  20898. /**
  20899. * Sets the coefficient of restitution
  20900. */
  20901. restitution: number;
  20902. /**
  20903. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20904. */
  20905. /**
  20906. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20907. */
  20908. pressure: number;
  20909. /**
  20910. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20911. */
  20912. /**
  20913. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20914. */
  20915. stiffness: number;
  20916. /**
  20917. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20918. */
  20919. /**
  20920. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20921. */
  20922. velocityIterations: number;
  20923. /**
  20924. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20925. */
  20926. /**
  20927. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20928. */
  20929. positionIterations: number;
  20930. /**
  20931. * The unique id of the physics imposter
  20932. * set by the physics engine when adding this impostor to the array
  20933. */
  20934. uniqueId: number;
  20935. /**
  20936. * @hidden
  20937. */
  20938. soft: boolean;
  20939. /**
  20940. * @hidden
  20941. */
  20942. segments: number;
  20943. private _joints;
  20944. /**
  20945. * Initializes the physics imposter
  20946. * @param object The physics-enabled object used as the physics imposter
  20947. * @param type The type of the physics imposter
  20948. * @param _options The options for the physics imposter
  20949. * @param _scene The Babylon scene
  20950. */
  20951. constructor(
  20952. /**
  20953. * The physics-enabled object used as the physics imposter
  20954. */
  20955. object: IPhysicsEnabledObject,
  20956. /**
  20957. * The type of the physics imposter
  20958. */
  20959. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20960. /**
  20961. * This function will completly initialize this impostor.
  20962. * It will create a new body - but only if this mesh has no parent.
  20963. * If it has, this impostor will not be used other than to define the impostor
  20964. * of the child mesh.
  20965. * @hidden
  20966. */
  20967. _init(): void;
  20968. private _getPhysicsParent;
  20969. /**
  20970. * Should a new body be generated.
  20971. * @returns boolean specifying if body initialization is required
  20972. */
  20973. isBodyInitRequired(): boolean;
  20974. /**
  20975. * Sets the updated scaling
  20976. * @param updated Specifies if the scaling is updated
  20977. */
  20978. setScalingUpdated(): void;
  20979. /**
  20980. * Force a regeneration of this or the parent's impostor's body.
  20981. * Use under cautious - This will remove all joints already implemented.
  20982. */
  20983. forceUpdate(): void;
  20984. /**
  20985. * Gets the body that holds this impostor. Either its own, or its parent.
  20986. */
  20987. /**
  20988. * Set the physics body. Used mainly by the physics engine/plugin
  20989. */
  20990. physicsBody: any;
  20991. /**
  20992. * Get the parent of the physics imposter
  20993. * @returns Physics imposter or null
  20994. */
  20995. /**
  20996. * Sets the parent of the physics imposter
  20997. */
  20998. parent: Nullable<PhysicsImpostor>;
  20999. /**
  21000. * Resets the update flags
  21001. */
  21002. resetUpdateFlags(): void;
  21003. /**
  21004. * Gets the object extend size
  21005. * @returns the object extend size
  21006. */
  21007. getObjectExtendSize(): Vector3;
  21008. /**
  21009. * Gets the object center
  21010. * @returns The object center
  21011. */
  21012. getObjectCenter(): Vector3;
  21013. /**
  21014. * Get a specific parametes from the options parameter
  21015. * @param paramName The object parameter name
  21016. * @returns The object parameter
  21017. */
  21018. getParam(paramName: string): any;
  21019. /**
  21020. * Sets a specific parameter in the options given to the physics plugin
  21021. * @param paramName The parameter name
  21022. * @param value The value of the parameter
  21023. */
  21024. setParam(paramName: string, value: number): void;
  21025. /**
  21026. * Specifically change the body's mass option. Won't recreate the physics body object
  21027. * @param mass The mass of the physics imposter
  21028. */
  21029. setMass(mass: number): void;
  21030. /**
  21031. * Gets the linear velocity
  21032. * @returns linear velocity or null
  21033. */
  21034. getLinearVelocity(): Nullable<Vector3>;
  21035. /**
  21036. * Sets the linear velocity
  21037. * @param velocity linear velocity or null
  21038. */
  21039. setLinearVelocity(velocity: Nullable<Vector3>): void;
  21040. /**
  21041. * Gets the angular velocity
  21042. * @returns angular velocity or null
  21043. */
  21044. getAngularVelocity(): Nullable<Vector3>;
  21045. /**
  21046. * Sets the angular velocity
  21047. * @param velocity The velocity or null
  21048. */
  21049. setAngularVelocity(velocity: Nullable<Vector3>): void;
  21050. /**
  21051. * Execute a function with the physics plugin native code
  21052. * Provide a function the will have two variables - the world object and the physics body object
  21053. * @param func The function to execute with the physics plugin native code
  21054. */
  21055. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  21056. /**
  21057. * Register a function that will be executed before the physics world is stepping forward
  21058. * @param func The function to execute before the physics world is stepped forward
  21059. */
  21060. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21061. /**
  21062. * Unregister a function that will be executed before the physics world is stepping forward
  21063. * @param func The function to execute before the physics world is stepped forward
  21064. */
  21065. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21066. /**
  21067. * Register a function that will be executed after the physics step
  21068. * @param func The function to execute after physics step
  21069. */
  21070. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21071. /**
  21072. * Unregisters a function that will be executed after the physics step
  21073. * @param func The function to execute after physics step
  21074. */
  21075. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21076. /**
  21077. * register a function that will be executed when this impostor collides against a different body
  21078. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  21079. * @param func Callback that is executed on collision
  21080. */
  21081. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  21082. /**
  21083. * Unregisters the physics imposter on contact
  21084. * @param collideAgainst The physics object to collide against
  21085. * @param func Callback to execute on collision
  21086. */
  21087. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  21088. private _tmpQuat;
  21089. private _tmpQuat2;
  21090. /**
  21091. * Get the parent rotation
  21092. * @returns The parent rotation
  21093. */
  21094. getParentsRotation(): Quaternion;
  21095. /**
  21096. * this function is executed by the physics engine.
  21097. */
  21098. beforeStep: () => void;
  21099. /**
  21100. * this function is executed by the physics engine
  21101. */
  21102. afterStep: () => void;
  21103. /**
  21104. * Legacy collision detection event support
  21105. */
  21106. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  21107. /**
  21108. * event and body object due to cannon's event-based architecture.
  21109. */
  21110. onCollide: (e: {
  21111. body: any;
  21112. }) => void;
  21113. /**
  21114. * Apply a force
  21115. * @param force The force to apply
  21116. * @param contactPoint The contact point for the force
  21117. * @returns The physics imposter
  21118. */
  21119. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21120. /**
  21121. * Apply an impulse
  21122. * @param force The impulse force
  21123. * @param contactPoint The contact point for the impulse force
  21124. * @returns The physics imposter
  21125. */
  21126. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21127. /**
  21128. * A help function to create a joint
  21129. * @param otherImpostor A physics imposter used to create a joint
  21130. * @param jointType The type of joint
  21131. * @param jointData The data for the joint
  21132. * @returns The physics imposter
  21133. */
  21134. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  21135. /**
  21136. * Add a joint to this impostor with a different impostor
  21137. * @param otherImpostor A physics imposter used to add a joint
  21138. * @param joint The joint to add
  21139. * @returns The physics imposter
  21140. */
  21141. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  21142. /**
  21143. * Add an anchor to a cloth impostor
  21144. * @param otherImpostor rigid impostor to anchor to
  21145. * @param width ratio across width from 0 to 1
  21146. * @param height ratio up height from 0 to 1
  21147. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  21148. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  21149. * @returns impostor the soft imposter
  21150. */
  21151. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21152. /**
  21153. * Add a hook to a rope impostor
  21154. * @param otherImpostor rigid impostor to anchor to
  21155. * @param length ratio across rope from 0 to 1
  21156. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  21157. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  21158. * @returns impostor the rope imposter
  21159. */
  21160. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21161. /**
  21162. * Will keep this body still, in a sleep mode.
  21163. * @returns the physics imposter
  21164. */
  21165. sleep(): PhysicsImpostor;
  21166. /**
  21167. * Wake the body up.
  21168. * @returns The physics imposter
  21169. */
  21170. wakeUp(): PhysicsImpostor;
  21171. /**
  21172. * Clones the physics imposter
  21173. * @param newObject The physics imposter clones to this physics-enabled object
  21174. * @returns A nullable physics imposter
  21175. */
  21176. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  21177. /**
  21178. * Disposes the physics imposter
  21179. */
  21180. dispose(): void;
  21181. /**
  21182. * Sets the delta position
  21183. * @param position The delta position amount
  21184. */
  21185. setDeltaPosition(position: Vector3): void;
  21186. /**
  21187. * Sets the delta rotation
  21188. * @param rotation The delta rotation amount
  21189. */
  21190. setDeltaRotation(rotation: Quaternion): void;
  21191. /**
  21192. * Gets the box size of the physics imposter and stores the result in the input parameter
  21193. * @param result Stores the box size
  21194. * @returns The physics imposter
  21195. */
  21196. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  21197. /**
  21198. * Gets the radius of the physics imposter
  21199. * @returns Radius of the physics imposter
  21200. */
  21201. getRadius(): number;
  21202. /**
  21203. * Sync a bone with this impostor
  21204. * @param bone The bone to sync to the impostor.
  21205. * @param boneMesh The mesh that the bone is influencing.
  21206. * @param jointPivot The pivot of the joint / bone in local space.
  21207. * @param distToJoint Optional distance from the impostor to the joint.
  21208. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21209. */
  21210. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  21211. /**
  21212. * Sync impostor to a bone
  21213. * @param bone The bone that the impostor will be synced to.
  21214. * @param boneMesh The mesh that the bone is influencing.
  21215. * @param jointPivot The pivot of the joint / bone in local space.
  21216. * @param distToJoint Optional distance from the impostor to the joint.
  21217. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21218. * @param boneAxis Optional vector3 axis the bone is aligned with
  21219. */
  21220. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  21221. /**
  21222. * No-Imposter type
  21223. */
  21224. static NoImpostor: number;
  21225. /**
  21226. * Sphere-Imposter type
  21227. */
  21228. static SphereImpostor: number;
  21229. /**
  21230. * Box-Imposter type
  21231. */
  21232. static BoxImpostor: number;
  21233. /**
  21234. * Plane-Imposter type
  21235. */
  21236. static PlaneImpostor: number;
  21237. /**
  21238. * Mesh-imposter type
  21239. */
  21240. static MeshImpostor: number;
  21241. /**
  21242. * Cylinder-Imposter type
  21243. */
  21244. static CylinderImpostor: number;
  21245. /**
  21246. * Particle-Imposter type
  21247. */
  21248. static ParticleImpostor: number;
  21249. /**
  21250. * Heightmap-Imposter type
  21251. */
  21252. static HeightmapImpostor: number;
  21253. /**
  21254. * ConvexHull-Impostor type (Ammo.js plugin only)
  21255. */
  21256. static ConvexHullImpostor: number;
  21257. /**
  21258. * Rope-Imposter type
  21259. */
  21260. static RopeImpostor: number;
  21261. /**
  21262. * Cloth-Imposter type
  21263. */
  21264. static ClothImpostor: number;
  21265. /**
  21266. * Softbody-Imposter type
  21267. */
  21268. static SoftbodyImpostor: number;
  21269. }
  21270. }
  21271. declare module "babylonjs/Meshes/mesh" {
  21272. import { Observable } from "babylonjs/Misc/observable";
  21273. import { IAnimatable } from "babylonjs/Misc/tools";
  21274. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21275. import { Camera } from "babylonjs/Cameras/camera";
  21276. import { Scene } from "babylonjs/scene";
  21277. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  21278. import { Engine } from "babylonjs/Engines/engine";
  21279. import { Node } from "babylonjs/node";
  21280. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21281. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  21282. import { Buffer } from "babylonjs/Meshes/buffer";
  21283. import { Geometry } from "babylonjs/Meshes/geometry";
  21284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21285. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21286. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  21287. import { Effect } from "babylonjs/Materials/effect";
  21288. import { Material } from "babylonjs/Materials/material";
  21289. import { Skeleton } from "babylonjs/Bones/skeleton";
  21290. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  21291. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  21292. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  21293. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  21294. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  21295. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  21296. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  21297. /**
  21298. * @hidden
  21299. **/
  21300. export class _CreationDataStorage {
  21301. closePath?: boolean;
  21302. closeArray?: boolean;
  21303. idx: number[];
  21304. dashSize: number;
  21305. gapSize: number;
  21306. path3D: Path3D;
  21307. pathArray: Vector3[][];
  21308. arc: number;
  21309. radius: number;
  21310. cap: number;
  21311. tessellation: number;
  21312. }
  21313. /**
  21314. * @hidden
  21315. **/
  21316. class _InstanceDataStorage {
  21317. visibleInstances: any;
  21318. batchCache: _InstancesBatch;
  21319. instancesBufferSize: number;
  21320. instancesBuffer: Nullable<Buffer>;
  21321. instancesData: Float32Array;
  21322. overridenInstanceCount: number;
  21323. isFrozen: boolean;
  21324. previousBatch: _InstancesBatch;
  21325. hardwareInstancedRendering: boolean;
  21326. sideOrientation: number;
  21327. }
  21328. /**
  21329. * @hidden
  21330. **/
  21331. export class _InstancesBatch {
  21332. mustReturn: boolean;
  21333. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  21334. renderSelf: boolean[];
  21335. hardwareInstancedRendering: boolean[];
  21336. }
  21337. /**
  21338. * Class used to represent renderable models
  21339. */
  21340. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21341. /**
  21342. * Mesh side orientation : usually the external or front surface
  21343. */
  21344. static readonly FRONTSIDE: number;
  21345. /**
  21346. * Mesh side orientation : usually the internal or back surface
  21347. */
  21348. static readonly BACKSIDE: number;
  21349. /**
  21350. * Mesh side orientation : both internal and external or front and back surfaces
  21351. */
  21352. static readonly DOUBLESIDE: number;
  21353. /**
  21354. * Mesh side orientation : by default, `FRONTSIDE`
  21355. */
  21356. static readonly DEFAULTSIDE: number;
  21357. /**
  21358. * Mesh cap setting : no cap
  21359. */
  21360. static readonly NO_CAP: number;
  21361. /**
  21362. * Mesh cap setting : one cap at the beginning of the mesh
  21363. */
  21364. static readonly CAP_START: number;
  21365. /**
  21366. * Mesh cap setting : one cap at the end of the mesh
  21367. */
  21368. static readonly CAP_END: number;
  21369. /**
  21370. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21371. */
  21372. static readonly CAP_ALL: number;
  21373. /**
  21374. * Gets the default side orientation.
  21375. * @param orientation the orientation to value to attempt to get
  21376. * @returns the default orientation
  21377. * @hidden
  21378. */
  21379. static _GetDefaultSideOrientation(orientation?: number): number;
  21380. private _onBeforeRenderObservable;
  21381. private _onBeforeBindObservable;
  21382. private _onAfterRenderObservable;
  21383. private _onBeforeDrawObservable;
  21384. /**
  21385. * An event triggered before rendering the mesh
  21386. */
  21387. readonly onBeforeRenderObservable: Observable<Mesh>;
  21388. /**
  21389. * An event triggered before binding the mesh
  21390. */
  21391. readonly onBeforeBindObservable: Observable<Mesh>;
  21392. /**
  21393. * An event triggered after rendering the mesh
  21394. */
  21395. readonly onAfterRenderObservable: Observable<Mesh>;
  21396. /**
  21397. * An event triggered before drawing the mesh
  21398. */
  21399. readonly onBeforeDrawObservable: Observable<Mesh>;
  21400. private _onBeforeDrawObserver;
  21401. /**
  21402. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  21403. */
  21404. onBeforeDraw: () => void;
  21405. /**
  21406. * Gets the delay loading state of the mesh (when delay loading is turned on)
  21407. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  21408. */
  21409. delayLoadState: number;
  21410. /**
  21411. * Gets the list of instances created from this mesh
  21412. * it is not supposed to be modified manually.
  21413. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  21414. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21415. */
  21416. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  21417. /**
  21418. * Gets the file containing delay loading data for this mesh
  21419. */
  21420. delayLoadingFile: string;
  21421. /** @hidden */
  21422. _binaryInfo: any;
  21423. private _LODLevels;
  21424. /**
  21425. * User defined function used to change how LOD level selection is done
  21426. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21427. */
  21428. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21429. private _morphTargetManager;
  21430. /**
  21431. * Gets or sets the morph target manager
  21432. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21433. */
  21434. morphTargetManager: Nullable<MorphTargetManager>;
  21435. /** @hidden */
  21436. _creationDataStorage: Nullable<_CreationDataStorage>;
  21437. /** @hidden */
  21438. _geometry: Nullable<Geometry>;
  21439. /** @hidden */
  21440. _delayInfo: Array<string>;
  21441. /** @hidden */
  21442. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21443. /** @hidden */
  21444. _instanceDataStorage: _InstanceDataStorage;
  21445. private _effectiveMaterial;
  21446. /** @hidden */
  21447. _shouldGenerateFlatShading: boolean;
  21448. private _preActivateId;
  21449. /** @hidden */
  21450. _originalBuilderSideOrientation: number;
  21451. /**
  21452. * Use this property to change the original side orientation defined at construction time
  21453. */
  21454. overrideMaterialSideOrientation: Nullable<number>;
  21455. private _areNormalsFrozen;
  21456. private _sourcePositions;
  21457. private _sourceNormals;
  21458. private _source;
  21459. private meshMap;
  21460. /**
  21461. * Gets the source mesh (the one used to clone this one from)
  21462. */
  21463. readonly source: Nullable<Mesh>;
  21464. /**
  21465. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21466. */
  21467. isUnIndexed: boolean;
  21468. /**
  21469. * @constructor
  21470. * @param name The value used by scene.getMeshByName() to do a lookup.
  21471. * @param scene The scene to add this mesh to.
  21472. * @param parent The parent of this mesh, if it has one
  21473. * @param source An optional Mesh from which geometry is shared, cloned.
  21474. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21475. * When false, achieved by calling a clone(), also passing False.
  21476. * This will make creation of children, recursive.
  21477. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21478. */
  21479. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21480. /**
  21481. * Gets the class name
  21482. * @returns the string "Mesh".
  21483. */
  21484. getClassName(): string;
  21485. /** @hidden */
  21486. readonly _isMesh: boolean;
  21487. /**
  21488. * Returns a description of this mesh
  21489. * @param fullDetails define if full details about this mesh must be used
  21490. * @returns a descriptive string representing this mesh
  21491. */
  21492. toString(fullDetails?: boolean): string;
  21493. /** @hidden */
  21494. _unBindEffect(): void;
  21495. /**
  21496. * Gets a boolean indicating if this mesh has LOD
  21497. */
  21498. readonly hasLODLevels: boolean;
  21499. /**
  21500. * Gets the list of MeshLODLevel associated with the current mesh
  21501. * @returns an array of MeshLODLevel
  21502. */
  21503. getLODLevels(): MeshLODLevel[];
  21504. private _sortLODLevels;
  21505. /**
  21506. * Add a mesh as LOD level triggered at the given distance.
  21507. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21508. * @param distance The distance from the center of the object to show this level
  21509. * @param mesh The mesh to be added as LOD level (can be null)
  21510. * @return This mesh (for chaining)
  21511. */
  21512. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21513. /**
  21514. * Returns the LOD level mesh at the passed distance or null if not found.
  21515. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21516. * @param distance The distance from the center of the object to show this level
  21517. * @returns a Mesh or `null`
  21518. */
  21519. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21520. /**
  21521. * Remove a mesh from the LOD array
  21522. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21523. * @param mesh defines the mesh to be removed
  21524. * @return This mesh (for chaining)
  21525. */
  21526. removeLODLevel(mesh: Mesh): Mesh;
  21527. /**
  21528. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21529. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21530. * @param camera defines the camera to use to compute distance
  21531. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21532. * @return This mesh (for chaining)
  21533. */
  21534. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21535. /**
  21536. * Gets the mesh internal Geometry object
  21537. */
  21538. readonly geometry: Nullable<Geometry>;
  21539. /**
  21540. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21541. * @returns the total number of vertices
  21542. */
  21543. getTotalVertices(): number;
  21544. /**
  21545. * Returns the content of an associated vertex buffer
  21546. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21547. * - VertexBuffer.PositionKind
  21548. * - VertexBuffer.UVKind
  21549. * - VertexBuffer.UV2Kind
  21550. * - VertexBuffer.UV3Kind
  21551. * - VertexBuffer.UV4Kind
  21552. * - VertexBuffer.UV5Kind
  21553. * - VertexBuffer.UV6Kind
  21554. * - VertexBuffer.ColorKind
  21555. * - VertexBuffer.MatricesIndicesKind
  21556. * - VertexBuffer.MatricesIndicesExtraKind
  21557. * - VertexBuffer.MatricesWeightsKind
  21558. * - VertexBuffer.MatricesWeightsExtraKind
  21559. * @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
  21560. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21561. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21562. */
  21563. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21564. /**
  21565. * Returns the mesh VertexBuffer object from the requested `kind`
  21566. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21567. * - VertexBuffer.PositionKind
  21568. * - VertexBuffer.UVKind
  21569. * - VertexBuffer.UV2Kind
  21570. * - VertexBuffer.UV3Kind
  21571. * - VertexBuffer.UV4Kind
  21572. * - VertexBuffer.UV5Kind
  21573. * - VertexBuffer.UV6Kind
  21574. * - VertexBuffer.ColorKind
  21575. * - VertexBuffer.MatricesIndicesKind
  21576. * - VertexBuffer.MatricesIndicesExtraKind
  21577. * - VertexBuffer.MatricesWeightsKind
  21578. * - VertexBuffer.MatricesWeightsExtraKind
  21579. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21580. */
  21581. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21582. /**
  21583. * Tests if a specific vertex buffer is associated with this mesh
  21584. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21585. * - VertexBuffer.PositionKind
  21586. * - VertexBuffer.UVKind
  21587. * - VertexBuffer.UV2Kind
  21588. * - VertexBuffer.UV3Kind
  21589. * - VertexBuffer.UV4Kind
  21590. * - VertexBuffer.UV5Kind
  21591. * - VertexBuffer.UV6Kind
  21592. * - VertexBuffer.ColorKind
  21593. * - VertexBuffer.MatricesIndicesKind
  21594. * - VertexBuffer.MatricesIndicesExtraKind
  21595. * - VertexBuffer.MatricesWeightsKind
  21596. * - VertexBuffer.MatricesWeightsExtraKind
  21597. * @returns a boolean
  21598. */
  21599. isVerticesDataPresent(kind: string): boolean;
  21600. /**
  21601. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21602. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21603. * - VertexBuffer.PositionKind
  21604. * - VertexBuffer.UVKind
  21605. * - VertexBuffer.UV2Kind
  21606. * - VertexBuffer.UV3Kind
  21607. * - VertexBuffer.UV4Kind
  21608. * - VertexBuffer.UV5Kind
  21609. * - VertexBuffer.UV6Kind
  21610. * - VertexBuffer.ColorKind
  21611. * - VertexBuffer.MatricesIndicesKind
  21612. * - VertexBuffer.MatricesIndicesExtraKind
  21613. * - VertexBuffer.MatricesWeightsKind
  21614. * - VertexBuffer.MatricesWeightsExtraKind
  21615. * @returns a boolean
  21616. */
  21617. isVertexBufferUpdatable(kind: string): boolean;
  21618. /**
  21619. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21620. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21621. * - VertexBuffer.PositionKind
  21622. * - VertexBuffer.UVKind
  21623. * - VertexBuffer.UV2Kind
  21624. * - VertexBuffer.UV3Kind
  21625. * - VertexBuffer.UV4Kind
  21626. * - VertexBuffer.UV5Kind
  21627. * - VertexBuffer.UV6Kind
  21628. * - VertexBuffer.ColorKind
  21629. * - VertexBuffer.MatricesIndicesKind
  21630. * - VertexBuffer.MatricesIndicesExtraKind
  21631. * - VertexBuffer.MatricesWeightsKind
  21632. * - VertexBuffer.MatricesWeightsExtraKind
  21633. * @returns an array of strings
  21634. */
  21635. getVerticesDataKinds(): string[];
  21636. /**
  21637. * Returns a positive integer : the total number of indices in this mesh geometry.
  21638. * @returns the numner of indices or zero if the mesh has no geometry.
  21639. */
  21640. getTotalIndices(): number;
  21641. /**
  21642. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21643. * @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.
  21644. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21645. * @returns the indices array or an empty array if the mesh has no geometry
  21646. */
  21647. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21648. readonly isBlocked: boolean;
  21649. /**
  21650. * Determine if the current mesh is ready to be rendered
  21651. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21652. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21653. * @returns true if all associated assets are ready (material, textures, shaders)
  21654. */
  21655. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21656. /**
  21657. * 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.
  21658. */
  21659. readonly areNormalsFrozen: boolean;
  21660. /**
  21661. * 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.
  21662. * @returns the current mesh
  21663. */
  21664. freezeNormals(): Mesh;
  21665. /**
  21666. * 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
  21667. * @returns the current mesh
  21668. */
  21669. unfreezeNormals(): Mesh;
  21670. /**
  21671. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21672. */
  21673. overridenInstanceCount: number;
  21674. /** @hidden */
  21675. _preActivate(): Mesh;
  21676. /** @hidden */
  21677. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21678. /** @hidden */
  21679. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21680. /**
  21681. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21682. * This means the mesh underlying bounding box and sphere are recomputed.
  21683. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21684. * @returns the current mesh
  21685. */
  21686. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21687. /** @hidden */
  21688. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21689. /**
  21690. * This function will subdivide the mesh into multiple submeshes
  21691. * @param count defines the expected number of submeshes
  21692. */
  21693. subdivide(count: number): void;
  21694. /**
  21695. * Copy a FloatArray into a specific associated vertex buffer
  21696. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21697. * - VertexBuffer.PositionKind
  21698. * - VertexBuffer.UVKind
  21699. * - VertexBuffer.UV2Kind
  21700. * - VertexBuffer.UV3Kind
  21701. * - VertexBuffer.UV4Kind
  21702. * - VertexBuffer.UV5Kind
  21703. * - VertexBuffer.UV6Kind
  21704. * - VertexBuffer.ColorKind
  21705. * - VertexBuffer.MatricesIndicesKind
  21706. * - VertexBuffer.MatricesIndicesExtraKind
  21707. * - VertexBuffer.MatricesWeightsKind
  21708. * - VertexBuffer.MatricesWeightsExtraKind
  21709. * @param data defines the data source
  21710. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21711. * @param stride defines the data stride size (can be null)
  21712. * @returns the current mesh
  21713. */
  21714. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21715. /**
  21716. * Flags an associated vertex buffer as updatable
  21717. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21718. * - VertexBuffer.PositionKind
  21719. * - VertexBuffer.UVKind
  21720. * - VertexBuffer.UV2Kind
  21721. * - VertexBuffer.UV3Kind
  21722. * - VertexBuffer.UV4Kind
  21723. * - VertexBuffer.UV5Kind
  21724. * - VertexBuffer.UV6Kind
  21725. * - VertexBuffer.ColorKind
  21726. * - VertexBuffer.MatricesIndicesKind
  21727. * - VertexBuffer.MatricesIndicesExtraKind
  21728. * - VertexBuffer.MatricesWeightsKind
  21729. * - VertexBuffer.MatricesWeightsExtraKind
  21730. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21731. */
  21732. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21733. /**
  21734. * Sets the mesh global Vertex Buffer
  21735. * @param buffer defines the buffer to use
  21736. * @returns the current mesh
  21737. */
  21738. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21739. /**
  21740. * Update a specific associated vertex buffer
  21741. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21742. * - VertexBuffer.PositionKind
  21743. * - VertexBuffer.UVKind
  21744. * - VertexBuffer.UV2Kind
  21745. * - VertexBuffer.UV3Kind
  21746. * - VertexBuffer.UV4Kind
  21747. * - VertexBuffer.UV5Kind
  21748. * - VertexBuffer.UV6Kind
  21749. * - VertexBuffer.ColorKind
  21750. * - VertexBuffer.MatricesIndicesKind
  21751. * - VertexBuffer.MatricesIndicesExtraKind
  21752. * - VertexBuffer.MatricesWeightsKind
  21753. * - VertexBuffer.MatricesWeightsExtraKind
  21754. * @param data defines the data source
  21755. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21756. * @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)
  21757. * @returns the current mesh
  21758. */
  21759. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21760. /**
  21761. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21762. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21763. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21764. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21765. * @returns the current mesh
  21766. */
  21767. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21768. /**
  21769. * Creates a un-shared specific occurence of the geometry for the mesh.
  21770. * @returns the current mesh
  21771. */
  21772. makeGeometryUnique(): Mesh;
  21773. /**
  21774. * Set the index buffer of this mesh
  21775. * @param indices defines the source data
  21776. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21777. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21778. * @returns the current mesh
  21779. */
  21780. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21781. /**
  21782. * Update the current index buffer
  21783. * @param indices defines the source data
  21784. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21785. * @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)
  21786. * @returns the current mesh
  21787. */
  21788. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21789. /**
  21790. * Invert the geometry to move from a right handed system to a left handed one.
  21791. * @returns the current mesh
  21792. */
  21793. toLeftHanded(): Mesh;
  21794. /** @hidden */
  21795. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21796. /** @hidden */
  21797. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21798. /**
  21799. * Registers for this mesh a javascript function called just before the rendering process
  21800. * @param func defines the function to call before rendering this mesh
  21801. * @returns the current mesh
  21802. */
  21803. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21804. /**
  21805. * Disposes a previously registered javascript function called before the rendering
  21806. * @param func defines the function to remove
  21807. * @returns the current mesh
  21808. */
  21809. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21810. /**
  21811. * Registers for this mesh a javascript function called just after the rendering is complete
  21812. * @param func defines the function to call after rendering this mesh
  21813. * @returns the current mesh
  21814. */
  21815. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21816. /**
  21817. * Disposes a previously registered javascript function called after the rendering.
  21818. * @param func defines the function to remove
  21819. * @returns the current mesh
  21820. */
  21821. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21822. /** @hidden */
  21823. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21824. /** @hidden */
  21825. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21826. /** @hidden */
  21827. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21828. /** @hidden */
  21829. _freeze(): void;
  21830. /** @hidden */
  21831. _unFreeze(): void;
  21832. /**
  21833. * 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
  21834. * @param subMesh defines the subMesh to render
  21835. * @param enableAlphaMode defines if alpha mode can be changed
  21836. * @returns the current mesh
  21837. */
  21838. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21839. private _onBeforeDraw;
  21840. /**
  21841. * Renormalize the mesh and patch it up if there are no weights
  21842. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21843. * However in the case of zero weights then we set just a single influence to 1.
  21844. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21845. */
  21846. cleanMatrixWeights(): void;
  21847. private normalizeSkinFourWeights;
  21848. private normalizeSkinWeightsAndExtra;
  21849. /**
  21850. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21851. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21852. * the user know there was an issue with importing the mesh
  21853. * @returns a validation object with skinned, valid and report string
  21854. */
  21855. validateSkinning(): {
  21856. skinned: boolean;
  21857. valid: boolean;
  21858. report: string;
  21859. };
  21860. /** @hidden */
  21861. _checkDelayState(): Mesh;
  21862. private _queueLoad;
  21863. /**
  21864. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21865. * A mesh is in the frustum if its bounding box intersects the frustum
  21866. * @param frustumPlanes defines the frustum to test
  21867. * @returns true if the mesh is in the frustum planes
  21868. */
  21869. isInFrustum(frustumPlanes: Plane[]): boolean;
  21870. /**
  21871. * Sets the mesh material by the material or multiMaterial `id` property
  21872. * @param id is a string identifying the material or the multiMaterial
  21873. * @returns the current mesh
  21874. */
  21875. setMaterialByID(id: string): Mesh;
  21876. /**
  21877. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21878. * @returns an array of IAnimatable
  21879. */
  21880. getAnimatables(): IAnimatable[];
  21881. /**
  21882. * Modifies the mesh geometry according to the passed transformation matrix.
  21883. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21884. * The mesh normals are modified using the same transformation.
  21885. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21886. * @param transform defines the transform matrix to use
  21887. * @see http://doc.babylonjs.com/resources/baking_transformations
  21888. * @returns the current mesh
  21889. */
  21890. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21891. /**
  21892. * Modifies the mesh geometry according to its own current World Matrix.
  21893. * The mesh World Matrix is then reset.
  21894. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21895. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21896. * @see http://doc.babylonjs.com/resources/baking_transformations
  21897. * @returns the current mesh
  21898. */
  21899. bakeCurrentTransformIntoVertices(): Mesh;
  21900. /** @hidden */
  21901. readonly _positions: Nullable<Vector3[]>;
  21902. /** @hidden */
  21903. _resetPointsArrayCache(): Mesh;
  21904. /** @hidden */
  21905. _generatePointsArray(): boolean;
  21906. /**
  21907. * Returns a new Mesh object generated from the current mesh properties.
  21908. * This method must not get confused with createInstance()
  21909. * @param name is a string, the name given to the new mesh
  21910. * @param newParent can be any Node object (default `null`)
  21911. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21912. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21913. * @returns a new mesh
  21914. */
  21915. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21916. /**
  21917. * Releases resources associated with this mesh.
  21918. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21919. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21920. */
  21921. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21922. /**
  21923. * Modifies the mesh geometry according to a displacement map.
  21924. * 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.
  21925. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21926. * @param url is a string, the URL from the image file is to be downloaded.
  21927. * @param minHeight is the lower limit of the displacement.
  21928. * @param maxHeight is the upper limit of the displacement.
  21929. * @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.
  21930. * @param uvOffset is an optional vector2 used to offset UV.
  21931. * @param uvScale is an optional vector2 used to scale UV.
  21932. * @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.
  21933. * @returns the Mesh.
  21934. */
  21935. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21936. /**
  21937. * Modifies the mesh geometry according to a displacementMap buffer.
  21938. * 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.
  21939. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21940. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21941. * @param heightMapWidth is the width of the buffer image.
  21942. * @param heightMapHeight is the height of the buffer image.
  21943. * @param minHeight is the lower limit of the displacement.
  21944. * @param maxHeight is the upper limit of the displacement.
  21945. * @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.
  21946. * @param uvOffset is an optional vector2 used to offset UV.
  21947. * @param uvScale is an optional vector2 used to scale UV.
  21948. * @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.
  21949. * @returns the Mesh.
  21950. */
  21951. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21952. /**
  21953. * Modify the mesh to get a flat shading rendering.
  21954. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21955. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21956. * @returns current mesh
  21957. */
  21958. convertToFlatShadedMesh(): Mesh;
  21959. /**
  21960. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21961. * In other words, more vertices, no more indices and a single bigger VBO.
  21962. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21963. * @returns current mesh
  21964. */
  21965. convertToUnIndexedMesh(): Mesh;
  21966. /**
  21967. * Inverses facet orientations.
  21968. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21969. * @param flipNormals will also inverts the normals
  21970. * @returns current mesh
  21971. */
  21972. flipFaces(flipNormals?: boolean): Mesh;
  21973. /**
  21974. * Increase the number of facets and hence vertices in a mesh
  21975. * Vertex normals are interpolated from existing vertex normals
  21976. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21977. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21978. */
  21979. increaseVertices(numberPerEdge: number): void;
  21980. /**
  21981. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21982. * This will undo any application of covertToFlatShadedMesh
  21983. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21984. */
  21985. forceSharedVertices(): void;
  21986. /** @hidden */
  21987. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21988. /** @hidden */
  21989. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21990. /**
  21991. * Creates a new InstancedMesh object from the mesh model.
  21992. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21993. * @param name defines the name of the new instance
  21994. * @returns a new InstancedMesh
  21995. */
  21996. createInstance(name: string): InstancedMesh;
  21997. /**
  21998. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21999. * After this call, all the mesh instances have the same submeshes than the current mesh.
  22000. * @returns the current mesh
  22001. */
  22002. synchronizeInstances(): Mesh;
  22003. /**
  22004. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  22005. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  22006. * This should be used together with the simplification to avoid disappearing triangles.
  22007. * @param successCallback an optional success callback to be called after the optimization finished.
  22008. * @returns the current mesh
  22009. */
  22010. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  22011. /**
  22012. * Serialize current mesh
  22013. * @param serializationObject defines the object which will receive the serialization data
  22014. */
  22015. serialize(serializationObject: any): void;
  22016. /** @hidden */
  22017. _syncGeometryWithMorphTargetManager(): void;
  22018. /** @hidden */
  22019. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  22020. /**
  22021. * Returns a new Mesh object parsed from the source provided.
  22022. * @param parsedMesh is the source
  22023. * @param scene defines the hosting scene
  22024. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  22025. * @returns a new Mesh
  22026. */
  22027. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  22028. /**
  22029. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  22030. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22031. * @param name defines the name of the mesh to create
  22032. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  22033. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  22034. * @param closePath creates a seam between the first and the last points of each path of the path array
  22035. * @param offset is taken in account only if the `pathArray` is containing a single path
  22036. * @param scene defines the hosting scene
  22037. * @param updatable defines if the mesh must be flagged as updatable
  22038. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22039. * @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)
  22040. * @returns a new Mesh
  22041. */
  22042. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22043. /**
  22044. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  22045. * @param name defines the name of the mesh to create
  22046. * @param radius sets the radius size (float) of the polygon (default 0.5)
  22047. * @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
  22048. * @param scene defines the hosting scene
  22049. * @param updatable defines if the mesh must be flagged as updatable
  22050. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22051. * @returns a new Mesh
  22052. */
  22053. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22054. /**
  22055. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  22056. * @param name defines the name of the mesh to create
  22057. * @param size sets the size (float) of each box side (default 1)
  22058. * @param scene defines the hosting scene
  22059. * @param updatable defines if the mesh must be flagged as updatable
  22060. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22061. * @returns a new Mesh
  22062. */
  22063. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22064. /**
  22065. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  22066. * @param name defines the name of the mesh to create
  22067. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22068. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22069. * @param scene defines the hosting scene
  22070. * @param updatable defines if the mesh must be flagged as updatable
  22071. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22072. * @returns a new Mesh
  22073. */
  22074. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22075. /**
  22076. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  22077. * @param name defines the name of the mesh to create
  22078. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22079. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22080. * @param scene defines the hosting scene
  22081. * @returns a new Mesh
  22082. */
  22083. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  22084. /**
  22085. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  22086. * @param name defines the name of the mesh to create
  22087. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  22088. * @param diameterTop set the top cap diameter (floats, default 1)
  22089. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  22090. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  22091. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  22092. * @param scene defines the hosting scene
  22093. * @param updatable defines if the mesh must be flagged as updatable
  22094. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22095. * @returns a new Mesh
  22096. */
  22097. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  22098. /**
  22099. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  22100. * @param name defines the name of the mesh to create
  22101. * @param diameter sets the diameter size (float) of the torus (default 1)
  22102. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  22103. * @param tessellation sets the number of torus sides (postive integer, default 16)
  22104. * @param scene defines the hosting scene
  22105. * @param updatable defines if the mesh must be flagged as updatable
  22106. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22107. * @returns a new Mesh
  22108. */
  22109. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22110. /**
  22111. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  22112. * @param name defines the name of the mesh to create
  22113. * @param radius sets the global radius size (float) of the torus knot (default 2)
  22114. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  22115. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  22116. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  22117. * @param p the number of windings on X axis (positive integers, default 2)
  22118. * @param q the number of windings on Y axis (positive integers, default 3)
  22119. * @param scene defines the hosting scene
  22120. * @param updatable defines if the mesh must be flagged as updatable
  22121. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22122. * @returns a new Mesh
  22123. */
  22124. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22125. /**
  22126. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  22127. * @param name defines the name of the mesh to create
  22128. * @param points is an array successive Vector3
  22129. * @param scene defines the hosting scene
  22130. * @param updatable defines if the mesh must be flagged as updatable
  22131. * @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).
  22132. * @returns a new Mesh
  22133. */
  22134. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  22135. /**
  22136. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  22137. * @param name defines the name of the mesh to create
  22138. * @param points is an array successive Vector3
  22139. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  22140. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22141. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  22142. * @param scene defines the hosting scene
  22143. * @param updatable defines if the mesh must be flagged as updatable
  22144. * @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)
  22145. * @returns a new Mesh
  22146. */
  22147. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  22148. /**
  22149. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  22150. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  22151. * 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.
  22152. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22153. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22154. * Remember you can only change the shape positions, not their number when updating a polygon.
  22155. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  22156. * @param name defines the name of the mesh to create
  22157. * @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
  22158. * @param scene defines the hosting scene
  22159. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22160. * @param updatable defines if the mesh must be flagged as updatable
  22161. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22162. * @param earcutInjection can be used to inject your own earcut reference
  22163. * @returns a new Mesh
  22164. */
  22165. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22166. /**
  22167. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  22168. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  22169. * @param name defines the name of the mesh to create
  22170. * @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
  22171. * @param depth defines the height of extrusion
  22172. * @param scene defines the hosting scene
  22173. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22174. * @param updatable defines if the mesh must be flagged as updatable
  22175. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22176. * @param earcutInjection can be used to inject your own earcut reference
  22177. * @returns a new Mesh
  22178. */
  22179. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22180. /**
  22181. * Creates an extruded shape mesh.
  22182. * 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
  22183. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22184. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22185. * @param name defines the name of the mesh to create
  22186. * @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
  22187. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22188. * @param scale is the value to scale the shape
  22189. * @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
  22190. * @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
  22191. * @param scene defines the hosting scene
  22192. * @param updatable defines if the mesh must be flagged as updatable
  22193. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22194. * @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)
  22195. * @returns a new Mesh
  22196. */
  22197. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22198. /**
  22199. * Creates an custom extruded shape mesh.
  22200. * The custom extrusion is a parametric shape.
  22201. * It has no predefined shape. Its final shape will depend on the input parameters.
  22202. * Please consider using the same method from the MeshBuilder class instead
  22203. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22204. * @param name defines the name of the mesh to create
  22205. * @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
  22206. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22207. * @param scaleFunction is a custom Javascript function called on each path point
  22208. * @param rotationFunction is a custom Javascript function called on each path point
  22209. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22210. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  22211. * @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
  22212. * @param scene defines the hosting scene
  22213. * @param updatable defines if the mesh must be flagged as updatable
  22214. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22215. * @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)
  22216. * @returns a new Mesh
  22217. */
  22218. 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;
  22219. /**
  22220. * Creates lathe mesh.
  22221. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  22222. * Please consider using the same method from the MeshBuilder class instead
  22223. * @param name defines the name of the mesh to create
  22224. * @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
  22225. * @param radius is the radius value of the lathe
  22226. * @param tessellation is the side number of the lathe.
  22227. * @param scene defines the hosting scene
  22228. * @param updatable defines if the mesh must be flagged as updatable
  22229. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22230. * @returns a new Mesh
  22231. */
  22232. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22233. /**
  22234. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  22235. * @param name defines the name of the mesh to create
  22236. * @param size sets the size (float) of both sides of the plane at once (default 1)
  22237. * @param scene defines the hosting scene
  22238. * @param updatable defines if the mesh must be flagged as updatable
  22239. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22240. * @returns a new Mesh
  22241. */
  22242. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22243. /**
  22244. * Creates a ground mesh.
  22245. * Please consider using the same method from the MeshBuilder class instead
  22246. * @param name defines the name of the mesh to create
  22247. * @param width set the width of the ground
  22248. * @param height set the height of the ground
  22249. * @param subdivisions sets the number of subdivisions per side
  22250. * @param scene defines the hosting scene
  22251. * @param updatable defines if the mesh must be flagged as updatable
  22252. * @returns a new Mesh
  22253. */
  22254. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22255. /**
  22256. * Creates a tiled ground mesh.
  22257. * Please consider using the same method from the MeshBuilder class instead
  22258. * @param name defines the name of the mesh to create
  22259. * @param xmin set the ground minimum X coordinate
  22260. * @param zmin set the ground minimum Y coordinate
  22261. * @param xmax set the ground maximum X coordinate
  22262. * @param zmax set the ground maximum Z coordinate
  22263. * @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
  22264. * @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
  22265. * @param scene defines the hosting scene
  22266. * @param updatable defines if the mesh must be flagged as updatable
  22267. * @returns a new Mesh
  22268. */
  22269. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22270. w: number;
  22271. h: number;
  22272. }, precision: {
  22273. w: number;
  22274. h: number;
  22275. }, scene: Scene, updatable?: boolean): Mesh;
  22276. /**
  22277. * Creates a ground mesh from a height map.
  22278. * Please consider using the same method from the MeshBuilder class instead
  22279. * @see http://doc.babylonjs.com/babylon101/height_map
  22280. * @param name defines the name of the mesh to create
  22281. * @param url sets the URL of the height map image resource
  22282. * @param width set the ground width size
  22283. * @param height set the ground height size
  22284. * @param subdivisions sets the number of subdivision per side
  22285. * @param minHeight is the minimum altitude on the ground
  22286. * @param maxHeight is the maximum altitude on the ground
  22287. * @param scene defines the hosting scene
  22288. * @param updatable defines if the mesh must be flagged as updatable
  22289. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  22290. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  22291. * @returns a new Mesh
  22292. */
  22293. 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;
  22294. /**
  22295. * Creates a tube mesh.
  22296. * The tube is a parametric shape.
  22297. * It has no predefined shape. Its final shape will depend on the input parameters.
  22298. * Please consider using the same method from the MeshBuilder class instead
  22299. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22300. * @param name defines the name of the mesh to create
  22301. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  22302. * @param radius sets the tube radius size
  22303. * @param tessellation is the number of sides on the tubular surface
  22304. * @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
  22305. * @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
  22306. * @param scene defines the hosting scene
  22307. * @param updatable defines if the mesh must be flagged as updatable
  22308. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22309. * @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)
  22310. * @returns a new Mesh
  22311. */
  22312. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22313. (i: number, distance: number): number;
  22314. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22315. /**
  22316. * Creates a polyhedron mesh.
  22317. * Please consider using the same method from the MeshBuilder class instead.
  22318. * * 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
  22319. * * The parameter `size` (positive float, default 1) sets the polygon size
  22320. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22321. * * 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`
  22322. * * 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
  22323. * * 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)`)
  22324. * * 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
  22325. * * 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
  22326. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22327. * * If you create a double-sided mesh, you can choose what parts of 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
  22328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22329. * @param name defines the name of the mesh to create
  22330. * @param options defines the options used to create the mesh
  22331. * @param scene defines the hosting scene
  22332. * @returns a new Mesh
  22333. */
  22334. static CreatePolyhedron(name: string, options: {
  22335. type?: number;
  22336. size?: number;
  22337. sizeX?: number;
  22338. sizeY?: number;
  22339. sizeZ?: number;
  22340. custom?: any;
  22341. faceUV?: Vector4[];
  22342. faceColors?: Color4[];
  22343. updatable?: boolean;
  22344. sideOrientation?: number;
  22345. }, scene: Scene): Mesh;
  22346. /**
  22347. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22348. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22349. * * 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`)
  22350. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22351. * * 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
  22352. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22353. * * If you create a double-sided mesh, you can choose what parts of 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
  22354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22355. * @param name defines the name of the mesh
  22356. * @param options defines the options used to create the mesh
  22357. * @param scene defines the hosting scene
  22358. * @returns a new Mesh
  22359. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22360. */
  22361. static CreateIcoSphere(name: string, options: {
  22362. radius?: number;
  22363. flat?: boolean;
  22364. subdivisions?: number;
  22365. sideOrientation?: number;
  22366. updatable?: boolean;
  22367. }, scene: Scene): Mesh;
  22368. /**
  22369. * Creates a decal mesh.
  22370. * Please consider using the same method from the MeshBuilder class instead.
  22371. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22372. * @param name defines the name of the mesh
  22373. * @param sourceMesh defines the mesh receiving the decal
  22374. * @param position sets the position of the decal in world coordinates
  22375. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22376. * @param size sets the decal scaling
  22377. * @param angle sets the angle to rotate the decal
  22378. * @returns a new Mesh
  22379. */
  22380. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22381. /**
  22382. * Prepare internal position array for software CPU skinning
  22383. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22384. */
  22385. setPositionsForCPUSkinning(): Float32Array;
  22386. /**
  22387. * Prepare internal normal array for software CPU skinning
  22388. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22389. */
  22390. setNormalsForCPUSkinning(): Float32Array;
  22391. /**
  22392. * Updates the vertex buffer by applying transformation from the bones
  22393. * @param skeleton defines the skeleton to apply to current mesh
  22394. * @returns the current mesh
  22395. */
  22396. applySkeleton(skeleton: Skeleton): Mesh;
  22397. /**
  22398. * 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
  22399. * @param meshes defines the list of meshes to scan
  22400. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22401. */
  22402. static MinMax(meshes: AbstractMesh[]): {
  22403. min: Vector3;
  22404. max: Vector3;
  22405. };
  22406. /**
  22407. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22408. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22409. * @returns a vector3
  22410. */
  22411. static Center(meshesOrMinMaxVector: {
  22412. min: Vector3;
  22413. max: Vector3;
  22414. } | AbstractMesh[]): Vector3;
  22415. /**
  22416. * Merge the array of meshes into a single mesh for performance reasons.
  22417. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22418. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22419. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22420. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22421. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22422. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22423. * @returns a new mesh
  22424. */
  22425. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22426. /** @hidden */
  22427. addInstance(instance: InstancedMesh): void;
  22428. /** @hidden */
  22429. removeInstance(instance: InstancedMesh): void;
  22430. }
  22431. }
  22432. declare module "babylonjs/Materials/material" {
  22433. import { IAnimatable } from "babylonjs/Misc/tools";
  22434. import { SmartArray } from "babylonjs/Misc/smartArray";
  22435. import { Observable } from "babylonjs/Misc/observable";
  22436. import { Nullable } from "babylonjs/types";
  22437. import { Scene } from "babylonjs/scene";
  22438. import { Matrix } from "babylonjs/Maths/math";
  22439. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22440. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22441. import { Mesh } from "babylonjs/Meshes/mesh";
  22442. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22443. import { Effect } from "babylonjs/Materials/effect";
  22444. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22445. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22446. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22447. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22448. import { Animation } from "babylonjs/Animations/animation";
  22449. /**
  22450. * Base class for the main features of a material in Babylon.js
  22451. */
  22452. export class Material implements IAnimatable {
  22453. /**
  22454. * Returns the triangle fill mode
  22455. */
  22456. static readonly TriangleFillMode: number;
  22457. /**
  22458. * Returns the wireframe mode
  22459. */
  22460. static readonly WireFrameFillMode: number;
  22461. /**
  22462. * Returns the point fill mode
  22463. */
  22464. static readonly PointFillMode: number;
  22465. /**
  22466. * Returns the point list draw mode
  22467. */
  22468. static readonly PointListDrawMode: number;
  22469. /**
  22470. * Returns the line list draw mode
  22471. */
  22472. static readonly LineListDrawMode: number;
  22473. /**
  22474. * Returns the line loop draw mode
  22475. */
  22476. static readonly LineLoopDrawMode: number;
  22477. /**
  22478. * Returns the line strip draw mode
  22479. */
  22480. static readonly LineStripDrawMode: number;
  22481. /**
  22482. * Returns the triangle strip draw mode
  22483. */
  22484. static readonly TriangleStripDrawMode: number;
  22485. /**
  22486. * Returns the triangle fan draw mode
  22487. */
  22488. static readonly TriangleFanDrawMode: number;
  22489. /**
  22490. * Stores the clock-wise side orientation
  22491. */
  22492. static readonly ClockWiseSideOrientation: number;
  22493. /**
  22494. * Stores the counter clock-wise side orientation
  22495. */
  22496. static readonly CounterClockWiseSideOrientation: number;
  22497. /**
  22498. * The dirty texture flag value
  22499. */
  22500. static readonly TextureDirtyFlag: number;
  22501. /**
  22502. * The dirty light flag value
  22503. */
  22504. static readonly LightDirtyFlag: number;
  22505. /**
  22506. * The dirty fresnel flag value
  22507. */
  22508. static readonly FresnelDirtyFlag: number;
  22509. /**
  22510. * The dirty attribute flag value
  22511. */
  22512. static readonly AttributesDirtyFlag: number;
  22513. /**
  22514. * The dirty misc flag value
  22515. */
  22516. static readonly MiscDirtyFlag: number;
  22517. /**
  22518. * The all dirty flag value
  22519. */
  22520. static readonly AllDirtyFlag: number;
  22521. /**
  22522. * The ID of the material
  22523. */
  22524. id: string;
  22525. /**
  22526. * Gets or sets the unique id of the material
  22527. */
  22528. uniqueId: number;
  22529. /**
  22530. * The name of the material
  22531. */
  22532. name: string;
  22533. /**
  22534. * Gets or sets user defined metadata
  22535. */
  22536. metadata: any;
  22537. /**
  22538. * For internal use only. Please do not use.
  22539. */
  22540. reservedDataStore: any;
  22541. /**
  22542. * Specifies if the ready state should be checked on each call
  22543. */
  22544. checkReadyOnEveryCall: boolean;
  22545. /**
  22546. * Specifies if the ready state should be checked once
  22547. */
  22548. checkReadyOnlyOnce: boolean;
  22549. /**
  22550. * The state of the material
  22551. */
  22552. state: string;
  22553. /**
  22554. * The alpha value of the material
  22555. */
  22556. protected _alpha: number;
  22557. /**
  22558. * List of inspectable custom properties (used by the Inspector)
  22559. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22560. */
  22561. inspectableCustomProperties: IInspectable[];
  22562. /**
  22563. * Sets the alpha value of the material
  22564. */
  22565. /**
  22566. * Gets the alpha value of the material
  22567. */
  22568. alpha: number;
  22569. /**
  22570. * Specifies if back face culling is enabled
  22571. */
  22572. protected _backFaceCulling: boolean;
  22573. /**
  22574. * Sets the back-face culling state
  22575. */
  22576. /**
  22577. * Gets the back-face culling state
  22578. */
  22579. backFaceCulling: boolean;
  22580. /**
  22581. * Stores the value for side orientation
  22582. */
  22583. sideOrientation: number;
  22584. /**
  22585. * Callback triggered when the material is compiled
  22586. */
  22587. onCompiled: Nullable<(effect: Effect) => void>;
  22588. /**
  22589. * Callback triggered when an error occurs
  22590. */
  22591. onError: Nullable<(effect: Effect, errors: string) => void>;
  22592. /**
  22593. * Callback triggered to get the render target textures
  22594. */
  22595. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22596. /**
  22597. * Gets a boolean indicating that current material needs to register RTT
  22598. */
  22599. readonly hasRenderTargetTextures: boolean;
  22600. /**
  22601. * Specifies if the material should be serialized
  22602. */
  22603. doNotSerialize: boolean;
  22604. /**
  22605. * @hidden
  22606. */
  22607. _storeEffectOnSubMeshes: boolean;
  22608. /**
  22609. * Stores the animations for the material
  22610. */
  22611. animations: Nullable<Array<Animation>>;
  22612. /**
  22613. * An event triggered when the material is disposed
  22614. */
  22615. onDisposeObservable: Observable<Material>;
  22616. /**
  22617. * An observer which watches for dispose events
  22618. */
  22619. private _onDisposeObserver;
  22620. private _onUnBindObservable;
  22621. /**
  22622. * Called during a dispose event
  22623. */
  22624. onDispose: () => void;
  22625. private _onBindObservable;
  22626. /**
  22627. * An event triggered when the material is bound
  22628. */
  22629. readonly onBindObservable: Observable<AbstractMesh>;
  22630. /**
  22631. * An observer which watches for bind events
  22632. */
  22633. private _onBindObserver;
  22634. /**
  22635. * Called during a bind event
  22636. */
  22637. onBind: (Mesh: AbstractMesh) => void;
  22638. /**
  22639. * An event triggered when the material is unbound
  22640. */
  22641. readonly onUnBindObservable: Observable<Material>;
  22642. /**
  22643. * Stores the value of the alpha mode
  22644. */
  22645. private _alphaMode;
  22646. /**
  22647. * Sets the value of the alpha mode.
  22648. *
  22649. * | Value | Type | Description |
  22650. * | --- | --- | --- |
  22651. * | 0 | ALPHA_DISABLE | |
  22652. * | 1 | ALPHA_ADD | |
  22653. * | 2 | ALPHA_COMBINE | |
  22654. * | 3 | ALPHA_SUBTRACT | |
  22655. * | 4 | ALPHA_MULTIPLY | |
  22656. * | 5 | ALPHA_MAXIMIZED | |
  22657. * | 6 | ALPHA_ONEONE | |
  22658. * | 7 | ALPHA_PREMULTIPLIED | |
  22659. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22660. * | 9 | ALPHA_INTERPOLATE | |
  22661. * | 10 | ALPHA_SCREENMODE | |
  22662. *
  22663. */
  22664. /**
  22665. * Gets the value of the alpha mode
  22666. */
  22667. alphaMode: number;
  22668. /**
  22669. * Stores the state of the need depth pre-pass value
  22670. */
  22671. private _needDepthPrePass;
  22672. /**
  22673. * Sets the need depth pre-pass value
  22674. */
  22675. /**
  22676. * Gets the depth pre-pass value
  22677. */
  22678. needDepthPrePass: boolean;
  22679. /**
  22680. * Specifies if depth writing should be disabled
  22681. */
  22682. disableDepthWrite: boolean;
  22683. /**
  22684. * Specifies if depth writing should be forced
  22685. */
  22686. forceDepthWrite: boolean;
  22687. /**
  22688. * Specifies if there should be a separate pass for culling
  22689. */
  22690. separateCullingPass: boolean;
  22691. /**
  22692. * Stores the state specifing if fog should be enabled
  22693. */
  22694. private _fogEnabled;
  22695. /**
  22696. * Sets the state for enabling fog
  22697. */
  22698. /**
  22699. * Gets the value of the fog enabled state
  22700. */
  22701. fogEnabled: boolean;
  22702. /**
  22703. * Stores the size of points
  22704. */
  22705. pointSize: number;
  22706. /**
  22707. * Stores the z offset value
  22708. */
  22709. zOffset: number;
  22710. /**
  22711. * Gets a value specifying if wireframe mode is enabled
  22712. */
  22713. /**
  22714. * Sets the state of wireframe mode
  22715. */
  22716. wireframe: boolean;
  22717. /**
  22718. * Gets the value specifying if point clouds are enabled
  22719. */
  22720. /**
  22721. * Sets the state of point cloud mode
  22722. */
  22723. pointsCloud: boolean;
  22724. /**
  22725. * Gets the material fill mode
  22726. */
  22727. /**
  22728. * Sets the material fill mode
  22729. */
  22730. fillMode: number;
  22731. /**
  22732. * @hidden
  22733. * Stores the effects for the material
  22734. */
  22735. _effect: Nullable<Effect>;
  22736. /**
  22737. * @hidden
  22738. * Specifies if the material was previously ready
  22739. */
  22740. _wasPreviouslyReady: boolean;
  22741. /**
  22742. * Specifies if uniform buffers should be used
  22743. */
  22744. private _useUBO;
  22745. /**
  22746. * Stores a reference to the scene
  22747. */
  22748. private _scene;
  22749. /**
  22750. * Stores the fill mode state
  22751. */
  22752. private _fillMode;
  22753. /**
  22754. * Specifies if the depth write state should be cached
  22755. */
  22756. private _cachedDepthWriteState;
  22757. /**
  22758. * Stores the uniform buffer
  22759. */
  22760. protected _uniformBuffer: UniformBuffer;
  22761. /** @hidden */
  22762. _indexInSceneMaterialArray: number;
  22763. /** @hidden */
  22764. meshMap: Nullable<{
  22765. [id: string]: AbstractMesh | undefined;
  22766. }>;
  22767. /**
  22768. * Creates a material instance
  22769. * @param name defines the name of the material
  22770. * @param scene defines the scene to reference
  22771. * @param doNotAdd specifies if the material should be added to the scene
  22772. */
  22773. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22774. /**
  22775. * Returns a string representation of the current material
  22776. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22777. * @returns a string with material information
  22778. */
  22779. toString(fullDetails?: boolean): string;
  22780. /**
  22781. * Gets the class name of the material
  22782. * @returns a string with the class name of the material
  22783. */
  22784. getClassName(): string;
  22785. /**
  22786. * Specifies if updates for the material been locked
  22787. */
  22788. readonly isFrozen: boolean;
  22789. /**
  22790. * Locks updates for the material
  22791. */
  22792. freeze(): void;
  22793. /**
  22794. * Unlocks updates for the material
  22795. */
  22796. unfreeze(): void;
  22797. /**
  22798. * Specifies if the material is ready to be used
  22799. * @param mesh defines the mesh to check
  22800. * @param useInstances specifies if instances should be used
  22801. * @returns a boolean indicating if the material is ready to be used
  22802. */
  22803. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22804. /**
  22805. * Specifies that the submesh is ready to be used
  22806. * @param mesh defines the mesh to check
  22807. * @param subMesh defines which submesh to check
  22808. * @param useInstances specifies that instances should be used
  22809. * @returns a boolean indicating that the submesh is ready or not
  22810. */
  22811. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22812. /**
  22813. * Returns the material effect
  22814. * @returns the effect associated with the material
  22815. */
  22816. getEffect(): Nullable<Effect>;
  22817. /**
  22818. * Returns the current scene
  22819. * @returns a Scene
  22820. */
  22821. getScene(): Scene;
  22822. /**
  22823. * Specifies if the material will require alpha blending
  22824. * @returns a boolean specifying if alpha blending is needed
  22825. */
  22826. needAlphaBlending(): boolean;
  22827. /**
  22828. * Specifies if the mesh will require alpha blending
  22829. * @param mesh defines the mesh to check
  22830. * @returns a boolean specifying if alpha blending is needed for the mesh
  22831. */
  22832. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22833. /**
  22834. * Specifies if this material should be rendered in alpha test mode
  22835. * @returns a boolean specifying if an alpha test is needed.
  22836. */
  22837. needAlphaTesting(): boolean;
  22838. /**
  22839. * Gets the texture used for the alpha test
  22840. * @returns the texture to use for alpha testing
  22841. */
  22842. getAlphaTestTexture(): Nullable<BaseTexture>;
  22843. /**
  22844. * Marks the material to indicate that it needs to be re-calculated
  22845. */
  22846. markDirty(): void;
  22847. /** @hidden */
  22848. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22849. /**
  22850. * Binds the material to the mesh
  22851. * @param world defines the world transformation matrix
  22852. * @param mesh defines the mesh to bind the material to
  22853. */
  22854. bind(world: Matrix, mesh?: Mesh): void;
  22855. /**
  22856. * Binds the submesh to the material
  22857. * @param world defines the world transformation matrix
  22858. * @param mesh defines the mesh containing the submesh
  22859. * @param subMesh defines the submesh to bind the material to
  22860. */
  22861. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22862. /**
  22863. * Binds the world matrix to the material
  22864. * @param world defines the world transformation matrix
  22865. */
  22866. bindOnlyWorldMatrix(world: Matrix): void;
  22867. /**
  22868. * Binds the scene's uniform buffer to the effect.
  22869. * @param effect defines the effect to bind to the scene uniform buffer
  22870. * @param sceneUbo defines the uniform buffer storing scene data
  22871. */
  22872. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22873. /**
  22874. * Binds the view matrix to the effect
  22875. * @param effect defines the effect to bind the view matrix to
  22876. */
  22877. bindView(effect: Effect): void;
  22878. /**
  22879. * Binds the view projection matrix to the effect
  22880. * @param effect defines the effect to bind the view projection matrix to
  22881. */
  22882. bindViewProjection(effect: Effect): void;
  22883. /**
  22884. * Specifies if material alpha testing should be turned on for the mesh
  22885. * @param mesh defines the mesh to check
  22886. */
  22887. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22888. /**
  22889. * Processes to execute after binding the material to a mesh
  22890. * @param mesh defines the rendered mesh
  22891. */
  22892. protected _afterBind(mesh?: Mesh): void;
  22893. /**
  22894. * Unbinds the material from the mesh
  22895. */
  22896. unbind(): void;
  22897. /**
  22898. * Gets the active textures from the material
  22899. * @returns an array of textures
  22900. */
  22901. getActiveTextures(): BaseTexture[];
  22902. /**
  22903. * Specifies if the material uses a texture
  22904. * @param texture defines the texture to check against the material
  22905. * @returns a boolean specifying if the material uses the texture
  22906. */
  22907. hasTexture(texture: BaseTexture): boolean;
  22908. /**
  22909. * Makes a duplicate of the material, and gives it a new name
  22910. * @param name defines the new name for the duplicated material
  22911. * @returns the cloned material
  22912. */
  22913. clone(name: string): Nullable<Material>;
  22914. /**
  22915. * Gets the meshes bound to the material
  22916. * @returns an array of meshes bound to the material
  22917. */
  22918. getBindedMeshes(): AbstractMesh[];
  22919. /**
  22920. * Force shader compilation
  22921. * @param mesh defines the mesh associated with this material
  22922. * @param onCompiled defines a function to execute once the material is compiled
  22923. * @param options defines the options to configure the compilation
  22924. */
  22925. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22926. clipPlane: boolean;
  22927. }>): void;
  22928. /**
  22929. * Force shader compilation
  22930. * @param mesh defines the mesh that will use this material
  22931. * @param options defines additional options for compiling the shaders
  22932. * @returns a promise that resolves when the compilation completes
  22933. */
  22934. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22935. clipPlane: boolean;
  22936. }>): Promise<void>;
  22937. private static readonly _ImageProcessingDirtyCallBack;
  22938. private static readonly _TextureDirtyCallBack;
  22939. private static readonly _FresnelDirtyCallBack;
  22940. private static readonly _MiscDirtyCallBack;
  22941. private static readonly _LightsDirtyCallBack;
  22942. private static readonly _AttributeDirtyCallBack;
  22943. private static _FresnelAndMiscDirtyCallBack;
  22944. private static _TextureAndMiscDirtyCallBack;
  22945. private static readonly _DirtyCallbackArray;
  22946. private static readonly _RunDirtyCallBacks;
  22947. /**
  22948. * Marks a define in the material to indicate that it needs to be re-computed
  22949. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22950. */
  22951. markAsDirty(flag: number): void;
  22952. /**
  22953. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22954. * @param func defines a function which checks material defines against the submeshes
  22955. */
  22956. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22957. /**
  22958. * Indicates that image processing needs to be re-calculated for all submeshes
  22959. */
  22960. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22961. /**
  22962. * Indicates that textures need to be re-calculated for all submeshes
  22963. */
  22964. protected _markAllSubMeshesAsTexturesDirty(): void;
  22965. /**
  22966. * Indicates that fresnel needs to be re-calculated for all submeshes
  22967. */
  22968. protected _markAllSubMeshesAsFresnelDirty(): void;
  22969. /**
  22970. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22971. */
  22972. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22973. /**
  22974. * Indicates that lights need to be re-calculated for all submeshes
  22975. */
  22976. protected _markAllSubMeshesAsLightsDirty(): void;
  22977. /**
  22978. * Indicates that attributes need to be re-calculated for all submeshes
  22979. */
  22980. protected _markAllSubMeshesAsAttributesDirty(): void;
  22981. /**
  22982. * Indicates that misc needs to be re-calculated for all submeshes
  22983. */
  22984. protected _markAllSubMeshesAsMiscDirty(): void;
  22985. /**
  22986. * Indicates that textures and misc need to be re-calculated for all submeshes
  22987. */
  22988. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22989. /**
  22990. * Disposes the material
  22991. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22992. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22993. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22994. */
  22995. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22996. /** @hidden */
  22997. private releaseVertexArrayObject;
  22998. /**
  22999. * Serializes this material
  23000. * @returns the serialized material object
  23001. */
  23002. serialize(): any;
  23003. /**
  23004. * Creates a material from parsed material data
  23005. * @param parsedMaterial defines parsed material data
  23006. * @param scene defines the hosting scene
  23007. * @param rootUrl defines the root URL to use to load textures
  23008. * @returns a new material
  23009. */
  23010. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23011. }
  23012. }
  23013. declare module "babylonjs/Meshes/subMesh" {
  23014. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23015. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23016. import { Engine } from "babylonjs/Engines/engine";
  23017. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23018. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23019. import { Effect } from "babylonjs/Materials/effect";
  23020. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23021. import { Collider } from "babylonjs/Collisions/collider";
  23022. import { Material } from "babylonjs/Materials/material";
  23023. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23025. import { Mesh } from "babylonjs/Meshes/mesh";
  23026. import { Ray } from "babylonjs/Culling/ray";
  23027. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23028. /**
  23029. * Base class for submeshes
  23030. */
  23031. export class BaseSubMesh {
  23032. /** @hidden */
  23033. _materialDefines: Nullable<MaterialDefines>;
  23034. /** @hidden */
  23035. _materialEffect: Nullable<Effect>;
  23036. /**
  23037. * Gets associated effect
  23038. */
  23039. readonly effect: Nullable<Effect>;
  23040. /**
  23041. * Sets associated effect (effect used to render this submesh)
  23042. * @param effect defines the effect to associate with
  23043. * @param defines defines the set of defines used to compile this effect
  23044. */
  23045. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23046. }
  23047. /**
  23048. * Defines a subdivision inside a mesh
  23049. */
  23050. export class SubMesh extends BaseSubMesh implements ICullable {
  23051. /** the material index to use */
  23052. materialIndex: number;
  23053. /** vertex index start */
  23054. verticesStart: number;
  23055. /** vertices count */
  23056. verticesCount: number;
  23057. /** index start */
  23058. indexStart: number;
  23059. /** indices count */
  23060. indexCount: number;
  23061. /** @hidden */
  23062. _linesIndexCount: number;
  23063. private _mesh;
  23064. private _renderingMesh;
  23065. private _boundingInfo;
  23066. private _linesIndexBuffer;
  23067. /** @hidden */
  23068. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23069. /** @hidden */
  23070. _trianglePlanes: Plane[];
  23071. /** @hidden */
  23072. _lastColliderTransformMatrix: Nullable<Matrix>;
  23073. /** @hidden */
  23074. _renderId: number;
  23075. /** @hidden */
  23076. _alphaIndex: number;
  23077. /** @hidden */
  23078. _distanceToCamera: number;
  23079. /** @hidden */
  23080. _id: number;
  23081. private _currentMaterial;
  23082. /**
  23083. * Add a new submesh to a mesh
  23084. * @param materialIndex defines the material index to use
  23085. * @param verticesStart defines vertex index start
  23086. * @param verticesCount defines vertices count
  23087. * @param indexStart defines index start
  23088. * @param indexCount defines indices count
  23089. * @param mesh defines the parent mesh
  23090. * @param renderingMesh defines an optional rendering mesh
  23091. * @param createBoundingBox defines if bounding box should be created for this submesh
  23092. * @returns the new submesh
  23093. */
  23094. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23095. /**
  23096. * Creates a new submesh
  23097. * @param materialIndex defines the material index to use
  23098. * @param verticesStart defines vertex index start
  23099. * @param verticesCount defines vertices count
  23100. * @param indexStart defines index start
  23101. * @param indexCount defines indices count
  23102. * @param mesh defines the parent mesh
  23103. * @param renderingMesh defines an optional rendering mesh
  23104. * @param createBoundingBox defines if bounding box should be created for this submesh
  23105. */
  23106. constructor(
  23107. /** the material index to use */
  23108. materialIndex: number,
  23109. /** vertex index start */
  23110. verticesStart: number,
  23111. /** vertices count */
  23112. verticesCount: number,
  23113. /** index start */
  23114. indexStart: number,
  23115. /** indices count */
  23116. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23117. /**
  23118. * Returns true if this submesh covers the entire parent mesh
  23119. * @ignorenaming
  23120. */
  23121. readonly IsGlobal: boolean;
  23122. /**
  23123. * Returns the submesh BoudingInfo object
  23124. * @returns current bounding info (or mesh's one if the submesh is global)
  23125. */
  23126. getBoundingInfo(): BoundingInfo;
  23127. /**
  23128. * Sets the submesh BoundingInfo
  23129. * @param boundingInfo defines the new bounding info to use
  23130. * @returns the SubMesh
  23131. */
  23132. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23133. /**
  23134. * Returns the mesh of the current submesh
  23135. * @return the parent mesh
  23136. */
  23137. getMesh(): AbstractMesh;
  23138. /**
  23139. * Returns the rendering mesh of the submesh
  23140. * @returns the rendering mesh (could be different from parent mesh)
  23141. */
  23142. getRenderingMesh(): Mesh;
  23143. /**
  23144. * Returns the submesh material
  23145. * @returns null or the current material
  23146. */
  23147. getMaterial(): Nullable<Material>;
  23148. /**
  23149. * Sets a new updated BoundingInfo object to the submesh
  23150. * @param data defines an optional position array to use to determine the bounding info
  23151. * @returns the SubMesh
  23152. */
  23153. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23154. /** @hidden */
  23155. _checkCollision(collider: Collider): boolean;
  23156. /**
  23157. * Updates the submesh BoundingInfo
  23158. * @param world defines the world matrix to use to update the bounding info
  23159. * @returns the submesh
  23160. */
  23161. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23162. /**
  23163. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23164. * @param frustumPlanes defines the frustum planes
  23165. * @returns true if the submesh is intersecting with the frustum
  23166. */
  23167. isInFrustum(frustumPlanes: Plane[]): boolean;
  23168. /**
  23169. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23170. * @param frustumPlanes defines the frustum planes
  23171. * @returns true if the submesh is inside the frustum
  23172. */
  23173. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23174. /**
  23175. * Renders the submesh
  23176. * @param enableAlphaMode defines if alpha needs to be used
  23177. * @returns the submesh
  23178. */
  23179. render(enableAlphaMode: boolean): SubMesh;
  23180. /**
  23181. * @hidden
  23182. */
  23183. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23184. /**
  23185. * Checks if the submesh intersects with a ray
  23186. * @param ray defines the ray to test
  23187. * @returns true is the passed ray intersects the submesh bounding box
  23188. */
  23189. canIntersects(ray: Ray): boolean;
  23190. /**
  23191. * Intersects current submesh with a ray
  23192. * @param ray defines the ray to test
  23193. * @param positions defines mesh's positions array
  23194. * @param indices defines mesh's indices array
  23195. * @param fastCheck defines if only bounding info should be used
  23196. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23197. * @returns intersection info or null if no intersection
  23198. */
  23199. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23200. /** @hidden */
  23201. private _intersectLines;
  23202. /** @hidden */
  23203. private _intersectTriangles;
  23204. /** @hidden */
  23205. _rebuild(): void;
  23206. /**
  23207. * Creates a new submesh from the passed mesh
  23208. * @param newMesh defines the new hosting mesh
  23209. * @param newRenderingMesh defines an optional rendering mesh
  23210. * @returns the new submesh
  23211. */
  23212. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23213. /**
  23214. * Release associated resources
  23215. */
  23216. dispose(): void;
  23217. /**
  23218. * Gets the class name
  23219. * @returns the string "SubMesh".
  23220. */
  23221. getClassName(): string;
  23222. /**
  23223. * Creates a new submesh from indices data
  23224. * @param materialIndex the index of the main mesh material
  23225. * @param startIndex the index where to start the copy in the mesh indices array
  23226. * @param indexCount the number of indices to copy then from the startIndex
  23227. * @param mesh the main mesh to create the submesh from
  23228. * @param renderingMesh the optional rendering mesh
  23229. * @returns a new submesh
  23230. */
  23231. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23232. }
  23233. }
  23234. declare module "babylonjs/Meshes/geometry" {
  23235. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23236. import { Scene } from "babylonjs/scene";
  23237. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23238. import { Engine } from "babylonjs/Engines/engine";
  23239. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23240. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23241. import { Effect } from "babylonjs/Materials/effect";
  23242. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23243. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23244. import { Mesh } from "babylonjs/Meshes/mesh";
  23245. /**
  23246. * Class used to store geometry data (vertex buffers + index buffer)
  23247. */
  23248. export class Geometry implements IGetSetVerticesData {
  23249. /**
  23250. * Gets or sets the ID of the geometry
  23251. */
  23252. id: string;
  23253. /**
  23254. * Gets or sets the unique ID of the geometry
  23255. */
  23256. uniqueId: number;
  23257. /**
  23258. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23259. */
  23260. delayLoadState: number;
  23261. /**
  23262. * Gets the file containing the data to load when running in delay load state
  23263. */
  23264. delayLoadingFile: Nullable<string>;
  23265. /**
  23266. * Callback called when the geometry is updated
  23267. */
  23268. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23269. private _scene;
  23270. private _engine;
  23271. private _meshes;
  23272. private _totalVertices;
  23273. /** @hidden */
  23274. _indices: IndicesArray;
  23275. /** @hidden */
  23276. _vertexBuffers: {
  23277. [key: string]: VertexBuffer;
  23278. };
  23279. private _isDisposed;
  23280. private _extend;
  23281. private _boundingBias;
  23282. /** @hidden */
  23283. _delayInfo: Array<string>;
  23284. private _indexBuffer;
  23285. private _indexBufferIsUpdatable;
  23286. /** @hidden */
  23287. _boundingInfo: Nullable<BoundingInfo>;
  23288. /** @hidden */
  23289. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23290. /** @hidden */
  23291. _softwareSkinningFrameId: number;
  23292. private _vertexArrayObjects;
  23293. private _updatable;
  23294. /** @hidden */
  23295. _positions: Nullable<Vector3[]>;
  23296. /**
  23297. * 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
  23298. */
  23299. /**
  23300. * 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
  23301. */
  23302. boundingBias: Vector2;
  23303. /**
  23304. * Static function used to attach a new empty geometry to a mesh
  23305. * @param mesh defines the mesh to attach the geometry to
  23306. * @returns the new Geometry
  23307. */
  23308. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23309. /**
  23310. * Creates a new geometry
  23311. * @param id defines the unique ID
  23312. * @param scene defines the hosting scene
  23313. * @param vertexData defines the VertexData used to get geometry data
  23314. * @param updatable defines if geometry must be updatable (false by default)
  23315. * @param mesh defines the mesh that will be associated with the geometry
  23316. */
  23317. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23318. /**
  23319. * Gets the current extend of the geometry
  23320. */
  23321. readonly extend: {
  23322. minimum: Vector3;
  23323. maximum: Vector3;
  23324. };
  23325. /**
  23326. * Gets the hosting scene
  23327. * @returns the hosting Scene
  23328. */
  23329. getScene(): Scene;
  23330. /**
  23331. * Gets the hosting engine
  23332. * @returns the hosting Engine
  23333. */
  23334. getEngine(): Engine;
  23335. /**
  23336. * Defines if the geometry is ready to use
  23337. * @returns true if the geometry is ready to be used
  23338. */
  23339. isReady(): boolean;
  23340. /**
  23341. * Gets a value indicating that the geometry should not be serialized
  23342. */
  23343. readonly doNotSerialize: boolean;
  23344. /** @hidden */
  23345. _rebuild(): void;
  23346. /**
  23347. * Affects all geometry data in one call
  23348. * @param vertexData defines the geometry data
  23349. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23350. */
  23351. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23352. /**
  23353. * Set specific vertex data
  23354. * @param kind defines the data kind (Position, normal, etc...)
  23355. * @param data defines the vertex data to use
  23356. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23357. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23358. */
  23359. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23360. /**
  23361. * Removes a specific vertex data
  23362. * @param kind defines the data kind (Position, normal, etc...)
  23363. */
  23364. removeVerticesData(kind: string): void;
  23365. /**
  23366. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23367. * @param buffer defines the vertex buffer to use
  23368. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23369. */
  23370. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23371. /**
  23372. * Update a specific vertex buffer
  23373. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23374. * It will do nothing if the buffer is not updatable
  23375. * @param kind defines the data kind (Position, normal, etc...)
  23376. * @param data defines the data to use
  23377. * @param offset defines the offset in the target buffer where to store the data
  23378. * @param useBytes set to true if the offset is in bytes
  23379. */
  23380. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23381. /**
  23382. * Update a specific vertex buffer
  23383. * This function will create a new buffer if the current one is not updatable
  23384. * @param kind defines the data kind (Position, normal, etc...)
  23385. * @param data defines the data to use
  23386. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23387. */
  23388. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23389. private _updateBoundingInfo;
  23390. /** @hidden */
  23391. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23392. /**
  23393. * Gets total number of vertices
  23394. * @returns the total number of vertices
  23395. */
  23396. getTotalVertices(): number;
  23397. /**
  23398. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23399. * @param kind defines the data kind (Position, normal, etc...)
  23400. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23401. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23402. * @returns a float array containing vertex data
  23403. */
  23404. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23405. /**
  23406. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23407. * @param kind defines the data kind (Position, normal, etc...)
  23408. * @returns true if the vertex buffer with the specified kind is updatable
  23409. */
  23410. isVertexBufferUpdatable(kind: string): boolean;
  23411. /**
  23412. * Gets a specific vertex buffer
  23413. * @param kind defines the data kind (Position, normal, etc...)
  23414. * @returns a VertexBuffer
  23415. */
  23416. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23417. /**
  23418. * Returns all vertex buffers
  23419. * @return an object holding all vertex buffers indexed by kind
  23420. */
  23421. getVertexBuffers(): Nullable<{
  23422. [key: string]: VertexBuffer;
  23423. }>;
  23424. /**
  23425. * Gets a boolean indicating if specific vertex buffer is present
  23426. * @param kind defines the data kind (Position, normal, etc...)
  23427. * @returns true if data is present
  23428. */
  23429. isVerticesDataPresent(kind: string): boolean;
  23430. /**
  23431. * Gets a list of all attached data kinds (Position, normal, etc...)
  23432. * @returns a list of string containing all kinds
  23433. */
  23434. getVerticesDataKinds(): string[];
  23435. /**
  23436. * Update index buffer
  23437. * @param indices defines the indices to store in the index buffer
  23438. * @param offset defines the offset in the target buffer where to store the data
  23439. * @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)
  23440. */
  23441. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23442. /**
  23443. * Creates a new index buffer
  23444. * @param indices defines the indices to store in the index buffer
  23445. * @param totalVertices defines the total number of vertices (could be null)
  23446. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23447. */
  23448. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23449. /**
  23450. * Return the total number of indices
  23451. * @returns the total number of indices
  23452. */
  23453. getTotalIndices(): number;
  23454. /**
  23455. * Gets the index buffer array
  23456. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23457. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23458. * @returns the index buffer array
  23459. */
  23460. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23461. /**
  23462. * Gets the index buffer
  23463. * @return the index buffer
  23464. */
  23465. getIndexBuffer(): Nullable<DataBuffer>;
  23466. /** @hidden */
  23467. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23468. /**
  23469. * Release the associated resources for a specific mesh
  23470. * @param mesh defines the source mesh
  23471. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23472. */
  23473. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23474. /**
  23475. * Apply current geometry to a given mesh
  23476. * @param mesh defines the mesh to apply geometry to
  23477. */
  23478. applyToMesh(mesh: Mesh): void;
  23479. private _updateExtend;
  23480. private _applyToMesh;
  23481. private notifyUpdate;
  23482. /**
  23483. * Load the geometry if it was flagged as delay loaded
  23484. * @param scene defines the hosting scene
  23485. * @param onLoaded defines a callback called when the geometry is loaded
  23486. */
  23487. load(scene: Scene, onLoaded?: () => void): void;
  23488. private _queueLoad;
  23489. /**
  23490. * Invert the geometry to move from a right handed system to a left handed one.
  23491. */
  23492. toLeftHanded(): void;
  23493. /** @hidden */
  23494. _resetPointsArrayCache(): void;
  23495. /** @hidden */
  23496. _generatePointsArray(): boolean;
  23497. /**
  23498. * Gets a value indicating if the geometry is disposed
  23499. * @returns true if the geometry was disposed
  23500. */
  23501. isDisposed(): boolean;
  23502. private _disposeVertexArrayObjects;
  23503. /**
  23504. * Free all associated resources
  23505. */
  23506. dispose(): void;
  23507. /**
  23508. * Clone the current geometry into a new geometry
  23509. * @param id defines the unique ID of the new geometry
  23510. * @returns a new geometry object
  23511. */
  23512. copy(id: string): Geometry;
  23513. /**
  23514. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23515. * @return a JSON representation of the current geometry data (without the vertices data)
  23516. */
  23517. serialize(): any;
  23518. private toNumberArray;
  23519. /**
  23520. * Serialize all vertices data into a JSON oject
  23521. * @returns a JSON representation of the current geometry data
  23522. */
  23523. serializeVerticeData(): any;
  23524. /**
  23525. * Extracts a clone of a mesh geometry
  23526. * @param mesh defines the source mesh
  23527. * @param id defines the unique ID of the new geometry object
  23528. * @returns the new geometry object
  23529. */
  23530. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23531. /**
  23532. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23533. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23534. * Be aware Math.random() could cause collisions, but:
  23535. * "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"
  23536. * @returns a string containing a new GUID
  23537. */
  23538. static RandomId(): string;
  23539. /** @hidden */
  23540. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23541. private static _CleanMatricesWeights;
  23542. /**
  23543. * Create a new geometry from persisted data (Using .babylon file format)
  23544. * @param parsedVertexData defines the persisted data
  23545. * @param scene defines the hosting scene
  23546. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23547. * @returns the new geometry object
  23548. */
  23549. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23550. }
  23551. }
  23552. declare module "babylonjs/Meshes/mesh.vertexData" {
  23553. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23554. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23555. import { Geometry } from "babylonjs/Meshes/geometry";
  23556. import { Mesh } from "babylonjs/Meshes/mesh";
  23557. /**
  23558. * Define an interface for all classes that will get and set the data on vertices
  23559. */
  23560. export interface IGetSetVerticesData {
  23561. /**
  23562. * Gets a boolean indicating if specific vertex data is present
  23563. * @param kind defines the vertex data kind to use
  23564. * @returns true is data kind is present
  23565. */
  23566. isVerticesDataPresent(kind: string): boolean;
  23567. /**
  23568. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23569. * @param kind defines the data kind (Position, normal, etc...)
  23570. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23571. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23572. * @returns a float array containing vertex data
  23573. */
  23574. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23575. /**
  23576. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23577. * @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.
  23578. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23579. * @returns the indices array or an empty array if the mesh has no geometry
  23580. */
  23581. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23582. /**
  23583. * Set specific vertex data
  23584. * @param kind defines the data kind (Position, normal, etc...)
  23585. * @param data defines the vertex data to use
  23586. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23587. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23588. */
  23589. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23590. /**
  23591. * Update a specific associated vertex buffer
  23592. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23593. * - VertexBuffer.PositionKind
  23594. * - VertexBuffer.UVKind
  23595. * - VertexBuffer.UV2Kind
  23596. * - VertexBuffer.UV3Kind
  23597. * - VertexBuffer.UV4Kind
  23598. * - VertexBuffer.UV5Kind
  23599. * - VertexBuffer.UV6Kind
  23600. * - VertexBuffer.ColorKind
  23601. * - VertexBuffer.MatricesIndicesKind
  23602. * - VertexBuffer.MatricesIndicesExtraKind
  23603. * - VertexBuffer.MatricesWeightsKind
  23604. * - VertexBuffer.MatricesWeightsExtraKind
  23605. * @param data defines the data source
  23606. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23607. * @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)
  23608. */
  23609. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23610. /**
  23611. * Creates a new index buffer
  23612. * @param indices defines the indices to store in the index buffer
  23613. * @param totalVertices defines the total number of vertices (could be null)
  23614. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23615. */
  23616. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23617. }
  23618. /**
  23619. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23620. */
  23621. export class VertexData {
  23622. /**
  23623. * Mesh side orientation : usually the external or front surface
  23624. */
  23625. static readonly FRONTSIDE: number;
  23626. /**
  23627. * Mesh side orientation : usually the internal or back surface
  23628. */
  23629. static readonly BACKSIDE: number;
  23630. /**
  23631. * Mesh side orientation : both internal and external or front and back surfaces
  23632. */
  23633. static readonly DOUBLESIDE: number;
  23634. /**
  23635. * Mesh side orientation : by default, `FRONTSIDE`
  23636. */
  23637. static readonly DEFAULTSIDE: number;
  23638. /**
  23639. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23640. */
  23641. positions: Nullable<FloatArray>;
  23642. /**
  23643. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23644. */
  23645. normals: Nullable<FloatArray>;
  23646. /**
  23647. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23648. */
  23649. tangents: Nullable<FloatArray>;
  23650. /**
  23651. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23652. */
  23653. uvs: Nullable<FloatArray>;
  23654. /**
  23655. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23656. */
  23657. uvs2: Nullable<FloatArray>;
  23658. /**
  23659. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23660. */
  23661. uvs3: Nullable<FloatArray>;
  23662. /**
  23663. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23664. */
  23665. uvs4: Nullable<FloatArray>;
  23666. /**
  23667. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23668. */
  23669. uvs5: Nullable<FloatArray>;
  23670. /**
  23671. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23672. */
  23673. uvs6: Nullable<FloatArray>;
  23674. /**
  23675. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23676. */
  23677. colors: Nullable<FloatArray>;
  23678. /**
  23679. * 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).
  23680. */
  23681. matricesIndices: Nullable<FloatArray>;
  23682. /**
  23683. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23684. */
  23685. matricesWeights: Nullable<FloatArray>;
  23686. /**
  23687. * An array extending the number of possible indices
  23688. */
  23689. matricesIndicesExtra: Nullable<FloatArray>;
  23690. /**
  23691. * An array extending the number of possible weights when the number of indices is extended
  23692. */
  23693. matricesWeightsExtra: Nullable<FloatArray>;
  23694. /**
  23695. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23696. */
  23697. indices: Nullable<IndicesArray>;
  23698. /**
  23699. * Uses the passed data array to set the set the values for the specified kind of data
  23700. * @param data a linear array of floating numbers
  23701. * @param kind the type of data that is being set, eg positions, colors etc
  23702. */
  23703. set(data: FloatArray, kind: string): void;
  23704. /**
  23705. * Associates the vertexData to the passed Mesh.
  23706. * Sets it as updatable or not (default `false`)
  23707. * @param mesh the mesh the vertexData is applied to
  23708. * @param updatable when used and having the value true allows new data to update the vertexData
  23709. * @returns the VertexData
  23710. */
  23711. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23712. /**
  23713. * Associates the vertexData to the passed Geometry.
  23714. * Sets it as updatable or not (default `false`)
  23715. * @param geometry the geometry the vertexData is applied to
  23716. * @param updatable when used and having the value true allows new data to update the vertexData
  23717. * @returns VertexData
  23718. */
  23719. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23720. /**
  23721. * Updates the associated mesh
  23722. * @param mesh the mesh to be updated
  23723. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23724. * @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
  23725. * @returns VertexData
  23726. */
  23727. updateMesh(mesh: Mesh): VertexData;
  23728. /**
  23729. * Updates the associated geometry
  23730. * @param geometry the geometry to be updated
  23731. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23732. * @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
  23733. * @returns VertexData.
  23734. */
  23735. updateGeometry(geometry: Geometry): VertexData;
  23736. private _applyTo;
  23737. private _update;
  23738. /**
  23739. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23740. * @param matrix the transforming matrix
  23741. * @returns the VertexData
  23742. */
  23743. transform(matrix: Matrix): VertexData;
  23744. /**
  23745. * Merges the passed VertexData into the current one
  23746. * @param other the VertexData to be merged into the current one
  23747. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23748. * @returns the modified VertexData
  23749. */
  23750. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23751. private _mergeElement;
  23752. private _validate;
  23753. /**
  23754. * Serializes the VertexData
  23755. * @returns a serialized object
  23756. */
  23757. serialize(): any;
  23758. /**
  23759. * Extracts the vertexData from a mesh
  23760. * @param mesh the mesh from which to extract the VertexData
  23761. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23762. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23763. * @returns the object VertexData associated to the passed mesh
  23764. */
  23765. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23766. /**
  23767. * Extracts the vertexData from the geometry
  23768. * @param geometry the geometry from which to extract the VertexData
  23769. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23770. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23771. * @returns the object VertexData associated to the passed mesh
  23772. */
  23773. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23774. private static _ExtractFrom;
  23775. /**
  23776. * Creates the VertexData for a Ribbon
  23777. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23778. * * pathArray array of paths, each of which an array of successive Vector3
  23779. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23780. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23781. * * 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
  23782. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23783. * * 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)
  23784. * * 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)
  23785. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23786. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23787. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23788. * @returns the VertexData of the ribbon
  23789. */
  23790. static CreateRibbon(options: {
  23791. pathArray: Vector3[][];
  23792. closeArray?: boolean;
  23793. closePath?: boolean;
  23794. offset?: number;
  23795. sideOrientation?: number;
  23796. frontUVs?: Vector4;
  23797. backUVs?: Vector4;
  23798. invertUV?: boolean;
  23799. uvs?: Vector2[];
  23800. colors?: Color4[];
  23801. }): VertexData;
  23802. /**
  23803. * Creates the VertexData for a box
  23804. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23805. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23806. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23807. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23808. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23809. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23810. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23811. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23812. * * 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)
  23813. * * 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)
  23814. * @returns the VertexData of the box
  23815. */
  23816. static CreateBox(options: {
  23817. size?: number;
  23818. width?: number;
  23819. height?: number;
  23820. depth?: number;
  23821. faceUV?: Vector4[];
  23822. faceColors?: Color4[];
  23823. sideOrientation?: number;
  23824. frontUVs?: Vector4;
  23825. backUVs?: Vector4;
  23826. }): VertexData;
  23827. /**
  23828. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23829. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23830. * * segments sets the number of horizontal strips optional, default 32
  23831. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23832. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23833. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23834. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23835. * * 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
  23836. * * 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
  23837. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23838. * * 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)
  23839. * * 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)
  23840. * @returns the VertexData of the ellipsoid
  23841. */
  23842. static CreateSphere(options: {
  23843. segments?: number;
  23844. diameter?: number;
  23845. diameterX?: number;
  23846. diameterY?: number;
  23847. diameterZ?: number;
  23848. arc?: number;
  23849. slice?: number;
  23850. sideOrientation?: number;
  23851. frontUVs?: Vector4;
  23852. backUVs?: Vector4;
  23853. }): VertexData;
  23854. /**
  23855. * Creates the VertexData for a cylinder, cone or prism
  23856. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23857. * * height sets the height (y direction) of the cylinder, optional, default 2
  23858. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23859. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23860. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23861. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23862. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23863. * * 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
  23864. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23865. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23866. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23867. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23868. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23869. * * 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)
  23870. * * 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)
  23871. * @returns the VertexData of the cylinder, cone or prism
  23872. */
  23873. static CreateCylinder(options: {
  23874. height?: number;
  23875. diameterTop?: number;
  23876. diameterBottom?: number;
  23877. diameter?: number;
  23878. tessellation?: number;
  23879. subdivisions?: number;
  23880. arc?: number;
  23881. faceColors?: Color4[];
  23882. faceUV?: Vector4[];
  23883. hasRings?: boolean;
  23884. enclose?: boolean;
  23885. sideOrientation?: number;
  23886. frontUVs?: Vector4;
  23887. backUVs?: Vector4;
  23888. }): VertexData;
  23889. /**
  23890. * Creates the VertexData for a torus
  23891. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23892. * * diameter the diameter of the torus, optional default 1
  23893. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23894. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23895. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23896. * * 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)
  23897. * * 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)
  23898. * @returns the VertexData of the torus
  23899. */
  23900. static CreateTorus(options: {
  23901. diameter?: number;
  23902. thickness?: number;
  23903. tessellation?: number;
  23904. sideOrientation?: number;
  23905. frontUVs?: Vector4;
  23906. backUVs?: Vector4;
  23907. }): VertexData;
  23908. /**
  23909. * Creates the VertexData of the LineSystem
  23910. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23911. * - lines an array of lines, each line being an array of successive Vector3
  23912. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23913. * @returns the VertexData of the LineSystem
  23914. */
  23915. static CreateLineSystem(options: {
  23916. lines: Vector3[][];
  23917. colors?: Nullable<Color4[][]>;
  23918. }): VertexData;
  23919. /**
  23920. * Create the VertexData for a DashedLines
  23921. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23922. * - points an array successive Vector3
  23923. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23924. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23925. * - dashNb the intended total number of dashes, optional, default 200
  23926. * @returns the VertexData for the DashedLines
  23927. */
  23928. static CreateDashedLines(options: {
  23929. points: Vector3[];
  23930. dashSize?: number;
  23931. gapSize?: number;
  23932. dashNb?: number;
  23933. }): VertexData;
  23934. /**
  23935. * Creates the VertexData for a Ground
  23936. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23937. * - width the width (x direction) of the ground, optional, default 1
  23938. * - height the height (z direction) of the ground, optional, default 1
  23939. * - subdivisions the number of subdivisions per side, optional, default 1
  23940. * @returns the VertexData of the Ground
  23941. */
  23942. static CreateGround(options: {
  23943. width?: number;
  23944. height?: number;
  23945. subdivisions?: number;
  23946. subdivisionsX?: number;
  23947. subdivisionsY?: number;
  23948. }): VertexData;
  23949. /**
  23950. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23951. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23952. * * xmin the ground minimum X coordinate, optional, default -1
  23953. * * zmin the ground minimum Z coordinate, optional, default -1
  23954. * * xmax the ground maximum X coordinate, optional, default 1
  23955. * * zmax the ground maximum Z coordinate, optional, default 1
  23956. * * 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}
  23957. * * 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}
  23958. * @returns the VertexData of the TiledGround
  23959. */
  23960. static CreateTiledGround(options: {
  23961. xmin: number;
  23962. zmin: number;
  23963. xmax: number;
  23964. zmax: number;
  23965. subdivisions?: {
  23966. w: number;
  23967. h: number;
  23968. };
  23969. precision?: {
  23970. w: number;
  23971. h: number;
  23972. };
  23973. }): VertexData;
  23974. /**
  23975. * Creates the VertexData of the Ground designed from a heightmap
  23976. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23977. * * width the width (x direction) of the ground
  23978. * * height the height (z direction) of the ground
  23979. * * subdivisions the number of subdivisions per side
  23980. * * minHeight the minimum altitude on the ground, optional, default 0
  23981. * * maxHeight the maximum altitude on the ground, optional default 1
  23982. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23983. * * buffer the array holding the image color data
  23984. * * bufferWidth the width of image
  23985. * * bufferHeight the height of image
  23986. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23987. * @returns the VertexData of the Ground designed from a heightmap
  23988. */
  23989. static CreateGroundFromHeightMap(options: {
  23990. width: number;
  23991. height: number;
  23992. subdivisions: number;
  23993. minHeight: number;
  23994. maxHeight: number;
  23995. colorFilter: Color3;
  23996. buffer: Uint8Array;
  23997. bufferWidth: number;
  23998. bufferHeight: number;
  23999. alphaFilter: number;
  24000. }): VertexData;
  24001. /**
  24002. * Creates the VertexData for a Plane
  24003. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24004. * * size sets the width and height of the plane to the value of size, optional default 1
  24005. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24006. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24007. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24008. * * 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)
  24009. * * 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)
  24010. * @returns the VertexData of the box
  24011. */
  24012. static CreatePlane(options: {
  24013. size?: number;
  24014. width?: number;
  24015. height?: number;
  24016. sideOrientation?: number;
  24017. frontUVs?: Vector4;
  24018. backUVs?: Vector4;
  24019. }): VertexData;
  24020. /**
  24021. * Creates the VertexData of the Disc or regular Polygon
  24022. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24023. * * radius the radius of the disc, optional default 0.5
  24024. * * tessellation the number of polygon sides, optional, default 64
  24025. * * 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
  24026. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24027. * * 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)
  24028. * * 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)
  24029. * @returns the VertexData of the box
  24030. */
  24031. static CreateDisc(options: {
  24032. radius?: number;
  24033. tessellation?: number;
  24034. arc?: number;
  24035. sideOrientation?: number;
  24036. frontUVs?: Vector4;
  24037. backUVs?: Vector4;
  24038. }): VertexData;
  24039. /**
  24040. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24041. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24042. * @param polygon a mesh built from polygonTriangulation.build()
  24043. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24044. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24045. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24046. * @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)
  24047. * @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)
  24048. * @returns the VertexData of the Polygon
  24049. */
  24050. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24051. /**
  24052. * Creates the VertexData of the IcoSphere
  24053. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24054. * * radius the radius of the IcoSphere, optional default 1
  24055. * * radiusX allows stretching in the x direction, optional, default radius
  24056. * * radiusY allows stretching in the y direction, optional, default radius
  24057. * * radiusZ allows stretching in the z direction, optional, default radius
  24058. * * flat when true creates a flat shaded mesh, optional, default true
  24059. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24060. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24061. * * 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)
  24062. * * 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)
  24063. * @returns the VertexData of the IcoSphere
  24064. */
  24065. static CreateIcoSphere(options: {
  24066. radius?: number;
  24067. radiusX?: number;
  24068. radiusY?: number;
  24069. radiusZ?: number;
  24070. flat?: boolean;
  24071. subdivisions?: number;
  24072. sideOrientation?: number;
  24073. frontUVs?: Vector4;
  24074. backUVs?: Vector4;
  24075. }): VertexData;
  24076. /**
  24077. * Creates the VertexData for a Polyhedron
  24078. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24079. * * type provided types are:
  24080. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24081. * * 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)
  24082. * * size the size of the IcoSphere, optional default 1
  24083. * * sizeX allows stretching in the x direction, optional, default size
  24084. * * sizeY allows stretching in the y direction, optional, default size
  24085. * * sizeZ allows stretching in the z direction, optional, default size
  24086. * * 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
  24087. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24088. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24089. * * flat when true creates a flat shaded mesh, optional, default true
  24090. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24091. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24092. * * 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)
  24093. * * 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)
  24094. * @returns the VertexData of the Polyhedron
  24095. */
  24096. static CreatePolyhedron(options: {
  24097. type?: number;
  24098. size?: number;
  24099. sizeX?: number;
  24100. sizeY?: number;
  24101. sizeZ?: number;
  24102. custom?: any;
  24103. faceUV?: Vector4[];
  24104. faceColors?: Color4[];
  24105. flat?: boolean;
  24106. sideOrientation?: number;
  24107. frontUVs?: Vector4;
  24108. backUVs?: Vector4;
  24109. }): VertexData;
  24110. /**
  24111. * Creates the VertexData for a TorusKnot
  24112. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24113. * * radius the radius of the torus knot, optional, default 2
  24114. * * tube the thickness of the tube, optional, default 0.5
  24115. * * radialSegments the number of sides on each tube segments, optional, default 32
  24116. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24117. * * p the number of windings around the z axis, optional, default 2
  24118. * * q the number of windings around the x axis, optional, default 3
  24119. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24120. * * 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)
  24121. * * 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)
  24122. * @returns the VertexData of the Torus Knot
  24123. */
  24124. static CreateTorusKnot(options: {
  24125. radius?: number;
  24126. tube?: number;
  24127. radialSegments?: number;
  24128. tubularSegments?: number;
  24129. p?: number;
  24130. q?: number;
  24131. sideOrientation?: number;
  24132. frontUVs?: Vector4;
  24133. backUVs?: Vector4;
  24134. }): VertexData;
  24135. /**
  24136. * Compute normals for given positions and indices
  24137. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24138. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24139. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24140. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24141. * * facetNormals : optional array of facet normals (vector3)
  24142. * * facetPositions : optional array of facet positions (vector3)
  24143. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24144. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24145. * * bInfo : optional bounding info, required for facetPartitioning computation
  24146. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24147. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24148. * * useRightHandedSystem: optional boolean to for right handed system computation
  24149. * * depthSort : optional boolean to enable the facet depth sort computation
  24150. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24151. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24152. */
  24153. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24154. facetNormals?: any;
  24155. facetPositions?: any;
  24156. facetPartitioning?: any;
  24157. ratio?: number;
  24158. bInfo?: any;
  24159. bbSize?: Vector3;
  24160. subDiv?: any;
  24161. useRightHandedSystem?: boolean;
  24162. depthSort?: boolean;
  24163. distanceTo?: Vector3;
  24164. depthSortedFacets?: any;
  24165. }): void;
  24166. /** @hidden */
  24167. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24168. /**
  24169. * Applies VertexData created from the imported parameters to the geometry
  24170. * @param parsedVertexData the parsed data from an imported file
  24171. * @param geometry the geometry to apply the VertexData to
  24172. */
  24173. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24174. }
  24175. }
  24176. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24177. import { Nullable } from "babylonjs/types";
  24178. import { Scene } from "babylonjs/scene";
  24179. import { Vector4 } from "babylonjs/Maths/math";
  24180. import { Mesh } from "babylonjs/Meshes/mesh";
  24181. /**
  24182. * Class containing static functions to help procedurally build meshes
  24183. */
  24184. export class DiscBuilder {
  24185. /**
  24186. * Creates a plane polygonal mesh. By default, this is a disc
  24187. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24188. * * 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
  24189. * * 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
  24190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24191. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24193. * @param name defines the name of the mesh
  24194. * @param options defines the options used to create the mesh
  24195. * @param scene defines the hosting scene
  24196. * @returns the plane polygonal mesh
  24197. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24198. */
  24199. static CreateDisc(name: string, options: {
  24200. radius?: number;
  24201. tessellation?: number;
  24202. arc?: number;
  24203. updatable?: boolean;
  24204. sideOrientation?: number;
  24205. frontUVs?: Vector4;
  24206. backUVs?: Vector4;
  24207. }, scene?: Nullable<Scene>): Mesh;
  24208. }
  24209. }
  24210. declare module "babylonjs/Particles/solidParticleSystem" {
  24211. import { Vector3 } from "babylonjs/Maths/math";
  24212. import { Mesh } from "babylonjs/Meshes/mesh";
  24213. import { Scene, IDisposable } from "babylonjs/scene";
  24214. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24215. /**
  24216. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24217. *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.
  24218. * The SPS is also a particle system. It provides some methods to manage the particles.
  24219. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24220. *
  24221. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24222. */
  24223. export class SolidParticleSystem implements IDisposable {
  24224. /**
  24225. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24226. * Example : var p = SPS.particles[i];
  24227. */
  24228. particles: SolidParticle[];
  24229. /**
  24230. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24231. */
  24232. nbParticles: number;
  24233. /**
  24234. * If the particles must ever face the camera (default false). Useful for planar particles.
  24235. */
  24236. billboard: boolean;
  24237. /**
  24238. * Recompute normals when adding a shape
  24239. */
  24240. recomputeNormals: boolean;
  24241. /**
  24242. * This a counter ofr your own usage. It's not set by any SPS functions.
  24243. */
  24244. counter: number;
  24245. /**
  24246. * The SPS name. This name is also given to the underlying mesh.
  24247. */
  24248. name: string;
  24249. /**
  24250. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24251. */
  24252. mesh: Mesh;
  24253. /**
  24254. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24255. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24256. */
  24257. vars: any;
  24258. /**
  24259. * This array is populated when the SPS is set as 'pickable'.
  24260. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24261. * Each element of this array is an object `{idx: int, faceId: int}`.
  24262. * `idx` is the picked particle index in the `SPS.particles` array
  24263. * `faceId` is the picked face index counted within this particle.
  24264. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24265. */
  24266. pickedParticles: {
  24267. idx: number;
  24268. faceId: number;
  24269. }[];
  24270. /**
  24271. * This array is populated when `enableDepthSort` is set to true.
  24272. * Each element of this array is an instance of the class DepthSortedParticle.
  24273. */
  24274. depthSortedParticles: DepthSortedParticle[];
  24275. /**
  24276. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24277. * @hidden
  24278. */
  24279. _bSphereOnly: boolean;
  24280. /**
  24281. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24282. * @hidden
  24283. */
  24284. _bSphereRadiusFactor: number;
  24285. private _scene;
  24286. private _positions;
  24287. private _indices;
  24288. private _normals;
  24289. private _colors;
  24290. private _uvs;
  24291. private _indices32;
  24292. private _positions32;
  24293. private _normals32;
  24294. private _fixedNormal32;
  24295. private _colors32;
  24296. private _uvs32;
  24297. private _index;
  24298. private _updatable;
  24299. private _pickable;
  24300. private _isVisibilityBoxLocked;
  24301. private _alwaysVisible;
  24302. private _depthSort;
  24303. private _shapeCounter;
  24304. private _copy;
  24305. private _color;
  24306. private _computeParticleColor;
  24307. private _computeParticleTexture;
  24308. private _computeParticleRotation;
  24309. private _computeParticleVertex;
  24310. private _computeBoundingBox;
  24311. private _depthSortParticles;
  24312. private _camera;
  24313. private _mustUnrotateFixedNormals;
  24314. private _particlesIntersect;
  24315. private _needs32Bits;
  24316. /**
  24317. * Creates a SPS (Solid Particle System) object.
  24318. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24319. * @param scene (Scene) is the scene in which the SPS is added.
  24320. * @param options defines the options of the sps e.g.
  24321. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24322. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24323. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24324. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24325. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24326. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24327. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24328. */
  24329. constructor(name: string, scene: Scene, options?: {
  24330. updatable?: boolean;
  24331. isPickable?: boolean;
  24332. enableDepthSort?: boolean;
  24333. particleIntersection?: boolean;
  24334. boundingSphereOnly?: boolean;
  24335. bSphereRadiusFactor?: number;
  24336. });
  24337. /**
  24338. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24339. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24340. * @returns the created mesh
  24341. */
  24342. buildMesh(): Mesh;
  24343. /**
  24344. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24345. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24346. * Thus the particles generated from `digest()` have their property `position` set yet.
  24347. * @param mesh ( Mesh ) is the mesh to be digested
  24348. * @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
  24349. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24350. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24351. * @returns the current SPS
  24352. */
  24353. digest(mesh: Mesh, options?: {
  24354. facetNb?: number;
  24355. number?: number;
  24356. delta?: number;
  24357. }): SolidParticleSystem;
  24358. private _unrotateFixedNormals;
  24359. private _resetCopy;
  24360. private _meshBuilder;
  24361. private _posToShape;
  24362. private _uvsToShapeUV;
  24363. private _addParticle;
  24364. /**
  24365. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24366. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24367. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24368. * @param nb (positive integer) the number of particles to be created from this model
  24369. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24370. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24371. * @returns the number of shapes in the system
  24372. */
  24373. addShape(mesh: Mesh, nb: number, options?: {
  24374. positionFunction?: any;
  24375. vertexFunction?: any;
  24376. }): number;
  24377. private _rebuildParticle;
  24378. /**
  24379. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24380. * @returns the SPS.
  24381. */
  24382. rebuildMesh(): SolidParticleSystem;
  24383. /**
  24384. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24385. * This method calls `updateParticle()` for each particle of the SPS.
  24386. * For an animated SPS, it is usually called within the render loop.
  24387. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24388. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24389. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24390. * @returns the SPS.
  24391. */
  24392. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24393. /**
  24394. * Disposes the SPS.
  24395. */
  24396. dispose(): void;
  24397. /**
  24398. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24399. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24400. * @returns the SPS.
  24401. */
  24402. refreshVisibleSize(): SolidParticleSystem;
  24403. /**
  24404. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24405. * @param size the size (float) of the visibility box
  24406. * note : this doesn't lock the SPS mesh bounding box.
  24407. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24408. */
  24409. setVisibilityBox(size: number): void;
  24410. /**
  24411. * Gets whether the SPS as always visible or not
  24412. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24413. */
  24414. /**
  24415. * Sets the SPS as always visible or not
  24416. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24417. */
  24418. isAlwaysVisible: boolean;
  24419. /**
  24420. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24421. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24422. */
  24423. /**
  24424. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24425. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24426. */
  24427. isVisibilityBoxLocked: boolean;
  24428. /**
  24429. * Tells to `setParticles()` to compute the particle rotations or not.
  24430. * Default value : true. The SPS is faster when it's set to false.
  24431. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24432. */
  24433. /**
  24434. * Gets if `setParticles()` computes the particle rotations or not.
  24435. * Default value : true. The SPS is faster when it's set to false.
  24436. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24437. */
  24438. computeParticleRotation: boolean;
  24439. /**
  24440. * Tells to `setParticles()` to compute the particle colors or not.
  24441. * Default value : true. The SPS is faster when it's set to false.
  24442. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24443. */
  24444. /**
  24445. * Gets if `setParticles()` computes the particle colors or not.
  24446. * Default value : true. The SPS is faster when it's set to false.
  24447. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24448. */
  24449. computeParticleColor: boolean;
  24450. /**
  24451. * Gets if `setParticles()` computes the particle textures or not.
  24452. * Default value : true. The SPS is faster when it's set to false.
  24453. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24454. */
  24455. computeParticleTexture: boolean;
  24456. /**
  24457. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24458. * Default value : false. The SPS is faster when it's set to false.
  24459. * Note : the particle custom vertex positions aren't stored values.
  24460. */
  24461. /**
  24462. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24463. * Default value : false. The SPS is faster when it's set to false.
  24464. * Note : the particle custom vertex positions aren't stored values.
  24465. */
  24466. computeParticleVertex: boolean;
  24467. /**
  24468. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24469. */
  24470. /**
  24471. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24472. */
  24473. computeBoundingBox: boolean;
  24474. /**
  24475. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24476. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24477. * Default : `true`
  24478. */
  24479. /**
  24480. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24481. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24482. * Default : `true`
  24483. */
  24484. depthSortParticles: boolean;
  24485. /**
  24486. * This function does nothing. It may be overwritten to set all the particle first values.
  24487. * The SPS doesn't call this function, you may have to call it by your own.
  24488. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24489. */
  24490. initParticles(): void;
  24491. /**
  24492. * This function does nothing. It may be overwritten to recycle a particle.
  24493. * The SPS doesn't call this function, you may have to call it by your own.
  24494. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24495. * @param particle The particle to recycle
  24496. * @returns the recycled particle
  24497. */
  24498. recycleParticle(particle: SolidParticle): SolidParticle;
  24499. /**
  24500. * Updates a particle : this function should be overwritten by the user.
  24501. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24502. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24503. * @example : just set a particle position or velocity and recycle conditions
  24504. * @param particle The particle to update
  24505. * @returns the updated particle
  24506. */
  24507. updateParticle(particle: SolidParticle): SolidParticle;
  24508. /**
  24509. * Updates a vertex of a particle : it can be overwritten by the user.
  24510. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24511. * @param particle the current particle
  24512. * @param vertex the current index of the current particle
  24513. * @param pt the index of the current vertex in the particle shape
  24514. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24515. * @example : just set a vertex particle position
  24516. * @returns the updated vertex
  24517. */
  24518. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24519. /**
  24520. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24521. * This does nothing and may be overwritten by the user.
  24522. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24523. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24524. * @param update the boolean update value actually passed to setParticles()
  24525. */
  24526. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24527. /**
  24528. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24529. * This will be passed three parameters.
  24530. * This does nothing and may be overwritten by the user.
  24531. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24532. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24533. * @param update the boolean update value actually passed to setParticles()
  24534. */
  24535. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24536. }
  24537. }
  24538. declare module "babylonjs/Particles/solidParticle" {
  24539. import { Nullable } from "babylonjs/types";
  24540. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24541. import { Mesh } from "babylonjs/Meshes/mesh";
  24542. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24543. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24544. /**
  24545. * Represents one particle of a solid particle system.
  24546. */
  24547. export class SolidParticle {
  24548. /**
  24549. * particle global index
  24550. */
  24551. idx: number;
  24552. /**
  24553. * The color of the particle
  24554. */
  24555. color: Nullable<Color4>;
  24556. /**
  24557. * The world space position of the particle.
  24558. */
  24559. position: Vector3;
  24560. /**
  24561. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24562. */
  24563. rotation: Vector3;
  24564. /**
  24565. * The world space rotation quaternion of the particle.
  24566. */
  24567. rotationQuaternion: Nullable<Quaternion>;
  24568. /**
  24569. * The scaling of the particle.
  24570. */
  24571. scaling: Vector3;
  24572. /**
  24573. * The uvs of the particle.
  24574. */
  24575. uvs: Vector4;
  24576. /**
  24577. * The current speed of the particle.
  24578. */
  24579. velocity: Vector3;
  24580. /**
  24581. * The pivot point in the particle local space.
  24582. */
  24583. pivot: Vector3;
  24584. /**
  24585. * Must the particle be translated from its pivot point in its local space ?
  24586. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24587. * Default : false
  24588. */
  24589. translateFromPivot: boolean;
  24590. /**
  24591. * Is the particle active or not ?
  24592. */
  24593. alive: boolean;
  24594. /**
  24595. * Is the particle visible or not ?
  24596. */
  24597. isVisible: boolean;
  24598. /**
  24599. * Index of this particle in the global "positions" array (Internal use)
  24600. * @hidden
  24601. */
  24602. _pos: number;
  24603. /**
  24604. * @hidden Index of this particle in the global "indices" array (Internal use)
  24605. */
  24606. _ind: number;
  24607. /**
  24608. * @hidden ModelShape of this particle (Internal use)
  24609. */
  24610. _model: ModelShape;
  24611. /**
  24612. * ModelShape id of this particle
  24613. */
  24614. shapeId: number;
  24615. /**
  24616. * Index of the particle in its shape id (Internal use)
  24617. */
  24618. idxInShape: number;
  24619. /**
  24620. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24621. */
  24622. _modelBoundingInfo: BoundingInfo;
  24623. /**
  24624. * @hidden Particle BoundingInfo object (Internal use)
  24625. */
  24626. _boundingInfo: BoundingInfo;
  24627. /**
  24628. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24629. */
  24630. _sps: SolidParticleSystem;
  24631. /**
  24632. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24633. */
  24634. _stillInvisible: boolean;
  24635. /**
  24636. * @hidden Last computed particle rotation matrix
  24637. */
  24638. _rotationMatrix: number[];
  24639. /**
  24640. * Parent particle Id, if any.
  24641. * Default null.
  24642. */
  24643. parentId: Nullable<number>;
  24644. /**
  24645. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24646. * The possible values are :
  24647. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24648. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24649. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24650. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24651. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24652. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24653. * */
  24654. cullingStrategy: number;
  24655. /**
  24656. * @hidden Internal global position in the SPS.
  24657. */
  24658. _globalPosition: Vector3;
  24659. /**
  24660. * Creates a Solid Particle object.
  24661. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24662. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24663. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24664. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24665. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24666. * @param shapeId (integer) is the model shape identifier in the SPS.
  24667. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24668. * @param sps defines the sps it is associated to
  24669. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24670. */
  24671. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24672. /**
  24673. * Legacy support, changed scale to scaling
  24674. */
  24675. /**
  24676. * Legacy support, changed scale to scaling
  24677. */
  24678. scale: Vector3;
  24679. /**
  24680. * Legacy support, changed quaternion to rotationQuaternion
  24681. */
  24682. /**
  24683. * Legacy support, changed quaternion to rotationQuaternion
  24684. */
  24685. quaternion: Nullable<Quaternion>;
  24686. /**
  24687. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24688. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24689. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24690. * @returns true if it intersects
  24691. */
  24692. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24693. /**
  24694. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24695. * A particle is in the frustum if its bounding box intersects the frustum
  24696. * @param frustumPlanes defines the frustum to test
  24697. * @returns true if the particle is in the frustum planes
  24698. */
  24699. isInFrustum(frustumPlanes: Plane[]): boolean;
  24700. /**
  24701. * get the rotation matrix of the particle
  24702. * @hidden
  24703. */
  24704. getRotationMatrix(m: Matrix): void;
  24705. }
  24706. /**
  24707. * Represents the shape of the model used by one particle of a solid particle system.
  24708. * SPS internal tool, don't use it manually.
  24709. */
  24710. export class ModelShape {
  24711. /**
  24712. * The shape id
  24713. * @hidden
  24714. */
  24715. shapeID: number;
  24716. /**
  24717. * flat array of model positions (internal use)
  24718. * @hidden
  24719. */
  24720. _shape: Vector3[];
  24721. /**
  24722. * flat array of model UVs (internal use)
  24723. * @hidden
  24724. */
  24725. _shapeUV: number[];
  24726. /**
  24727. * length of the shape in the model indices array (internal use)
  24728. * @hidden
  24729. */
  24730. _indicesLength: number;
  24731. /**
  24732. * Custom position function (internal use)
  24733. * @hidden
  24734. */
  24735. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24736. /**
  24737. * Custom vertex function (internal use)
  24738. * @hidden
  24739. */
  24740. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24741. /**
  24742. * 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.
  24743. * SPS internal tool, don't use it manually.
  24744. * @hidden
  24745. */
  24746. 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>);
  24747. }
  24748. /**
  24749. * Represents a Depth Sorted Particle in the solid particle system.
  24750. */
  24751. export class DepthSortedParticle {
  24752. /**
  24753. * Index of the particle in the "indices" array
  24754. */
  24755. ind: number;
  24756. /**
  24757. * Length of the particle shape in the "indices" array
  24758. */
  24759. indicesLength: number;
  24760. /**
  24761. * Squared distance from the particle to the camera
  24762. */
  24763. sqDistance: number;
  24764. }
  24765. }
  24766. declare module "babylonjs/Meshes/abstractMesh" {
  24767. import { Observable } from "babylonjs/Misc/observable";
  24768. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24769. import { Camera } from "babylonjs/Cameras/camera";
  24770. import { Scene, IDisposable } from "babylonjs/scene";
  24771. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24772. import { Node } from "babylonjs/node";
  24773. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24774. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24775. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24776. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24777. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24778. import { Material } from "babylonjs/Materials/material";
  24779. import { Light } from "babylonjs/Lights/light";
  24780. import { Skeleton } from "babylonjs/Bones/skeleton";
  24781. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24782. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24783. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24784. import { Ray } from "babylonjs/Culling/ray";
  24785. import { Collider } from "babylonjs/Collisions/collider";
  24786. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24787. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  24788. /**
  24789. * Class used to store all common mesh properties
  24790. */
  24791. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24792. /** No occlusion */
  24793. static OCCLUSION_TYPE_NONE: number;
  24794. /** Occlusion set to optimisitic */
  24795. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24796. /** Occlusion set to strict */
  24797. static OCCLUSION_TYPE_STRICT: number;
  24798. /** Use an accurante occlusion algorithm */
  24799. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24800. /** Use a conservative occlusion algorithm */
  24801. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24802. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24803. * Test order :
  24804. * Is the bounding sphere outside the frustum ?
  24805. * If not, are the bounding box vertices outside the frustum ?
  24806. * It not, then the cullable object is in the frustum.
  24807. */
  24808. static readonly CULLINGSTRATEGY_STANDARD: number;
  24809. /** Culling strategy : Bounding Sphere Only.
  24810. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24811. * It's also less accurate than the standard because some not visible objects can still be selected.
  24812. * Test : is the bounding sphere outside the frustum ?
  24813. * If not, then the cullable object is in the frustum.
  24814. */
  24815. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24816. /** Culling strategy : Optimistic Inclusion.
  24817. * This in an inclusion test first, then the standard exclusion test.
  24818. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24819. * 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.
  24820. * Anyway, it's as accurate as the standard strategy.
  24821. * Test :
  24822. * Is the cullable object bounding sphere center in the frustum ?
  24823. * If not, apply the default culling strategy.
  24824. */
  24825. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24826. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24827. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24828. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24829. * 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.
  24830. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24831. * Test :
  24832. * Is the cullable object bounding sphere center in the frustum ?
  24833. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24834. */
  24835. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24836. /**
  24837. * No billboard
  24838. */
  24839. static readonly BILLBOARDMODE_NONE: number;
  24840. /** Billboard on X axis */
  24841. static readonly BILLBOARDMODE_X: number;
  24842. /** Billboard on Y axis */
  24843. static readonly BILLBOARDMODE_Y: number;
  24844. /** Billboard on Z axis */
  24845. static readonly BILLBOARDMODE_Z: number;
  24846. /** Billboard on all axes */
  24847. static readonly BILLBOARDMODE_ALL: number;
  24848. private _facetData;
  24849. /**
  24850. * The culling strategy to use to check whether the mesh must be rendered or not.
  24851. * This value can be changed at any time and will be used on the next render mesh selection.
  24852. * The possible values are :
  24853. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24854. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24855. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24856. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24857. * Please read each static variable documentation to get details about the culling process.
  24858. * */
  24859. cullingStrategy: number;
  24860. /**
  24861. * Gets the number of facets in the mesh
  24862. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24863. */
  24864. readonly facetNb: number;
  24865. /**
  24866. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24867. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24868. */
  24869. partitioningSubdivisions: number;
  24870. /**
  24871. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24872. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24873. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24874. */
  24875. partitioningBBoxRatio: number;
  24876. /**
  24877. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24878. * Works only for updatable meshes.
  24879. * Doesn't work with multi-materials
  24880. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24881. */
  24882. mustDepthSortFacets: boolean;
  24883. /**
  24884. * The location (Vector3) where the facet depth sort must be computed from.
  24885. * By default, the active camera position.
  24886. * Used only when facet depth sort is enabled
  24887. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24888. */
  24889. facetDepthSortFrom: Vector3;
  24890. /**
  24891. * gets a boolean indicating if facetData is enabled
  24892. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24893. */
  24894. readonly isFacetDataEnabled: boolean;
  24895. /** @hidden */
  24896. _updateNonUniformScalingState(value: boolean): boolean;
  24897. /**
  24898. * An event triggered when this mesh collides with another one
  24899. */
  24900. onCollideObservable: Observable<AbstractMesh>;
  24901. private _onCollideObserver;
  24902. /** Set a function to call when this mesh collides with another one */
  24903. onCollide: () => void;
  24904. /**
  24905. * An event triggered when the collision's position changes
  24906. */
  24907. onCollisionPositionChangeObservable: Observable<Vector3>;
  24908. private _onCollisionPositionChangeObserver;
  24909. /** Set a function to call when the collision's position changes */
  24910. onCollisionPositionChange: () => void;
  24911. /**
  24912. * An event triggered when material is changed
  24913. */
  24914. onMaterialChangedObservable: Observable<AbstractMesh>;
  24915. /**
  24916. * Gets or sets the orientation for POV movement & rotation
  24917. */
  24918. definedFacingForward: boolean;
  24919. /** @hidden */
  24920. _occlusionQuery: Nullable<WebGLQuery>;
  24921. private _visibility;
  24922. /** @hidden */
  24923. _isActive: boolean;
  24924. /** @hidden */
  24925. _onlyForInstances: boolean;
  24926. /** @hidden */
  24927. _renderingGroup: Nullable<RenderingGroup>;
  24928. /**
  24929. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24930. */
  24931. /**
  24932. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24933. */
  24934. visibility: number;
  24935. /** Gets or sets the alpha index used to sort transparent meshes
  24936. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24937. */
  24938. alphaIndex: number;
  24939. /**
  24940. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24941. */
  24942. isVisible: boolean;
  24943. /**
  24944. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24945. */
  24946. isPickable: boolean;
  24947. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24948. showSubMeshesBoundingBox: boolean;
  24949. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24950. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24951. */
  24952. isBlocker: boolean;
  24953. /**
  24954. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24955. */
  24956. enablePointerMoveEvents: boolean;
  24957. /**
  24958. * Specifies the rendering group id for this mesh (0 by default)
  24959. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24960. */
  24961. renderingGroupId: number;
  24962. private _material;
  24963. /** Gets or sets current material */
  24964. material: Nullable<Material>;
  24965. private _receiveShadows;
  24966. /**
  24967. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24968. * @see http://doc.babylonjs.com/babylon101/shadows
  24969. */
  24970. receiveShadows: boolean;
  24971. /** Defines color to use when rendering outline */
  24972. outlineColor: Color3;
  24973. /** Define width to use when rendering outline */
  24974. outlineWidth: number;
  24975. /** Defines color to use when rendering overlay */
  24976. overlayColor: Color3;
  24977. /** Defines alpha to use when rendering overlay */
  24978. overlayAlpha: number;
  24979. private _hasVertexAlpha;
  24980. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24981. hasVertexAlpha: boolean;
  24982. private _useVertexColors;
  24983. /** 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) */
  24984. useVertexColors: boolean;
  24985. private _computeBonesUsingShaders;
  24986. /**
  24987. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24988. */
  24989. computeBonesUsingShaders: boolean;
  24990. private _numBoneInfluencers;
  24991. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24992. numBoneInfluencers: number;
  24993. private _applyFog;
  24994. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24995. applyFog: boolean;
  24996. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24997. useOctreeForRenderingSelection: boolean;
  24998. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24999. useOctreeForPicking: boolean;
  25000. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25001. useOctreeForCollisions: boolean;
  25002. private _layerMask;
  25003. /**
  25004. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25005. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25006. */
  25007. layerMask: number;
  25008. /**
  25009. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25010. */
  25011. alwaysSelectAsActiveMesh: boolean;
  25012. /**
  25013. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25014. */
  25015. doNotSyncBoundingInfo: boolean;
  25016. /**
  25017. * Gets or sets the current action manager
  25018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25019. */
  25020. actionManager: Nullable<AbstractActionManager>;
  25021. private _checkCollisions;
  25022. private _collisionMask;
  25023. private _collisionGroup;
  25024. /**
  25025. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25026. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25027. */
  25028. ellipsoid: Vector3;
  25029. /**
  25030. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25031. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25032. */
  25033. ellipsoidOffset: Vector3;
  25034. private _collider;
  25035. private _oldPositionForCollisions;
  25036. private _diffPositionForCollisions;
  25037. /**
  25038. * Gets or sets a collision mask used to mask collisions (default is -1).
  25039. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25040. */
  25041. collisionMask: number;
  25042. /**
  25043. * Gets or sets the current collision group mask (-1 by default).
  25044. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25045. */
  25046. collisionGroup: number;
  25047. /**
  25048. * Defines edge width used when edgesRenderer is enabled
  25049. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25050. */
  25051. edgesWidth: number;
  25052. /**
  25053. * Defines edge color used when edgesRenderer is enabled
  25054. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25055. */
  25056. edgesColor: Color4;
  25057. /** @hidden */
  25058. _edgesRenderer: Nullable<IEdgesRenderer>;
  25059. /** @hidden */
  25060. _masterMesh: Nullable<AbstractMesh>;
  25061. /** @hidden */
  25062. _boundingInfo: Nullable<BoundingInfo>;
  25063. /** @hidden */
  25064. _renderId: number;
  25065. /**
  25066. * Gets or sets the list of subMeshes
  25067. * @see http://doc.babylonjs.com/how_to/multi_materials
  25068. */
  25069. subMeshes: SubMesh[];
  25070. /** @hidden */
  25071. _intersectionsInProgress: AbstractMesh[];
  25072. /** @hidden */
  25073. _unIndexed: boolean;
  25074. /** @hidden */
  25075. _lightSources: Light[];
  25076. /** @hidden */
  25077. readonly _positions: Nullable<Vector3[]>;
  25078. /** @hidden */
  25079. _waitingActions: Nullable<any>;
  25080. /** @hidden */
  25081. _waitingFreezeWorldMatrix: Nullable<boolean>;
  25082. private _skeleton;
  25083. /** @hidden */
  25084. _bonesTransformMatrices: Nullable<Float32Array>;
  25085. /**
  25086. * Gets or sets a skeleton to apply skining transformations
  25087. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25088. */
  25089. skeleton: Nullable<Skeleton>;
  25090. /**
  25091. * An event triggered when the mesh is rebuilt.
  25092. */
  25093. onRebuildObservable: Observable<AbstractMesh>;
  25094. /**
  25095. * Creates a new AbstractMesh
  25096. * @param name defines the name of the mesh
  25097. * @param scene defines the hosting scene
  25098. */
  25099. constructor(name: string, scene?: Nullable<Scene>);
  25100. /**
  25101. * Returns the string "AbstractMesh"
  25102. * @returns "AbstractMesh"
  25103. */
  25104. getClassName(): string;
  25105. /**
  25106. * Gets a string representation of the current mesh
  25107. * @param fullDetails defines a boolean indicating if full details must be included
  25108. * @returns a string representation of the current mesh
  25109. */
  25110. toString(fullDetails?: boolean): string;
  25111. /**
  25112. * @hidden
  25113. */
  25114. protected _getEffectiveParent(): Nullable<Node>;
  25115. /** @hidden */
  25116. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25117. /** @hidden */
  25118. _rebuild(): void;
  25119. /** @hidden */
  25120. _resyncLightSources(): void;
  25121. /** @hidden */
  25122. _resyncLighSource(light: Light): void;
  25123. /** @hidden */
  25124. _unBindEffect(): void;
  25125. /** @hidden */
  25126. _removeLightSource(light: Light): void;
  25127. private _markSubMeshesAsDirty;
  25128. /** @hidden */
  25129. _markSubMeshesAsLightDirty(): void;
  25130. /** @hidden */
  25131. _markSubMeshesAsAttributesDirty(): void;
  25132. /** @hidden */
  25133. _markSubMeshesAsMiscDirty(): void;
  25134. /**
  25135. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25136. */
  25137. scaling: Vector3;
  25138. /**
  25139. * Returns true if the mesh is blocked. Implemented by child classes
  25140. */
  25141. readonly isBlocked: boolean;
  25142. /**
  25143. * Returns the mesh itself by default. Implemented by child classes
  25144. * @param camera defines the camera to use to pick the right LOD level
  25145. * @returns the currentAbstractMesh
  25146. */
  25147. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25148. /**
  25149. * Returns 0 by default. Implemented by child classes
  25150. * @returns an integer
  25151. */
  25152. getTotalVertices(): number;
  25153. /**
  25154. * Returns a positive integer : the total number of indices in this mesh geometry.
  25155. * @returns the numner of indices or zero if the mesh has no geometry.
  25156. */
  25157. getTotalIndices(): number;
  25158. /**
  25159. * Returns null by default. Implemented by child classes
  25160. * @returns null
  25161. */
  25162. getIndices(): Nullable<IndicesArray>;
  25163. /**
  25164. * Returns the array of the requested vertex data kind. Implemented by child classes
  25165. * @param kind defines the vertex data kind to use
  25166. * @returns null
  25167. */
  25168. getVerticesData(kind: string): Nullable<FloatArray>;
  25169. /**
  25170. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25171. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25172. * Note that a new underlying VertexBuffer object is created each call.
  25173. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25174. * @param kind defines vertex data kind:
  25175. * * VertexBuffer.PositionKind
  25176. * * VertexBuffer.UVKind
  25177. * * VertexBuffer.UV2Kind
  25178. * * VertexBuffer.UV3Kind
  25179. * * VertexBuffer.UV4Kind
  25180. * * VertexBuffer.UV5Kind
  25181. * * VertexBuffer.UV6Kind
  25182. * * VertexBuffer.ColorKind
  25183. * * VertexBuffer.MatricesIndicesKind
  25184. * * VertexBuffer.MatricesIndicesExtraKind
  25185. * * VertexBuffer.MatricesWeightsKind
  25186. * * VertexBuffer.MatricesWeightsExtraKind
  25187. * @param data defines the data source
  25188. * @param updatable defines if the data must be flagged as updatable (or static)
  25189. * @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
  25190. * @returns the current mesh
  25191. */
  25192. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25193. /**
  25194. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25195. * If the mesh has no geometry, it is simply returned as it is.
  25196. * @param kind defines vertex data kind:
  25197. * * VertexBuffer.PositionKind
  25198. * * VertexBuffer.UVKind
  25199. * * VertexBuffer.UV2Kind
  25200. * * VertexBuffer.UV3Kind
  25201. * * VertexBuffer.UV4Kind
  25202. * * VertexBuffer.UV5Kind
  25203. * * VertexBuffer.UV6Kind
  25204. * * VertexBuffer.ColorKind
  25205. * * VertexBuffer.MatricesIndicesKind
  25206. * * VertexBuffer.MatricesIndicesExtraKind
  25207. * * VertexBuffer.MatricesWeightsKind
  25208. * * VertexBuffer.MatricesWeightsExtraKind
  25209. * @param data defines the data source
  25210. * @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
  25211. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25212. * @returns the current mesh
  25213. */
  25214. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25215. /**
  25216. * Sets the mesh indices,
  25217. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25218. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25219. * @param totalVertices Defines the total number of vertices
  25220. * @returns the current mesh
  25221. */
  25222. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25223. /**
  25224. * Gets a boolean indicating if specific vertex data is present
  25225. * @param kind defines the vertex data kind to use
  25226. * @returns true is data kind is present
  25227. */
  25228. isVerticesDataPresent(kind: string): boolean;
  25229. /**
  25230. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25231. * @returns a BoundingInfo
  25232. */
  25233. getBoundingInfo(): BoundingInfo;
  25234. /**
  25235. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25236. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25237. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25238. * @returns the current mesh
  25239. */
  25240. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  25241. /**
  25242. * Overwrite the current bounding info
  25243. * @param boundingInfo defines the new bounding info
  25244. * @returns the current mesh
  25245. */
  25246. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25247. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25248. readonly useBones: boolean;
  25249. /** @hidden */
  25250. _preActivate(): void;
  25251. /** @hidden */
  25252. _preActivateForIntermediateRendering(renderId: number): void;
  25253. /** @hidden */
  25254. _activate(renderId: number): boolean;
  25255. /** @hidden */
  25256. _freeze(): void;
  25257. /** @hidden */
  25258. _unFreeze(): void;
  25259. /**
  25260. * Gets the current world matrix
  25261. * @returns a Matrix
  25262. */
  25263. getWorldMatrix(): Matrix;
  25264. /** @hidden */
  25265. _getWorldMatrixDeterminant(): number;
  25266. /**
  25267. * Perform relative position change from the point of view of behind the front of the mesh.
  25268. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25269. * Supports definition of mesh facing forward or backward
  25270. * @param amountRight defines the distance on the right axis
  25271. * @param amountUp defines the distance on the up axis
  25272. * @param amountForward defines the distance on the forward axis
  25273. * @returns the current mesh
  25274. */
  25275. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25276. /**
  25277. * Calculate relative position change from the point of view of behind the front of the mesh.
  25278. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25279. * Supports definition of mesh facing forward or backward
  25280. * @param amountRight defines the distance on the right axis
  25281. * @param amountUp defines the distance on the up axis
  25282. * @param amountForward defines the distance on the forward axis
  25283. * @returns the new displacement vector
  25284. */
  25285. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25286. /**
  25287. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25288. * Supports definition of mesh facing forward or backward
  25289. * @param flipBack defines the flip
  25290. * @param twirlClockwise defines the twirl
  25291. * @param tiltRight defines the tilt
  25292. * @returns the current mesh
  25293. */
  25294. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25295. /**
  25296. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25297. * Supports definition of mesh facing forward or backward.
  25298. * @param flipBack defines the flip
  25299. * @param twirlClockwise defines the twirl
  25300. * @param tiltRight defines the tilt
  25301. * @returns the new rotation vector
  25302. */
  25303. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25304. /**
  25305. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25306. * This means the mesh underlying bounding box and sphere are recomputed.
  25307. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25308. * @returns the current mesh
  25309. */
  25310. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25311. /** @hidden */
  25312. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25313. /** @hidden */
  25314. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25315. /** @hidden */
  25316. _updateBoundingInfo(): AbstractMesh;
  25317. /** @hidden */
  25318. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25319. /** @hidden */
  25320. protected _afterComputeWorldMatrix(): void;
  25321. /** @hidden */
  25322. readonly _effectiveMesh: AbstractMesh;
  25323. /**
  25324. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25325. * A mesh is in the frustum if its bounding box intersects the frustum
  25326. * @param frustumPlanes defines the frustum to test
  25327. * @returns true if the mesh is in the frustum planes
  25328. */
  25329. isInFrustum(frustumPlanes: Plane[]): boolean;
  25330. /**
  25331. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25332. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25333. * @param frustumPlanes defines the frustum to test
  25334. * @returns true if the mesh is completely in the frustum planes
  25335. */
  25336. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25337. /**
  25338. * True if the mesh intersects another mesh or a SolidParticle object
  25339. * @param mesh defines a target mesh or SolidParticle to test
  25340. * @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)
  25341. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25342. * @returns true if there is an intersection
  25343. */
  25344. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25345. /**
  25346. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25347. * @param point defines the point to test
  25348. * @returns true if there is an intersection
  25349. */
  25350. intersectsPoint(point: Vector3): boolean;
  25351. /**
  25352. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25353. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25354. */
  25355. checkCollisions: boolean;
  25356. /**
  25357. * Gets Collider object used to compute collisions (not physics)
  25358. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25359. */
  25360. readonly collider: Nullable<Collider>;
  25361. /**
  25362. * Move the mesh using collision engine
  25363. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25364. * @param displacement defines the requested displacement vector
  25365. * @returns the current mesh
  25366. */
  25367. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25368. private _onCollisionPositionChange;
  25369. /** @hidden */
  25370. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25371. /** @hidden */
  25372. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25373. /** @hidden */
  25374. _checkCollision(collider: Collider): AbstractMesh;
  25375. /** @hidden */
  25376. _generatePointsArray(): boolean;
  25377. /**
  25378. * Checks if the passed Ray intersects with the mesh
  25379. * @param ray defines the ray to use
  25380. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25381. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25382. * @returns the picking info
  25383. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25384. */
  25385. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25386. /**
  25387. * Clones the current mesh
  25388. * @param name defines the mesh name
  25389. * @param newParent defines the new mesh parent
  25390. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25391. * @returns the new mesh
  25392. */
  25393. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25394. /**
  25395. * Disposes all the submeshes of the current meshnp
  25396. * @returns the current mesh
  25397. */
  25398. releaseSubMeshes(): AbstractMesh;
  25399. /**
  25400. * Releases resources associated with this abstract mesh.
  25401. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25402. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25403. */
  25404. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25405. /**
  25406. * Adds the passed mesh as a child to the current mesh
  25407. * @param mesh defines the child mesh
  25408. * @returns the current mesh
  25409. */
  25410. addChild(mesh: AbstractMesh): AbstractMesh;
  25411. /**
  25412. * Removes the passed mesh from the current mesh children list
  25413. * @param mesh defines the child mesh
  25414. * @returns the current mesh
  25415. */
  25416. removeChild(mesh: AbstractMesh): AbstractMesh;
  25417. /** @hidden */
  25418. private _initFacetData;
  25419. /**
  25420. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25421. * This method can be called within the render loop.
  25422. * 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
  25423. * @returns the current mesh
  25424. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25425. */
  25426. updateFacetData(): AbstractMesh;
  25427. /**
  25428. * Returns the facetLocalNormals array.
  25429. * The normals are expressed in the mesh local spac
  25430. * @returns an array of Vector3
  25431. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25432. */
  25433. getFacetLocalNormals(): Vector3[];
  25434. /**
  25435. * Returns the facetLocalPositions array.
  25436. * The facet positions are expressed in the mesh local space
  25437. * @returns an array of Vector3
  25438. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25439. */
  25440. getFacetLocalPositions(): Vector3[];
  25441. /**
  25442. * Returns the facetLocalPartioning array
  25443. * @returns an array of array of numbers
  25444. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25445. */
  25446. getFacetLocalPartitioning(): number[][];
  25447. /**
  25448. * Returns the i-th facet position in the world system.
  25449. * This method allocates a new Vector3 per call
  25450. * @param i defines the facet index
  25451. * @returns a new Vector3
  25452. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25453. */
  25454. getFacetPosition(i: number): Vector3;
  25455. /**
  25456. * Sets the reference Vector3 with the i-th facet position in the world system
  25457. * @param i defines the facet index
  25458. * @param ref defines the target vector
  25459. * @returns the current mesh
  25460. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25461. */
  25462. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25463. /**
  25464. * Returns the i-th facet normal in the world system.
  25465. * This method allocates a new Vector3 per call
  25466. * @param i defines the facet index
  25467. * @returns a new Vector3
  25468. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25469. */
  25470. getFacetNormal(i: number): Vector3;
  25471. /**
  25472. * Sets the reference Vector3 with the i-th facet normal in the world system
  25473. * @param i defines the facet index
  25474. * @param ref defines the target vector
  25475. * @returns the current mesh
  25476. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25477. */
  25478. getFacetNormalToRef(i: number, ref: Vector3): this;
  25479. /**
  25480. * 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)
  25481. * @param x defines x coordinate
  25482. * @param y defines y coordinate
  25483. * @param z defines z coordinate
  25484. * @returns the array of facet indexes
  25485. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25486. */
  25487. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25488. /**
  25489. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25490. * @param projected sets as the (x,y,z) world projection on the facet
  25491. * @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
  25492. * @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
  25493. * @param x defines x coordinate
  25494. * @param y defines y coordinate
  25495. * @param z defines z coordinate
  25496. * @returns the face index if found (or null instead)
  25497. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25498. */
  25499. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25500. /**
  25501. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25502. * @param projected sets as the (x,y,z) local projection on the facet
  25503. * @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
  25504. * @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
  25505. * @param x defines x coordinate
  25506. * @param y defines y coordinate
  25507. * @param z defines z coordinate
  25508. * @returns the face index if found (or null instead)
  25509. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25510. */
  25511. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25512. /**
  25513. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25514. * @returns the parameters
  25515. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25516. */
  25517. getFacetDataParameters(): any;
  25518. /**
  25519. * Disables the feature FacetData and frees the related memory
  25520. * @returns the current mesh
  25521. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25522. */
  25523. disableFacetData(): AbstractMesh;
  25524. /**
  25525. * Updates the AbstractMesh indices array
  25526. * @param indices defines the data source
  25527. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25528. * @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)
  25529. * @returns the current mesh
  25530. */
  25531. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25532. /**
  25533. * Creates new normals data for the mesh
  25534. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25535. * @returns the current mesh
  25536. */
  25537. createNormals(updatable: boolean): AbstractMesh;
  25538. /**
  25539. * Align the mesh with a normal
  25540. * @param normal defines the normal to use
  25541. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25542. * @returns the current mesh
  25543. */
  25544. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25545. /** @hidden */
  25546. _checkOcclusionQuery(): boolean;
  25547. }
  25548. }
  25549. declare module "babylonjs/Actions/actionEvent" {
  25550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25551. import { Nullable } from "babylonjs/types";
  25552. import { Sprite } from "babylonjs/Sprites/sprite";
  25553. import { Scene } from "babylonjs/scene";
  25554. import { Vector2 } from "babylonjs/Maths/math";
  25555. /**
  25556. * Interface used to define ActionEvent
  25557. */
  25558. export interface IActionEvent {
  25559. /** The mesh or sprite that triggered the action */
  25560. source: any;
  25561. /** The X mouse cursor position at the time of the event */
  25562. pointerX: number;
  25563. /** The Y mouse cursor position at the time of the event */
  25564. pointerY: number;
  25565. /** The mesh that is currently pointed at (can be null) */
  25566. meshUnderPointer: Nullable<AbstractMesh>;
  25567. /** the original (browser) event that triggered the ActionEvent */
  25568. sourceEvent?: any;
  25569. /** additional data for the event */
  25570. additionalData?: any;
  25571. }
  25572. /**
  25573. * ActionEvent is the event being sent when an action is triggered.
  25574. */
  25575. export class ActionEvent implements IActionEvent {
  25576. /** The mesh or sprite that triggered the action */
  25577. source: any;
  25578. /** The X mouse cursor position at the time of the event */
  25579. pointerX: number;
  25580. /** The Y mouse cursor position at the time of the event */
  25581. pointerY: number;
  25582. /** The mesh that is currently pointed at (can be null) */
  25583. meshUnderPointer: Nullable<AbstractMesh>;
  25584. /** the original (browser) event that triggered the ActionEvent */
  25585. sourceEvent?: any;
  25586. /** additional data for the event */
  25587. additionalData?: any;
  25588. /**
  25589. * Creates a new ActionEvent
  25590. * @param source The mesh or sprite that triggered the action
  25591. * @param pointerX The X mouse cursor position at the time of the event
  25592. * @param pointerY The Y mouse cursor position at the time of the event
  25593. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25594. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25595. * @param additionalData additional data for the event
  25596. */
  25597. constructor(
  25598. /** The mesh or sprite that triggered the action */
  25599. source: any,
  25600. /** The X mouse cursor position at the time of the event */
  25601. pointerX: number,
  25602. /** The Y mouse cursor position at the time of the event */
  25603. pointerY: number,
  25604. /** The mesh that is currently pointed at (can be null) */
  25605. meshUnderPointer: Nullable<AbstractMesh>,
  25606. /** the original (browser) event that triggered the ActionEvent */
  25607. sourceEvent?: any,
  25608. /** additional data for the event */
  25609. additionalData?: any);
  25610. /**
  25611. * Helper function to auto-create an ActionEvent from a source mesh.
  25612. * @param source The source mesh that triggered the event
  25613. * @param evt The original (browser) event
  25614. * @param additionalData additional data for the event
  25615. * @returns the new ActionEvent
  25616. */
  25617. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25618. /**
  25619. * Helper function to auto-create an ActionEvent from a source sprite
  25620. * @param source The source sprite that triggered the event
  25621. * @param scene Scene associated with the sprite
  25622. * @param evt The original (browser) event
  25623. * @param additionalData additional data for the event
  25624. * @returns the new ActionEvent
  25625. */
  25626. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25627. /**
  25628. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25629. * @param scene the scene where the event occurred
  25630. * @param evt The original (browser) event
  25631. * @returns the new ActionEvent
  25632. */
  25633. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25634. /**
  25635. * Helper function to auto-create an ActionEvent from a primitive
  25636. * @param prim defines the target primitive
  25637. * @param pointerPos defines the pointer position
  25638. * @param evt The original (browser) event
  25639. * @param additionalData additional data for the event
  25640. * @returns the new ActionEvent
  25641. */
  25642. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25643. }
  25644. }
  25645. declare module "babylonjs/Actions/abstractActionManager" {
  25646. import { IDisposable } from "babylonjs/scene";
  25647. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25648. import { IAction } from "babylonjs/Actions/action";
  25649. import { Nullable } from "babylonjs/types";
  25650. /**
  25651. * Abstract class used to decouple action Manager from scene and meshes.
  25652. * Do not instantiate.
  25653. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25654. */
  25655. export abstract class AbstractActionManager implements IDisposable {
  25656. /** Gets the list of active triggers */
  25657. static Triggers: {
  25658. [key: string]: number;
  25659. };
  25660. /** Gets the cursor to use when hovering items */
  25661. hoverCursor: string;
  25662. /** Gets the list of actions */
  25663. actions: IAction[];
  25664. /**
  25665. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25666. */
  25667. isRecursive: boolean;
  25668. /**
  25669. * Releases all associated resources
  25670. */
  25671. abstract dispose(): void;
  25672. /**
  25673. * Does this action manager has pointer triggers
  25674. */
  25675. abstract readonly hasPointerTriggers: boolean;
  25676. /**
  25677. * Does this action manager has pick triggers
  25678. */
  25679. abstract readonly hasPickTriggers: boolean;
  25680. /**
  25681. * Process a specific trigger
  25682. * @param trigger defines the trigger to process
  25683. * @param evt defines the event details to be processed
  25684. */
  25685. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25686. /**
  25687. * Does this action manager handles actions of any of the given triggers
  25688. * @param triggers defines the triggers to be tested
  25689. * @return a boolean indicating whether one (or more) of the triggers is handled
  25690. */
  25691. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25692. /**
  25693. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25694. * speed.
  25695. * @param triggerA defines the trigger to be tested
  25696. * @param triggerB defines the trigger to be tested
  25697. * @return a boolean indicating whether one (or more) of the triggers is handled
  25698. */
  25699. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25700. /**
  25701. * Does this action manager handles actions of a given trigger
  25702. * @param trigger defines the trigger to be tested
  25703. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25704. * @return whether the trigger is handled
  25705. */
  25706. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25707. /**
  25708. * Serialize this manager to a JSON object
  25709. * @param name defines the property name to store this manager
  25710. * @returns a JSON representation of this manager
  25711. */
  25712. abstract serialize(name: string): any;
  25713. /**
  25714. * Registers an action to this action manager
  25715. * @param action defines the action to be registered
  25716. * @return the action amended (prepared) after registration
  25717. */
  25718. abstract registerAction(action: IAction): Nullable<IAction>;
  25719. /**
  25720. * Unregisters an action to this action manager
  25721. * @param action defines the action to be unregistered
  25722. * @return a boolean indicating whether the action has been unregistered
  25723. */
  25724. abstract unregisterAction(action: IAction): Boolean;
  25725. /**
  25726. * Does exist one action manager with at least one trigger
  25727. **/
  25728. static readonly HasTriggers: boolean;
  25729. /**
  25730. * Does exist one action manager with at least one pick trigger
  25731. **/
  25732. static readonly HasPickTriggers: boolean;
  25733. /**
  25734. * Does exist one action manager that handles actions of a given trigger
  25735. * @param trigger defines the trigger to be tested
  25736. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25737. **/
  25738. static HasSpecificTrigger(trigger: number): boolean;
  25739. }
  25740. }
  25741. declare module "babylonjs/node" {
  25742. import { Scene } from "babylonjs/scene";
  25743. import { Nullable } from "babylonjs/types";
  25744. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  25745. import { Engine } from "babylonjs/Engines/engine";
  25746. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25747. import { Observable } from "babylonjs/Misc/observable";
  25748. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25749. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25750. import { Animatable } from "babylonjs/Animations/animatable";
  25751. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25752. import { Animation } from "babylonjs/Animations/animation";
  25753. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25755. /**
  25756. * Defines how a node can be built from a string name.
  25757. */
  25758. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25759. /**
  25760. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25761. */
  25762. export class Node implements IBehaviorAware<Node> {
  25763. /** @hidden */
  25764. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25765. private static _NodeConstructors;
  25766. /**
  25767. * Add a new node constructor
  25768. * @param type defines the type name of the node to construct
  25769. * @param constructorFunc defines the constructor function
  25770. */
  25771. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25772. /**
  25773. * Returns a node constructor based on type name
  25774. * @param type defines the type name
  25775. * @param name defines the new node name
  25776. * @param scene defines the hosting scene
  25777. * @param options defines optional options to transmit to constructors
  25778. * @returns the new constructor or null
  25779. */
  25780. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25781. /**
  25782. * Gets or sets the name of the node
  25783. */
  25784. name: string;
  25785. /**
  25786. * Gets or sets the id of the node
  25787. */
  25788. id: string;
  25789. /**
  25790. * Gets or sets the unique id of the node
  25791. */
  25792. uniqueId: number;
  25793. /**
  25794. * Gets or sets a string used to store user defined state for the node
  25795. */
  25796. state: string;
  25797. /**
  25798. * Gets or sets an object used to store user defined information for the node
  25799. */
  25800. metadata: any;
  25801. /**
  25802. * For internal use only. Please do not use.
  25803. */
  25804. reservedDataStore: any;
  25805. /**
  25806. * List of inspectable custom properties (used by the Inspector)
  25807. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25808. */
  25809. inspectableCustomProperties: IInspectable[];
  25810. /**
  25811. * Gets or sets a boolean used to define if the node must be serialized
  25812. */
  25813. doNotSerialize: boolean;
  25814. /** @hidden */
  25815. _isDisposed: boolean;
  25816. /**
  25817. * Gets a list of Animations associated with the node
  25818. */
  25819. animations: import("babylonjs/Animations/animation").Animation[];
  25820. protected _ranges: {
  25821. [name: string]: Nullable<AnimationRange>;
  25822. };
  25823. /**
  25824. * Callback raised when the node is ready to be used
  25825. */
  25826. onReady: Nullable<(node: Node) => void>;
  25827. private _isEnabled;
  25828. private _isParentEnabled;
  25829. private _isReady;
  25830. /** @hidden */
  25831. _currentRenderId: number;
  25832. private _parentUpdateId;
  25833. /** @hidden */
  25834. _childUpdateId: number;
  25835. /** @hidden */
  25836. _waitingParentId: Nullable<string>;
  25837. /** @hidden */
  25838. _scene: Scene;
  25839. /** @hidden */
  25840. _cache: any;
  25841. private _parentNode;
  25842. private _children;
  25843. /** @hidden */
  25844. _worldMatrix: Matrix;
  25845. /** @hidden */
  25846. _worldMatrixDeterminant: number;
  25847. /** @hidden */
  25848. _worldMatrixDeterminantIsDirty: boolean;
  25849. /** @hidden */
  25850. private _sceneRootNodesIndex;
  25851. /**
  25852. * Gets a boolean indicating if the node has been disposed
  25853. * @returns true if the node was disposed
  25854. */
  25855. isDisposed(): boolean;
  25856. /**
  25857. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25858. * @see https://doc.babylonjs.com/how_to/parenting
  25859. */
  25860. parent: Nullable<Node>;
  25861. private addToSceneRootNodes;
  25862. private removeFromSceneRootNodes;
  25863. private _animationPropertiesOverride;
  25864. /**
  25865. * Gets or sets the animation properties override
  25866. */
  25867. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25868. /**
  25869. * Gets a string idenfifying the name of the class
  25870. * @returns "Node" string
  25871. */
  25872. getClassName(): string;
  25873. /** @hidden */
  25874. readonly _isNode: boolean;
  25875. /**
  25876. * An event triggered when the mesh is disposed
  25877. */
  25878. onDisposeObservable: Observable<Node>;
  25879. private _onDisposeObserver;
  25880. /**
  25881. * Sets a callback that will be raised when the node will be disposed
  25882. */
  25883. onDispose: () => void;
  25884. /**
  25885. * Creates a new Node
  25886. * @param name the name and id to be given to this node
  25887. * @param scene the scene this node will be added to
  25888. * @param addToRootNodes the node will be added to scene.rootNodes
  25889. */
  25890. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25891. /**
  25892. * Gets the scene of the node
  25893. * @returns a scene
  25894. */
  25895. getScene(): Scene;
  25896. /**
  25897. * Gets the engine of the node
  25898. * @returns a Engine
  25899. */
  25900. getEngine(): Engine;
  25901. private _behaviors;
  25902. /**
  25903. * Attach a behavior to the node
  25904. * @see http://doc.babylonjs.com/features/behaviour
  25905. * @param behavior defines the behavior to attach
  25906. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25907. * @returns the current Node
  25908. */
  25909. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25910. /**
  25911. * Remove an attached behavior
  25912. * @see http://doc.babylonjs.com/features/behaviour
  25913. * @param behavior defines the behavior to attach
  25914. * @returns the current Node
  25915. */
  25916. removeBehavior(behavior: Behavior<Node>): Node;
  25917. /**
  25918. * Gets the list of attached behaviors
  25919. * @see http://doc.babylonjs.com/features/behaviour
  25920. */
  25921. readonly behaviors: Behavior<Node>[];
  25922. /**
  25923. * Gets an attached behavior by name
  25924. * @param name defines the name of the behavior to look for
  25925. * @see http://doc.babylonjs.com/features/behaviour
  25926. * @returns null if behavior was not found else the requested behavior
  25927. */
  25928. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25929. /**
  25930. * Returns the latest update of the World matrix
  25931. * @returns a Matrix
  25932. */
  25933. getWorldMatrix(): Matrix;
  25934. /** @hidden */
  25935. _getWorldMatrixDeterminant(): number;
  25936. /**
  25937. * Returns directly the latest state of the mesh World matrix.
  25938. * A Matrix is returned.
  25939. */
  25940. readonly worldMatrixFromCache: Matrix;
  25941. /** @hidden */
  25942. _initCache(): void;
  25943. /** @hidden */
  25944. updateCache(force?: boolean): void;
  25945. /** @hidden */
  25946. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25947. /** @hidden */
  25948. _updateCache(ignoreParentClass?: boolean): void;
  25949. /** @hidden */
  25950. _isSynchronized(): boolean;
  25951. /** @hidden */
  25952. _markSyncedWithParent(): void;
  25953. /** @hidden */
  25954. isSynchronizedWithParent(): boolean;
  25955. /** @hidden */
  25956. isSynchronized(): boolean;
  25957. /**
  25958. * Is this node ready to be used/rendered
  25959. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25960. * @return true if the node is ready
  25961. */
  25962. isReady(completeCheck?: boolean): boolean;
  25963. /**
  25964. * Is this node enabled?
  25965. * 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
  25966. * @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
  25967. * @return whether this node (and its parent) is enabled
  25968. */
  25969. isEnabled(checkAncestors?: boolean): boolean;
  25970. /** @hidden */
  25971. protected _syncParentEnabledState(): void;
  25972. /**
  25973. * Set the enabled state of this node
  25974. * @param value defines the new enabled state
  25975. */
  25976. setEnabled(value: boolean): void;
  25977. /**
  25978. * Is this node a descendant of the given node?
  25979. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25980. * @param ancestor defines the parent node to inspect
  25981. * @returns a boolean indicating if this node is a descendant of the given node
  25982. */
  25983. isDescendantOf(ancestor: Node): boolean;
  25984. /** @hidden */
  25985. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25986. /**
  25987. * Will return all nodes that have this node as ascendant
  25988. * @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
  25989. * @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
  25990. * @return all children nodes of all types
  25991. */
  25992. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25993. /**
  25994. * Get all child-meshes of this node
  25995. * @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)
  25996. * @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
  25997. * @returns an array of AbstractMesh
  25998. */
  25999. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26000. /**
  26001. * Get all direct children of this node
  26002. * @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
  26003. * @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)
  26004. * @returns an array of Node
  26005. */
  26006. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26007. /** @hidden */
  26008. _setReady(state: boolean): void;
  26009. /**
  26010. * Get an animation by name
  26011. * @param name defines the name of the animation to look for
  26012. * @returns null if not found else the requested animation
  26013. */
  26014. getAnimationByName(name: string): Nullable<Animation>;
  26015. /**
  26016. * Creates an animation range for this node
  26017. * @param name defines the name of the range
  26018. * @param from defines the starting key
  26019. * @param to defines the end key
  26020. */
  26021. createAnimationRange(name: string, from: number, to: number): void;
  26022. /**
  26023. * Delete a specific animation range
  26024. * @param name defines the name of the range to delete
  26025. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26026. */
  26027. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26028. /**
  26029. * Get an animation range by name
  26030. * @param name defines the name of the animation range to look for
  26031. * @returns null if not found else the requested animation range
  26032. */
  26033. getAnimationRange(name: string): Nullable<AnimationRange>;
  26034. /**
  26035. * Gets the list of all animation ranges defined on this node
  26036. * @returns an array
  26037. */
  26038. getAnimationRanges(): Nullable<AnimationRange>[];
  26039. /**
  26040. * Will start the animation sequence
  26041. * @param name defines the range frames for animation sequence
  26042. * @param loop defines if the animation should loop (false by default)
  26043. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26044. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26045. * @returns the object created for this animation. If range does not exist, it will return null
  26046. */
  26047. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26048. /**
  26049. * Serialize animation ranges into a JSON compatible object
  26050. * @returns serialization object
  26051. */
  26052. serializeAnimationRanges(): any;
  26053. /**
  26054. * Computes the world matrix of the node
  26055. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26056. * @returns the world matrix
  26057. */
  26058. computeWorldMatrix(force?: boolean): Matrix;
  26059. /**
  26060. * Releases resources associated with this node.
  26061. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26062. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26063. */
  26064. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26065. /**
  26066. * Parse animation range data from a serialization object and store them into a given node
  26067. * @param node defines where to store the animation ranges
  26068. * @param parsedNode defines the serialization object to read data from
  26069. * @param scene defines the hosting scene
  26070. */
  26071. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26072. /**
  26073. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26074. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26075. * @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
  26076. * @returns the new bounding vectors
  26077. */
  26078. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26079. min: Vector3;
  26080. max: Vector3;
  26081. };
  26082. }
  26083. }
  26084. declare module "babylonjs/Animations/animation" {
  26085. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26086. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26087. import { Nullable } from "babylonjs/types";
  26088. import { Scene } from "babylonjs/scene";
  26089. import { IAnimatable } from "babylonjs/Misc/tools";
  26090. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26091. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26092. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26093. import { Node } from "babylonjs/node";
  26094. import { Animatable } from "babylonjs/Animations/animatable";
  26095. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26096. /**
  26097. * @hidden
  26098. */
  26099. export class _IAnimationState {
  26100. key: number;
  26101. repeatCount: number;
  26102. workValue?: any;
  26103. loopMode?: number;
  26104. offsetValue?: any;
  26105. highLimitValue?: any;
  26106. }
  26107. /**
  26108. * Class used to store any kind of animation
  26109. */
  26110. export class Animation {
  26111. /**Name of the animation */
  26112. name: string;
  26113. /**Property to animate */
  26114. targetProperty: string;
  26115. /**The frames per second of the animation */
  26116. framePerSecond: number;
  26117. /**The data type of the animation */
  26118. dataType: number;
  26119. /**The loop mode of the animation */
  26120. loopMode?: number | undefined;
  26121. /**Specifies if blending should be enabled */
  26122. enableBlending?: boolean | undefined;
  26123. /**
  26124. * Use matrix interpolation instead of using direct key value when animating matrices
  26125. */
  26126. static AllowMatricesInterpolation: boolean;
  26127. /**
  26128. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26129. */
  26130. static AllowMatrixDecomposeForInterpolation: boolean;
  26131. /**
  26132. * Stores the key frames of the animation
  26133. */
  26134. private _keys;
  26135. /**
  26136. * Stores the easing function of the animation
  26137. */
  26138. private _easingFunction;
  26139. /**
  26140. * @hidden Internal use only
  26141. */
  26142. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26143. /**
  26144. * The set of event that will be linked to this animation
  26145. */
  26146. private _events;
  26147. /**
  26148. * Stores an array of target property paths
  26149. */
  26150. targetPropertyPath: string[];
  26151. /**
  26152. * Stores the blending speed of the animation
  26153. */
  26154. blendingSpeed: number;
  26155. /**
  26156. * Stores the animation ranges for the animation
  26157. */
  26158. private _ranges;
  26159. /**
  26160. * @hidden Internal use
  26161. */
  26162. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26163. /**
  26164. * Sets up an animation
  26165. * @param property The property to animate
  26166. * @param animationType The animation type to apply
  26167. * @param framePerSecond The frames per second of the animation
  26168. * @param easingFunction The easing function used in the animation
  26169. * @returns The created animation
  26170. */
  26171. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26172. /**
  26173. * Create and start an animation on a node
  26174. * @param name defines the name of the global animation that will be run on all nodes
  26175. * @param node defines the root node where the animation will take place
  26176. * @param targetProperty defines property to animate
  26177. * @param framePerSecond defines the number of frame per second yo use
  26178. * @param totalFrame defines the number of frames in total
  26179. * @param from defines the initial value
  26180. * @param to defines the final value
  26181. * @param loopMode defines which loop mode you want to use (off by default)
  26182. * @param easingFunction defines the easing function to use (linear by default)
  26183. * @param onAnimationEnd defines the callback to call when animation end
  26184. * @returns the animatable created for this animation
  26185. */
  26186. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26187. /**
  26188. * Create and start an animation on a node and its descendants
  26189. * @param name defines the name of the global animation that will be run on all nodes
  26190. * @param node defines the root node where the animation will take place
  26191. * @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
  26192. * @param targetProperty defines property to animate
  26193. * @param framePerSecond defines the number of frame per second to use
  26194. * @param totalFrame defines the number of frames in total
  26195. * @param from defines the initial value
  26196. * @param to defines the final value
  26197. * @param loopMode defines which loop mode you want to use (off by default)
  26198. * @param easingFunction defines the easing function to use (linear by default)
  26199. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26200. * @returns the list of animatables created for all nodes
  26201. * @example https://www.babylonjs-playground.com/#MH0VLI
  26202. */
  26203. 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[]>;
  26204. /**
  26205. * Creates a new animation, merges it with the existing animations and starts it
  26206. * @param name Name of the animation
  26207. * @param node Node which contains the scene that begins the animations
  26208. * @param targetProperty Specifies which property to animate
  26209. * @param framePerSecond The frames per second of the animation
  26210. * @param totalFrame The total number of frames
  26211. * @param from The frame at the beginning of the animation
  26212. * @param to The frame at the end of the animation
  26213. * @param loopMode Specifies the loop mode of the animation
  26214. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26215. * @param onAnimationEnd Callback to run once the animation is complete
  26216. * @returns Nullable animation
  26217. */
  26218. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26219. /**
  26220. * Transition property of an host to the target Value
  26221. * @param property The property to transition
  26222. * @param targetValue The target Value of the property
  26223. * @param host The object where the property to animate belongs
  26224. * @param scene Scene used to run the animation
  26225. * @param frameRate Framerate (in frame/s) to use
  26226. * @param transition The transition type we want to use
  26227. * @param duration The duration of the animation, in milliseconds
  26228. * @param onAnimationEnd Callback trigger at the end of the animation
  26229. * @returns Nullable animation
  26230. */
  26231. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26232. /**
  26233. * Return the array of runtime animations currently using this animation
  26234. */
  26235. readonly runtimeAnimations: RuntimeAnimation[];
  26236. /**
  26237. * Specifies if any of the runtime animations are currently running
  26238. */
  26239. readonly hasRunningRuntimeAnimations: boolean;
  26240. /**
  26241. * Initializes the animation
  26242. * @param name Name of the animation
  26243. * @param targetProperty Property to animate
  26244. * @param framePerSecond The frames per second of the animation
  26245. * @param dataType The data type of the animation
  26246. * @param loopMode The loop mode of the animation
  26247. * @param enableBlending Specifies if blending should be enabled
  26248. */
  26249. constructor(
  26250. /**Name of the animation */
  26251. name: string,
  26252. /**Property to animate */
  26253. targetProperty: string,
  26254. /**The frames per second of the animation */
  26255. framePerSecond: number,
  26256. /**The data type of the animation */
  26257. dataType: number,
  26258. /**The loop mode of the animation */
  26259. loopMode?: number | undefined,
  26260. /**Specifies if blending should be enabled */
  26261. enableBlending?: boolean | undefined);
  26262. /**
  26263. * Converts the animation to a string
  26264. * @param fullDetails support for multiple levels of logging within scene loading
  26265. * @returns String form of the animation
  26266. */
  26267. toString(fullDetails?: boolean): string;
  26268. /**
  26269. * Add an event to this animation
  26270. * @param event Event to add
  26271. */
  26272. addEvent(event: AnimationEvent): void;
  26273. /**
  26274. * Remove all events found at the given frame
  26275. * @param frame The frame to remove events from
  26276. */
  26277. removeEvents(frame: number): void;
  26278. /**
  26279. * Retrieves all the events from the animation
  26280. * @returns Events from the animation
  26281. */
  26282. getEvents(): AnimationEvent[];
  26283. /**
  26284. * Creates an animation range
  26285. * @param name Name of the animation range
  26286. * @param from Starting frame of the animation range
  26287. * @param to Ending frame of the animation
  26288. */
  26289. createRange(name: string, from: number, to: number): void;
  26290. /**
  26291. * Deletes an animation range by name
  26292. * @param name Name of the animation range to delete
  26293. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26294. */
  26295. deleteRange(name: string, deleteFrames?: boolean): void;
  26296. /**
  26297. * Gets the animation range by name, or null if not defined
  26298. * @param name Name of the animation range
  26299. * @returns Nullable animation range
  26300. */
  26301. getRange(name: string): Nullable<AnimationRange>;
  26302. /**
  26303. * Gets the key frames from the animation
  26304. * @returns The key frames of the animation
  26305. */
  26306. getKeys(): Array<IAnimationKey>;
  26307. /**
  26308. * Gets the highest frame rate of the animation
  26309. * @returns Highest frame rate of the animation
  26310. */
  26311. getHighestFrame(): number;
  26312. /**
  26313. * Gets the easing function of the animation
  26314. * @returns Easing function of the animation
  26315. */
  26316. getEasingFunction(): IEasingFunction;
  26317. /**
  26318. * Sets the easing function of the animation
  26319. * @param easingFunction A custom mathematical formula for animation
  26320. */
  26321. setEasingFunction(easingFunction: EasingFunction): void;
  26322. /**
  26323. * Interpolates a scalar linearly
  26324. * @param startValue Start value of the animation curve
  26325. * @param endValue End value of the animation curve
  26326. * @param gradient Scalar amount to interpolate
  26327. * @returns Interpolated scalar value
  26328. */
  26329. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26330. /**
  26331. * Interpolates a scalar cubically
  26332. * @param startValue Start value of the animation curve
  26333. * @param outTangent End tangent of the animation
  26334. * @param endValue End value of the animation curve
  26335. * @param inTangent Start tangent of the animation curve
  26336. * @param gradient Scalar amount to interpolate
  26337. * @returns Interpolated scalar value
  26338. */
  26339. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26340. /**
  26341. * Interpolates a quaternion using a spherical linear interpolation
  26342. * @param startValue Start value of the animation curve
  26343. * @param endValue End value of the animation curve
  26344. * @param gradient Scalar amount to interpolate
  26345. * @returns Interpolated quaternion value
  26346. */
  26347. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26348. /**
  26349. * Interpolates a quaternion cubically
  26350. * @param startValue Start value of the animation curve
  26351. * @param outTangent End tangent of the animation curve
  26352. * @param endValue End value of the animation curve
  26353. * @param inTangent Start tangent of the animation curve
  26354. * @param gradient Scalar amount to interpolate
  26355. * @returns Interpolated quaternion value
  26356. */
  26357. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26358. /**
  26359. * Interpolates a Vector3 linearl
  26360. * @param startValue Start value of the animation curve
  26361. * @param endValue End value of the animation curve
  26362. * @param gradient Scalar amount to interpolate
  26363. * @returns Interpolated scalar value
  26364. */
  26365. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26366. /**
  26367. * Interpolates a Vector3 cubically
  26368. * @param startValue Start value of the animation curve
  26369. * @param outTangent End tangent of the animation
  26370. * @param endValue End value of the animation curve
  26371. * @param inTangent Start tangent of the animation curve
  26372. * @param gradient Scalar amount to interpolate
  26373. * @returns InterpolatedVector3 value
  26374. */
  26375. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26376. /**
  26377. * Interpolates a Vector2 linearly
  26378. * @param startValue Start value of the animation curve
  26379. * @param endValue End value of the animation curve
  26380. * @param gradient Scalar amount to interpolate
  26381. * @returns Interpolated Vector2 value
  26382. */
  26383. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26384. /**
  26385. * Interpolates a Vector2 cubically
  26386. * @param startValue Start value of the animation curve
  26387. * @param outTangent End tangent of the animation
  26388. * @param endValue End value of the animation curve
  26389. * @param inTangent Start tangent of the animation curve
  26390. * @param gradient Scalar amount to interpolate
  26391. * @returns Interpolated Vector2 value
  26392. */
  26393. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26394. /**
  26395. * Interpolates a size linearly
  26396. * @param startValue Start value of the animation curve
  26397. * @param endValue End value of the animation curve
  26398. * @param gradient Scalar amount to interpolate
  26399. * @returns Interpolated Size value
  26400. */
  26401. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26402. /**
  26403. * Interpolates a Color3 linearly
  26404. * @param startValue Start value of the animation curve
  26405. * @param endValue End value of the animation curve
  26406. * @param gradient Scalar amount to interpolate
  26407. * @returns Interpolated Color3 value
  26408. */
  26409. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26410. /**
  26411. * @hidden Internal use only
  26412. */
  26413. _getKeyValue(value: any): any;
  26414. /**
  26415. * @hidden Internal use only
  26416. */
  26417. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26418. /**
  26419. * Defines the function to use to interpolate matrices
  26420. * @param startValue defines the start matrix
  26421. * @param endValue defines the end matrix
  26422. * @param gradient defines the gradient between both matrices
  26423. * @param result defines an optional target matrix where to store the interpolation
  26424. * @returns the interpolated matrix
  26425. */
  26426. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26427. /**
  26428. * Makes a copy of the animation
  26429. * @returns Cloned animation
  26430. */
  26431. clone(): Animation;
  26432. /**
  26433. * Sets the key frames of the animation
  26434. * @param values The animation key frames to set
  26435. */
  26436. setKeys(values: Array<IAnimationKey>): void;
  26437. /**
  26438. * Serializes the animation to an object
  26439. * @returns Serialized object
  26440. */
  26441. serialize(): any;
  26442. /**
  26443. * Float animation type
  26444. */
  26445. private static _ANIMATIONTYPE_FLOAT;
  26446. /**
  26447. * Vector3 animation type
  26448. */
  26449. private static _ANIMATIONTYPE_VECTOR3;
  26450. /**
  26451. * Quaternion animation type
  26452. */
  26453. private static _ANIMATIONTYPE_QUATERNION;
  26454. /**
  26455. * Matrix animation type
  26456. */
  26457. private static _ANIMATIONTYPE_MATRIX;
  26458. /**
  26459. * Color3 animation type
  26460. */
  26461. private static _ANIMATIONTYPE_COLOR3;
  26462. /**
  26463. * Vector2 animation type
  26464. */
  26465. private static _ANIMATIONTYPE_VECTOR2;
  26466. /**
  26467. * Size animation type
  26468. */
  26469. private static _ANIMATIONTYPE_SIZE;
  26470. /**
  26471. * Relative Loop Mode
  26472. */
  26473. private static _ANIMATIONLOOPMODE_RELATIVE;
  26474. /**
  26475. * Cycle Loop Mode
  26476. */
  26477. private static _ANIMATIONLOOPMODE_CYCLE;
  26478. /**
  26479. * Constant Loop Mode
  26480. */
  26481. private static _ANIMATIONLOOPMODE_CONSTANT;
  26482. /**
  26483. * Get the float animation type
  26484. */
  26485. static readonly ANIMATIONTYPE_FLOAT: number;
  26486. /**
  26487. * Get the Vector3 animation type
  26488. */
  26489. static readonly ANIMATIONTYPE_VECTOR3: number;
  26490. /**
  26491. * Get the Vector2 animation type
  26492. */
  26493. static readonly ANIMATIONTYPE_VECTOR2: number;
  26494. /**
  26495. * Get the Size animation type
  26496. */
  26497. static readonly ANIMATIONTYPE_SIZE: number;
  26498. /**
  26499. * Get the Quaternion animation type
  26500. */
  26501. static readonly ANIMATIONTYPE_QUATERNION: number;
  26502. /**
  26503. * Get the Matrix animation type
  26504. */
  26505. static readonly ANIMATIONTYPE_MATRIX: number;
  26506. /**
  26507. * Get the Color3 animation type
  26508. */
  26509. static readonly ANIMATIONTYPE_COLOR3: number;
  26510. /**
  26511. * Get the Relative Loop Mode
  26512. */
  26513. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26514. /**
  26515. * Get the Cycle Loop Mode
  26516. */
  26517. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26518. /**
  26519. * Get the Constant Loop Mode
  26520. */
  26521. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26522. /** @hidden */
  26523. static _UniversalLerp(left: any, right: any, amount: number): any;
  26524. /**
  26525. * Parses an animation object and creates an animation
  26526. * @param parsedAnimation Parsed animation object
  26527. * @returns Animation object
  26528. */
  26529. static Parse(parsedAnimation: any): Animation;
  26530. /**
  26531. * Appends the serialized animations from the source animations
  26532. * @param source Source containing the animations
  26533. * @param destination Target to store the animations
  26534. */
  26535. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26536. }
  26537. }
  26538. declare module "babylonjs/Materials/Textures/baseTexture" {
  26539. import { Observable } from "babylonjs/Misc/observable";
  26540. import { IAnimatable } from "babylonjs/Misc/tools";
  26541. import { Nullable } from "babylonjs/types";
  26542. import { Scene } from "babylonjs/scene";
  26543. import { Matrix, ISize } from "babylonjs/Maths/math";
  26544. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26545. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26546. /**
  26547. * Base class of all the textures in babylon.
  26548. * It groups all the common properties the materials, post process, lights... might need
  26549. * in order to make a correct use of the texture.
  26550. */
  26551. export class BaseTexture implements IAnimatable {
  26552. /**
  26553. * Default anisotropic filtering level for the application.
  26554. * It is set to 4 as a good tradeoff between perf and quality.
  26555. */
  26556. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26557. /**
  26558. * Gets or sets the unique id of the texture
  26559. */
  26560. uniqueId: number;
  26561. /**
  26562. * Define the name of the texture.
  26563. */
  26564. name: string;
  26565. /**
  26566. * Gets or sets an object used to store user defined information.
  26567. */
  26568. metadata: any;
  26569. /**
  26570. * For internal use only. Please do not use.
  26571. */
  26572. reservedDataStore: any;
  26573. private _hasAlpha;
  26574. /**
  26575. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26576. */
  26577. hasAlpha: boolean;
  26578. /**
  26579. * Defines if the alpha value should be determined via the rgb values.
  26580. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26581. */
  26582. getAlphaFromRGB: boolean;
  26583. /**
  26584. * Intensity or strength of the texture.
  26585. * It is commonly used by materials to fine tune the intensity of the texture
  26586. */
  26587. level: number;
  26588. /**
  26589. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26590. * This is part of the texture as textures usually maps to one uv set.
  26591. */
  26592. coordinatesIndex: number;
  26593. private _coordinatesMode;
  26594. /**
  26595. * How a texture is mapped.
  26596. *
  26597. * | Value | Type | Description |
  26598. * | ----- | ----------------------------------- | ----------- |
  26599. * | 0 | EXPLICIT_MODE | |
  26600. * | 1 | SPHERICAL_MODE | |
  26601. * | 2 | PLANAR_MODE | |
  26602. * | 3 | CUBIC_MODE | |
  26603. * | 4 | PROJECTION_MODE | |
  26604. * | 5 | SKYBOX_MODE | |
  26605. * | 6 | INVCUBIC_MODE | |
  26606. * | 7 | EQUIRECTANGULAR_MODE | |
  26607. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26608. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26609. */
  26610. coordinatesMode: number;
  26611. /**
  26612. * | Value | Type | Description |
  26613. * | ----- | ------------------ | ----------- |
  26614. * | 0 | CLAMP_ADDRESSMODE | |
  26615. * | 1 | WRAP_ADDRESSMODE | |
  26616. * | 2 | MIRROR_ADDRESSMODE | |
  26617. */
  26618. wrapU: number;
  26619. /**
  26620. * | Value | Type | Description |
  26621. * | ----- | ------------------ | ----------- |
  26622. * | 0 | CLAMP_ADDRESSMODE | |
  26623. * | 1 | WRAP_ADDRESSMODE | |
  26624. * | 2 | MIRROR_ADDRESSMODE | |
  26625. */
  26626. wrapV: number;
  26627. /**
  26628. * | Value | Type | Description |
  26629. * | ----- | ------------------ | ----------- |
  26630. * | 0 | CLAMP_ADDRESSMODE | |
  26631. * | 1 | WRAP_ADDRESSMODE | |
  26632. * | 2 | MIRROR_ADDRESSMODE | |
  26633. */
  26634. wrapR: number;
  26635. /**
  26636. * With compliant hardware and browser (supporting anisotropic filtering)
  26637. * this defines the level of anisotropic filtering in the texture.
  26638. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26639. */
  26640. anisotropicFilteringLevel: number;
  26641. /**
  26642. * Define if the texture is a cube texture or if false a 2d texture.
  26643. */
  26644. isCube: boolean;
  26645. /**
  26646. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26647. */
  26648. is3D: boolean;
  26649. /**
  26650. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26651. * HDR texture are usually stored in linear space.
  26652. * This only impacts the PBR and Background materials
  26653. */
  26654. gammaSpace: boolean;
  26655. /**
  26656. * Gets whether or not the texture contains RGBD data.
  26657. */
  26658. readonly isRGBD: boolean;
  26659. /**
  26660. * Is Z inverted in the texture (useful in a cube texture).
  26661. */
  26662. invertZ: boolean;
  26663. /**
  26664. * Are mip maps generated for this texture or not.
  26665. */
  26666. readonly noMipmap: boolean;
  26667. /**
  26668. * @hidden
  26669. */
  26670. lodLevelInAlpha: boolean;
  26671. /**
  26672. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26673. */
  26674. lodGenerationOffset: number;
  26675. /**
  26676. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26677. */
  26678. lodGenerationScale: number;
  26679. /**
  26680. * Define if the texture is a render target.
  26681. */
  26682. isRenderTarget: boolean;
  26683. /**
  26684. * Define the unique id of the texture in the scene.
  26685. */
  26686. readonly uid: string;
  26687. /**
  26688. * Return a string representation of the texture.
  26689. * @returns the texture as a string
  26690. */
  26691. toString(): string;
  26692. /**
  26693. * Get the class name of the texture.
  26694. * @returns "BaseTexture"
  26695. */
  26696. getClassName(): string;
  26697. /**
  26698. * Define the list of animation attached to the texture.
  26699. */
  26700. animations: import("babylonjs/Animations/animation").Animation[];
  26701. /**
  26702. * An event triggered when the texture is disposed.
  26703. */
  26704. onDisposeObservable: Observable<BaseTexture>;
  26705. private _onDisposeObserver;
  26706. /**
  26707. * Callback triggered when the texture has been disposed.
  26708. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26709. */
  26710. onDispose: () => void;
  26711. /**
  26712. * Define the current state of the loading sequence when in delayed load mode.
  26713. */
  26714. delayLoadState: number;
  26715. private _scene;
  26716. /** @hidden */
  26717. _texture: Nullable<InternalTexture>;
  26718. private _uid;
  26719. /**
  26720. * Define if the texture is preventinga material to render or not.
  26721. * If not and the texture is not ready, the engine will use a default black texture instead.
  26722. */
  26723. readonly isBlocking: boolean;
  26724. /**
  26725. * Instantiates a new BaseTexture.
  26726. * Base class of all the textures in babylon.
  26727. * It groups all the common properties the materials, post process, lights... might need
  26728. * in order to make a correct use of the texture.
  26729. * @param scene Define the scene the texture blongs to
  26730. */
  26731. constructor(scene: Nullable<Scene>);
  26732. /**
  26733. * Get the scene the texture belongs to.
  26734. * @returns the scene or null if undefined
  26735. */
  26736. getScene(): Nullable<Scene>;
  26737. /**
  26738. * Get the texture transform matrix used to offset tile the texture for istance.
  26739. * @returns the transformation matrix
  26740. */
  26741. getTextureMatrix(): Matrix;
  26742. /**
  26743. * Get the texture reflection matrix used to rotate/transform the reflection.
  26744. * @returns the reflection matrix
  26745. */
  26746. getReflectionTextureMatrix(): Matrix;
  26747. /**
  26748. * Get the underlying lower level texture from Babylon.
  26749. * @returns the insternal texture
  26750. */
  26751. getInternalTexture(): Nullable<InternalTexture>;
  26752. /**
  26753. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26754. * @returns true if ready or not blocking
  26755. */
  26756. isReadyOrNotBlocking(): boolean;
  26757. /**
  26758. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26759. * @returns true if fully ready
  26760. */
  26761. isReady(): boolean;
  26762. private _cachedSize;
  26763. /**
  26764. * Get the size of the texture.
  26765. * @returns the texture size.
  26766. */
  26767. getSize(): ISize;
  26768. /**
  26769. * Get the base size of the texture.
  26770. * It can be different from the size if the texture has been resized for POT for instance
  26771. * @returns the base size
  26772. */
  26773. getBaseSize(): ISize;
  26774. /**
  26775. * Update the sampling mode of the texture.
  26776. * Default is Trilinear mode.
  26777. *
  26778. * | Value | Type | Description |
  26779. * | ----- | ------------------ | ----------- |
  26780. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26781. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26782. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26783. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26784. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26785. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26786. * | 7 | NEAREST_LINEAR | |
  26787. * | 8 | NEAREST_NEAREST | |
  26788. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26789. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26790. * | 11 | LINEAR_LINEAR | |
  26791. * | 12 | LINEAR_NEAREST | |
  26792. *
  26793. * > _mag_: magnification filter (close to the viewer)
  26794. * > _min_: minification filter (far from the viewer)
  26795. * > _mip_: filter used between mip map levels
  26796. *@param samplingMode Define the new sampling mode of the texture
  26797. */
  26798. updateSamplingMode(samplingMode: number): void;
  26799. /**
  26800. * Scales the texture if is `canRescale()`
  26801. * @param ratio the resize factor we want to use to rescale
  26802. */
  26803. scale(ratio: number): void;
  26804. /**
  26805. * Get if the texture can rescale.
  26806. */
  26807. readonly canRescale: boolean;
  26808. /** @hidden */
  26809. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26810. /** @hidden */
  26811. _rebuild(): void;
  26812. /**
  26813. * Triggers the load sequence in delayed load mode.
  26814. */
  26815. delayLoad(): void;
  26816. /**
  26817. * Clones the texture.
  26818. * @returns the cloned texture
  26819. */
  26820. clone(): Nullable<BaseTexture>;
  26821. /**
  26822. * Get the texture underlying type (INT, FLOAT...)
  26823. */
  26824. readonly textureType: number;
  26825. /**
  26826. * Get the texture underlying format (RGB, RGBA...)
  26827. */
  26828. readonly textureFormat: number;
  26829. /**
  26830. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26831. * This will returns an RGBA array buffer containing either in values (0-255) or
  26832. * float values (0-1) depending of the underlying buffer type.
  26833. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26834. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26835. * @param buffer defines a user defined buffer to fill with data (can be null)
  26836. * @returns The Array buffer containing the pixels data.
  26837. */
  26838. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26839. /**
  26840. * Release and destroy the underlying lower level texture aka internalTexture.
  26841. */
  26842. releaseInternalTexture(): void;
  26843. /**
  26844. * Get the polynomial representation of the texture data.
  26845. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26846. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26847. */
  26848. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26849. /** @hidden */
  26850. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26851. /** @hidden */
  26852. readonly _lodTextureMid: Nullable<BaseTexture>;
  26853. /** @hidden */
  26854. readonly _lodTextureLow: Nullable<BaseTexture>;
  26855. /**
  26856. * Dispose the texture and release its associated resources.
  26857. */
  26858. dispose(): void;
  26859. /**
  26860. * Serialize the texture into a JSON representation that can be parsed later on.
  26861. * @returns the JSON representation of the texture
  26862. */
  26863. serialize(): any;
  26864. /**
  26865. * Helper function to be called back once a list of texture contains only ready textures.
  26866. * @param textures Define the list of textures to wait for
  26867. * @param callback Define the callback triggered once the entire list will be ready
  26868. */
  26869. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26870. }
  26871. }
  26872. declare module "babylonjs/Materials/uniformBuffer" {
  26873. import { Nullable, FloatArray } from "babylonjs/types";
  26874. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26875. import { Engine } from "babylonjs/Engines/engine";
  26876. import { Effect } from "babylonjs/Materials/effect";
  26877. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26878. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26879. /**
  26880. * Uniform buffer objects.
  26881. *
  26882. * Handles blocks of uniform on the GPU.
  26883. *
  26884. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26885. *
  26886. * For more information, please refer to :
  26887. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26888. */
  26889. export class UniformBuffer {
  26890. private _engine;
  26891. private _buffer;
  26892. private _data;
  26893. private _bufferData;
  26894. private _dynamic?;
  26895. private _uniformLocations;
  26896. private _uniformSizes;
  26897. private _uniformLocationPointer;
  26898. private _needSync;
  26899. private _noUBO;
  26900. private _currentEffect;
  26901. private static _MAX_UNIFORM_SIZE;
  26902. private static _tempBuffer;
  26903. /**
  26904. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26905. * This is dynamic to allow compat with webgl 1 and 2.
  26906. * You will need to pass the name of the uniform as well as the value.
  26907. */
  26908. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26909. /**
  26910. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26911. * This is dynamic to allow compat with webgl 1 and 2.
  26912. * You will need to pass the name of the uniform as well as the value.
  26913. */
  26914. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26915. /**
  26916. * Lambda to Update a single float in a uniform buffer.
  26917. * This is dynamic to allow compat with webgl 1 and 2.
  26918. * You will need to pass the name of the uniform as well as the value.
  26919. */
  26920. updateFloat: (name: string, x: number) => void;
  26921. /**
  26922. * Lambda to Update a vec2 of float in a uniform buffer.
  26923. * This is dynamic to allow compat with webgl 1 and 2.
  26924. * You will need to pass the name of the uniform as well as the value.
  26925. */
  26926. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26927. /**
  26928. * Lambda to Update a vec3 of float in a uniform buffer.
  26929. * This is dynamic to allow compat with webgl 1 and 2.
  26930. * You will need to pass the name of the uniform as well as the value.
  26931. */
  26932. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26933. /**
  26934. * Lambda to Update a vec4 of float in a uniform buffer.
  26935. * This is dynamic to allow compat with webgl 1 and 2.
  26936. * You will need to pass the name of the uniform as well as the value.
  26937. */
  26938. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26939. /**
  26940. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26941. * This is dynamic to allow compat with webgl 1 and 2.
  26942. * You will need to pass the name of the uniform as well as the value.
  26943. */
  26944. updateMatrix: (name: string, mat: Matrix) => void;
  26945. /**
  26946. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26947. * This is dynamic to allow compat with webgl 1 and 2.
  26948. * You will need to pass the name of the uniform as well as the value.
  26949. */
  26950. updateVector3: (name: string, vector: Vector3) => void;
  26951. /**
  26952. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26953. * This is dynamic to allow compat with webgl 1 and 2.
  26954. * You will need to pass the name of the uniform as well as the value.
  26955. */
  26956. updateVector4: (name: string, vector: Vector4) => void;
  26957. /**
  26958. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26959. * This is dynamic to allow compat with webgl 1 and 2.
  26960. * You will need to pass the name of the uniform as well as the value.
  26961. */
  26962. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26963. /**
  26964. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26965. * This is dynamic to allow compat with webgl 1 and 2.
  26966. * You will need to pass the name of the uniform as well as the value.
  26967. */
  26968. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26969. /**
  26970. * Instantiates a new Uniform buffer objects.
  26971. *
  26972. * Handles blocks of uniform on the GPU.
  26973. *
  26974. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26975. *
  26976. * For more information, please refer to :
  26977. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26978. * @param engine Define the engine the buffer is associated with
  26979. * @param data Define the data contained in the buffer
  26980. * @param dynamic Define if the buffer is updatable
  26981. */
  26982. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26983. /**
  26984. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26985. * or just falling back on setUniformXXX calls.
  26986. */
  26987. readonly useUbo: boolean;
  26988. /**
  26989. * Indicates if the WebGL underlying uniform buffer is in sync
  26990. * with the javascript cache data.
  26991. */
  26992. readonly isSync: boolean;
  26993. /**
  26994. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26995. * Also, a dynamic UniformBuffer will disable cache verification and always
  26996. * update the underlying WebGL uniform buffer to the GPU.
  26997. * @returns if Dynamic, otherwise false
  26998. */
  26999. isDynamic(): boolean;
  27000. /**
  27001. * The data cache on JS side.
  27002. * @returns the underlying data as a float array
  27003. */
  27004. getData(): Float32Array;
  27005. /**
  27006. * The underlying WebGL Uniform buffer.
  27007. * @returns the webgl buffer
  27008. */
  27009. getBuffer(): Nullable<DataBuffer>;
  27010. /**
  27011. * std140 layout specifies how to align data within an UBO structure.
  27012. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27013. * for specs.
  27014. */
  27015. private _fillAlignment;
  27016. /**
  27017. * Adds an uniform in the buffer.
  27018. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27019. * for the layout to be correct !
  27020. * @param name Name of the uniform, as used in the uniform block in the shader.
  27021. * @param size Data size, or data directly.
  27022. */
  27023. addUniform(name: string, size: number | number[]): void;
  27024. /**
  27025. * Adds a Matrix 4x4 to the uniform buffer.
  27026. * @param name Name of the uniform, as used in the uniform block in the shader.
  27027. * @param mat A 4x4 matrix.
  27028. */
  27029. addMatrix(name: string, mat: Matrix): void;
  27030. /**
  27031. * Adds a vec2 to the uniform buffer.
  27032. * @param name Name of the uniform, as used in the uniform block in the shader.
  27033. * @param x Define the x component value of the vec2
  27034. * @param y Define the y component value of the vec2
  27035. */
  27036. addFloat2(name: string, x: number, y: number): void;
  27037. /**
  27038. * Adds a vec3 to the uniform buffer.
  27039. * @param name Name of the uniform, as used in the uniform block in the shader.
  27040. * @param x Define the x component value of the vec3
  27041. * @param y Define the y component value of the vec3
  27042. * @param z Define the z component value of the vec3
  27043. */
  27044. addFloat3(name: string, x: number, y: number, z: number): void;
  27045. /**
  27046. * Adds a vec3 to the uniform buffer.
  27047. * @param name Name of the uniform, as used in the uniform block in the shader.
  27048. * @param color Define the vec3 from a Color
  27049. */
  27050. addColor3(name: string, color: Color3): void;
  27051. /**
  27052. * Adds a vec4 to the uniform buffer.
  27053. * @param name Name of the uniform, as used in the uniform block in the shader.
  27054. * @param color Define the rgb components from a Color
  27055. * @param alpha Define the a component of the vec4
  27056. */
  27057. addColor4(name: string, color: Color3, alpha: number): void;
  27058. /**
  27059. * Adds a vec3 to the uniform buffer.
  27060. * @param name Name of the uniform, as used in the uniform block in the shader.
  27061. * @param vector Define the vec3 components from a Vector
  27062. */
  27063. addVector3(name: string, vector: Vector3): void;
  27064. /**
  27065. * Adds a Matrix 3x3 to the uniform buffer.
  27066. * @param name Name of the uniform, as used in the uniform block in the shader.
  27067. */
  27068. addMatrix3x3(name: string): void;
  27069. /**
  27070. * Adds a Matrix 2x2 to the uniform buffer.
  27071. * @param name Name of the uniform, as used in the uniform block in the shader.
  27072. */
  27073. addMatrix2x2(name: string): void;
  27074. /**
  27075. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27076. */
  27077. create(): void;
  27078. /** @hidden */
  27079. _rebuild(): void;
  27080. /**
  27081. * Updates the WebGL Uniform Buffer on the GPU.
  27082. * If the `dynamic` flag is set to true, no cache comparison is done.
  27083. * Otherwise, the buffer will be updated only if the cache differs.
  27084. */
  27085. update(): void;
  27086. /**
  27087. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27088. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27089. * @param data Define the flattened data
  27090. * @param size Define the size of the data.
  27091. */
  27092. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27093. private _updateMatrix3x3ForUniform;
  27094. private _updateMatrix3x3ForEffect;
  27095. private _updateMatrix2x2ForEffect;
  27096. private _updateMatrix2x2ForUniform;
  27097. private _updateFloatForEffect;
  27098. private _updateFloatForUniform;
  27099. private _updateFloat2ForEffect;
  27100. private _updateFloat2ForUniform;
  27101. private _updateFloat3ForEffect;
  27102. private _updateFloat3ForUniform;
  27103. private _updateFloat4ForEffect;
  27104. private _updateFloat4ForUniform;
  27105. private _updateMatrixForEffect;
  27106. private _updateMatrixForUniform;
  27107. private _updateVector3ForEffect;
  27108. private _updateVector3ForUniform;
  27109. private _updateVector4ForEffect;
  27110. private _updateVector4ForUniform;
  27111. private _updateColor3ForEffect;
  27112. private _updateColor3ForUniform;
  27113. private _updateColor4ForEffect;
  27114. private _updateColor4ForUniform;
  27115. /**
  27116. * Sets a sampler uniform on the effect.
  27117. * @param name Define the name of the sampler.
  27118. * @param texture Define the texture to set in the sampler
  27119. */
  27120. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27121. /**
  27122. * Directly updates the value of the uniform in the cache AND on the GPU.
  27123. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27124. * @param data Define the flattened data
  27125. */
  27126. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27127. /**
  27128. * Binds this uniform buffer to an effect.
  27129. * @param effect Define the effect to bind the buffer to
  27130. * @param name Name of the uniform block in the shader.
  27131. */
  27132. bindToEffect(effect: Effect, name: string): void;
  27133. /**
  27134. * Disposes the uniform buffer.
  27135. */
  27136. dispose(): void;
  27137. }
  27138. }
  27139. declare module "babylonjs/Audio/analyser" {
  27140. import { Scene } from "babylonjs/scene";
  27141. /**
  27142. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27143. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27144. */
  27145. export class Analyser {
  27146. /**
  27147. * Gets or sets the smoothing
  27148. * @ignorenaming
  27149. */
  27150. SMOOTHING: number;
  27151. /**
  27152. * Gets or sets the FFT table size
  27153. * @ignorenaming
  27154. */
  27155. FFT_SIZE: number;
  27156. /**
  27157. * Gets or sets the bar graph amplitude
  27158. * @ignorenaming
  27159. */
  27160. BARGRAPHAMPLITUDE: number;
  27161. /**
  27162. * Gets or sets the position of the debug canvas
  27163. * @ignorenaming
  27164. */
  27165. DEBUGCANVASPOS: {
  27166. x: number;
  27167. y: number;
  27168. };
  27169. /**
  27170. * Gets or sets the debug canvas size
  27171. * @ignorenaming
  27172. */
  27173. DEBUGCANVASSIZE: {
  27174. width: number;
  27175. height: number;
  27176. };
  27177. private _byteFreqs;
  27178. private _byteTime;
  27179. private _floatFreqs;
  27180. private _webAudioAnalyser;
  27181. private _debugCanvas;
  27182. private _debugCanvasContext;
  27183. private _scene;
  27184. private _registerFunc;
  27185. private _audioEngine;
  27186. /**
  27187. * Creates a new analyser
  27188. * @param scene defines hosting scene
  27189. */
  27190. constructor(scene: Scene);
  27191. /**
  27192. * Get the number of data values you will have to play with for the visualization
  27193. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27194. * @returns a number
  27195. */
  27196. getFrequencyBinCount(): number;
  27197. /**
  27198. * Gets the current frequency data as a byte array
  27199. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27200. * @returns a Uint8Array
  27201. */
  27202. getByteFrequencyData(): Uint8Array;
  27203. /**
  27204. * Gets the current waveform as a byte array
  27205. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27206. * @returns a Uint8Array
  27207. */
  27208. getByteTimeDomainData(): Uint8Array;
  27209. /**
  27210. * Gets the current frequency data as a float array
  27211. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27212. * @returns a Float32Array
  27213. */
  27214. getFloatFrequencyData(): Float32Array;
  27215. /**
  27216. * Renders the debug canvas
  27217. */
  27218. drawDebugCanvas(): void;
  27219. /**
  27220. * Stops rendering the debug canvas and removes it
  27221. */
  27222. stopDebugCanvas(): void;
  27223. /**
  27224. * Connects two audio nodes
  27225. * @param inputAudioNode defines first node to connect
  27226. * @param outputAudioNode defines second node to connect
  27227. */
  27228. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27229. /**
  27230. * Releases all associated resources
  27231. */
  27232. dispose(): void;
  27233. }
  27234. }
  27235. declare module "babylonjs/Audio/audioEngine" {
  27236. import { IDisposable } from "babylonjs/scene";
  27237. import { Analyser } from "babylonjs/Audio/analyser";
  27238. import { Nullable } from "babylonjs/types";
  27239. import { Observable } from "babylonjs/Misc/observable";
  27240. /**
  27241. * This represents an audio engine and it is responsible
  27242. * to play, synchronize and analyse sounds throughout the application.
  27243. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27244. */
  27245. export interface IAudioEngine extends IDisposable {
  27246. /**
  27247. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27248. */
  27249. readonly canUseWebAudio: boolean;
  27250. /**
  27251. * Gets the current AudioContext if available.
  27252. */
  27253. readonly audioContext: Nullable<AudioContext>;
  27254. /**
  27255. * The master gain node defines the global audio volume of your audio engine.
  27256. */
  27257. readonly masterGain: GainNode;
  27258. /**
  27259. * Gets whether or not mp3 are supported by your browser.
  27260. */
  27261. readonly isMP3supported: boolean;
  27262. /**
  27263. * Gets whether or not ogg are supported by your browser.
  27264. */
  27265. readonly isOGGsupported: boolean;
  27266. /**
  27267. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27268. * @ignoreNaming
  27269. */
  27270. WarnedWebAudioUnsupported: boolean;
  27271. /**
  27272. * Defines if the audio engine relies on a custom unlocked button.
  27273. * In this case, the embedded button will not be displayed.
  27274. */
  27275. useCustomUnlockedButton: boolean;
  27276. /**
  27277. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27278. */
  27279. readonly unlocked: boolean;
  27280. /**
  27281. * Event raised when audio has been unlocked on the browser.
  27282. */
  27283. onAudioUnlockedObservable: Observable<AudioEngine>;
  27284. /**
  27285. * Event raised when audio has been locked on the browser.
  27286. */
  27287. onAudioLockedObservable: Observable<AudioEngine>;
  27288. /**
  27289. * Flags the audio engine in Locked state.
  27290. * This happens due to new browser policies preventing audio to autoplay.
  27291. */
  27292. lock(): void;
  27293. /**
  27294. * Unlocks the audio engine once a user action has been done on the dom.
  27295. * This is helpful to resume play once browser policies have been satisfied.
  27296. */
  27297. unlock(): void;
  27298. }
  27299. /**
  27300. * This represents the default audio engine used in babylon.
  27301. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27302. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27303. */
  27304. export class AudioEngine implements IAudioEngine {
  27305. private _audioContext;
  27306. private _audioContextInitialized;
  27307. private _muteButton;
  27308. private _hostElement;
  27309. /**
  27310. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27311. */
  27312. canUseWebAudio: boolean;
  27313. /**
  27314. * The master gain node defines the global audio volume of your audio engine.
  27315. */
  27316. masterGain: GainNode;
  27317. /**
  27318. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27319. * @ignoreNaming
  27320. */
  27321. WarnedWebAudioUnsupported: boolean;
  27322. /**
  27323. * Gets whether or not mp3 are supported by your browser.
  27324. */
  27325. isMP3supported: boolean;
  27326. /**
  27327. * Gets whether or not ogg are supported by your browser.
  27328. */
  27329. isOGGsupported: boolean;
  27330. /**
  27331. * Gets whether audio has been unlocked on the device.
  27332. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27333. * a user interaction has happened.
  27334. */
  27335. unlocked: boolean;
  27336. /**
  27337. * Defines if the audio engine relies on a custom unlocked button.
  27338. * In this case, the embedded button will not be displayed.
  27339. */
  27340. useCustomUnlockedButton: boolean;
  27341. /**
  27342. * Event raised when audio has been unlocked on the browser.
  27343. */
  27344. onAudioUnlockedObservable: Observable<AudioEngine>;
  27345. /**
  27346. * Event raised when audio has been locked on the browser.
  27347. */
  27348. onAudioLockedObservable: Observable<AudioEngine>;
  27349. /**
  27350. * Gets the current AudioContext if available.
  27351. */
  27352. readonly audioContext: Nullable<AudioContext>;
  27353. private _connectedAnalyser;
  27354. /**
  27355. * Instantiates a new audio engine.
  27356. *
  27357. * There should be only one per page as some browsers restrict the number
  27358. * of audio contexts you can create.
  27359. * @param hostElement defines the host element where to display the mute icon if necessary
  27360. */
  27361. constructor(hostElement?: Nullable<HTMLElement>);
  27362. /**
  27363. * Flags the audio engine in Locked state.
  27364. * This happens due to new browser policies preventing audio to autoplay.
  27365. */
  27366. lock(): void;
  27367. /**
  27368. * Unlocks the audio engine once a user action has been done on the dom.
  27369. * This is helpful to resume play once browser policies have been satisfied.
  27370. */
  27371. unlock(): void;
  27372. private _resumeAudioContext;
  27373. private _initializeAudioContext;
  27374. private _tryToRun;
  27375. private _triggerRunningState;
  27376. private _triggerSuspendedState;
  27377. private _displayMuteButton;
  27378. private _moveButtonToTopLeft;
  27379. private _onResize;
  27380. private _hideMuteButton;
  27381. /**
  27382. * Destroy and release the resources associated with the audio ccontext.
  27383. */
  27384. dispose(): void;
  27385. /**
  27386. * Gets the global volume sets on the master gain.
  27387. * @returns the global volume if set or -1 otherwise
  27388. */
  27389. getGlobalVolume(): number;
  27390. /**
  27391. * Sets the global volume of your experience (sets on the master gain).
  27392. * @param newVolume Defines the new global volume of the application
  27393. */
  27394. setGlobalVolume(newVolume: number): void;
  27395. /**
  27396. * Connect the audio engine to an audio analyser allowing some amazing
  27397. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27398. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27399. * @param analyser The analyser to connect to the engine
  27400. */
  27401. connectToAnalyser(analyser: Analyser): void;
  27402. }
  27403. }
  27404. declare module "babylonjs/Loading/loadingScreen" {
  27405. /**
  27406. * Interface used to present a loading screen while loading a scene
  27407. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27408. */
  27409. export interface ILoadingScreen {
  27410. /**
  27411. * Function called to display the loading screen
  27412. */
  27413. displayLoadingUI: () => void;
  27414. /**
  27415. * Function called to hide the loading screen
  27416. */
  27417. hideLoadingUI: () => void;
  27418. /**
  27419. * Gets or sets the color to use for the background
  27420. */
  27421. loadingUIBackgroundColor: string;
  27422. /**
  27423. * Gets or sets the text to display while loading
  27424. */
  27425. loadingUIText: string;
  27426. }
  27427. /**
  27428. * Class used for the default loading screen
  27429. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27430. */
  27431. export class DefaultLoadingScreen implements ILoadingScreen {
  27432. private _renderingCanvas;
  27433. private _loadingText;
  27434. private _loadingDivBackgroundColor;
  27435. private _loadingDiv;
  27436. private _loadingTextDiv;
  27437. /**
  27438. * Creates a new default loading screen
  27439. * @param _renderingCanvas defines the canvas used to render the scene
  27440. * @param _loadingText defines the default text to display
  27441. * @param _loadingDivBackgroundColor defines the default background color
  27442. */
  27443. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27444. /**
  27445. * Function called to display the loading screen
  27446. */
  27447. displayLoadingUI(): void;
  27448. /**
  27449. * Function called to hide the loading screen
  27450. */
  27451. hideLoadingUI(): void;
  27452. /**
  27453. * Gets or sets the text to display while loading
  27454. */
  27455. loadingUIText: string;
  27456. /**
  27457. * Gets or sets the color to use for the background
  27458. */
  27459. loadingUIBackgroundColor: string;
  27460. private _resizeLoadingUI;
  27461. }
  27462. }
  27463. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27464. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27465. import { Engine } from "babylonjs/Engines/engine";
  27466. import { Nullable } from "babylonjs/types";
  27467. /** @hidden */
  27468. export class WebGLPipelineContext implements IPipelineContext {
  27469. engine: Engine;
  27470. program: Nullable<WebGLProgram>;
  27471. context?: WebGLRenderingContext;
  27472. vertexShader?: WebGLShader;
  27473. fragmentShader?: WebGLShader;
  27474. isParallelCompiled: boolean;
  27475. onCompiled?: () => void;
  27476. transformFeedback?: WebGLTransformFeedback | null;
  27477. readonly isAsync: boolean;
  27478. readonly isReady: boolean;
  27479. }
  27480. }
  27481. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27482. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27483. /** @hidden */
  27484. export class WebGLDataBuffer extends DataBuffer {
  27485. private _buffer;
  27486. constructor(resource: WebGLBuffer);
  27487. readonly underlyingResource: any;
  27488. }
  27489. }
  27490. declare module "babylonjs/Materials/Textures/videoTexture" {
  27491. import { Observable } from "babylonjs/Misc/observable";
  27492. import { Nullable } from "babylonjs/types";
  27493. import { Scene } from "babylonjs/scene";
  27494. import { Texture } from "babylonjs/Materials/Textures/texture";
  27495. /**
  27496. * Settings for finer control over video usage
  27497. */
  27498. export interface VideoTextureSettings {
  27499. /**
  27500. * Applies `autoplay` to video, if specified
  27501. */
  27502. autoPlay?: boolean;
  27503. /**
  27504. * Applies `loop` to video, if specified
  27505. */
  27506. loop?: boolean;
  27507. /**
  27508. * Automatically updates internal texture from video at every frame in the render loop
  27509. */
  27510. autoUpdateTexture: boolean;
  27511. /**
  27512. * Image src displayed during the video loading or until the user interacts with the video.
  27513. */
  27514. poster?: string;
  27515. }
  27516. /**
  27517. * If you want to display a video in your scene, this is the special texture for that.
  27518. * This special texture works similar to other textures, with the exception of a few parameters.
  27519. * @see https://doc.babylonjs.com/how_to/video_texture
  27520. */
  27521. export class VideoTexture extends Texture {
  27522. /**
  27523. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27524. */
  27525. readonly autoUpdateTexture: boolean;
  27526. /**
  27527. * The video instance used by the texture internally
  27528. */
  27529. readonly video: HTMLVideoElement;
  27530. private _onUserActionRequestedObservable;
  27531. /**
  27532. * Event triggerd when a dom action is required by the user to play the video.
  27533. * This happens due to recent changes in browser policies preventing video to auto start.
  27534. */
  27535. readonly onUserActionRequestedObservable: Observable<Texture>;
  27536. private _generateMipMaps;
  27537. private _engine;
  27538. private _stillImageCaptured;
  27539. private _displayingPosterTexture;
  27540. private _settings;
  27541. private _createInternalTextureOnEvent;
  27542. /**
  27543. * Creates a video texture.
  27544. * If you want to display a video in your scene, this is the special texture for that.
  27545. * This special texture works similar to other textures, with the exception of a few parameters.
  27546. * @see https://doc.babylonjs.com/how_to/video_texture
  27547. * @param name optional name, will detect from video source, if not defined
  27548. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27549. * @param scene is obviously the current scene.
  27550. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27551. * @param invertY is false by default but can be used to invert video on Y axis
  27552. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27553. * @param settings allows finer control over video usage
  27554. */
  27555. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27556. private _getName;
  27557. private _getVideo;
  27558. private _createInternalTexture;
  27559. private reset;
  27560. /**
  27561. * @hidden Internal method to initiate `update`.
  27562. */
  27563. _rebuild(): void;
  27564. /**
  27565. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27566. */
  27567. update(): void;
  27568. /**
  27569. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27570. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27571. */
  27572. updateTexture(isVisible: boolean): void;
  27573. protected _updateInternalTexture: () => void;
  27574. /**
  27575. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27576. * @param url New url.
  27577. */
  27578. updateURL(url: string): void;
  27579. /**
  27580. * Dispose the texture and release its associated resources.
  27581. */
  27582. dispose(): void;
  27583. /**
  27584. * Creates a video texture straight from a stream.
  27585. * @param scene Define the scene the texture should be created in
  27586. * @param stream Define the stream the texture should be created from
  27587. * @returns The created video texture as a promise
  27588. */
  27589. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27590. /**
  27591. * Creates a video texture straight from your WebCam video feed.
  27592. * @param scene Define the scene the texture should be created in
  27593. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27594. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27595. * @returns The created video texture as a promise
  27596. */
  27597. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27598. minWidth: number;
  27599. maxWidth: number;
  27600. minHeight: number;
  27601. maxHeight: number;
  27602. deviceId: string;
  27603. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27604. /**
  27605. * Creates a video texture straight from your WebCam video feed.
  27606. * @param scene Define the scene the texture should be created in
  27607. * @param onReady Define a callback to triggered once the texture will be ready
  27608. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27609. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27610. */
  27611. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27612. minWidth: number;
  27613. maxWidth: number;
  27614. minHeight: number;
  27615. maxHeight: number;
  27616. deviceId: string;
  27617. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27618. }
  27619. }
  27620. declare module "babylonjs/Engines/engine" {
  27621. import { Observable } from "babylonjs/Misc/observable";
  27622. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27623. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27624. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27625. import { Camera } from "babylonjs/Cameras/camera";
  27626. import { Scene } from "babylonjs/scene";
  27627. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27628. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27629. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27630. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27631. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27632. import { Material } from "babylonjs/Materials/material";
  27633. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27634. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27635. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27636. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27637. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27638. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27639. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27640. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27641. import { WebRequest } from "babylonjs/Misc/webRequest";
  27642. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  27643. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27644. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27645. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27646. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27647. /**
  27648. * Interface for attribute information associated with buffer instanciation
  27649. */
  27650. export class InstancingAttributeInfo {
  27651. /**
  27652. * Index/offset of the attribute in the vertex shader
  27653. */
  27654. index: number;
  27655. /**
  27656. * size of the attribute, 1, 2, 3 or 4
  27657. */
  27658. attributeSize: number;
  27659. /**
  27660. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27661. * default is FLOAT
  27662. */
  27663. attribyteType: number;
  27664. /**
  27665. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27666. */
  27667. normalized: boolean;
  27668. /**
  27669. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27670. */
  27671. offset: number;
  27672. /**
  27673. * Name of the GLSL attribute, for debugging purpose only
  27674. */
  27675. attributeName: string;
  27676. }
  27677. /**
  27678. * Define options used to create a depth texture
  27679. */
  27680. export class DepthTextureCreationOptions {
  27681. /** Specifies whether or not a stencil should be allocated in the texture */
  27682. generateStencil?: boolean;
  27683. /** Specifies whether or not bilinear filtering is enable on the texture */
  27684. bilinearFiltering?: boolean;
  27685. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27686. comparisonFunction?: number;
  27687. /** Specifies if the created texture is a cube texture */
  27688. isCube?: boolean;
  27689. }
  27690. /**
  27691. * Class used to describe the capabilities of the engine relatively to the current browser
  27692. */
  27693. export class EngineCapabilities {
  27694. /** Maximum textures units per fragment shader */
  27695. maxTexturesImageUnits: number;
  27696. /** Maximum texture units per vertex shader */
  27697. maxVertexTextureImageUnits: number;
  27698. /** Maximum textures units in the entire pipeline */
  27699. maxCombinedTexturesImageUnits: number;
  27700. /** Maximum texture size */
  27701. maxTextureSize: number;
  27702. /** Maximum cube texture size */
  27703. maxCubemapTextureSize: number;
  27704. /** Maximum render texture size */
  27705. maxRenderTextureSize: number;
  27706. /** Maximum number of vertex attributes */
  27707. maxVertexAttribs: number;
  27708. /** Maximum number of varyings */
  27709. maxVaryingVectors: number;
  27710. /** Maximum number of uniforms per vertex shader */
  27711. maxVertexUniformVectors: number;
  27712. /** Maximum number of uniforms per fragment shader */
  27713. maxFragmentUniformVectors: number;
  27714. /** Defines if standard derivates (dx/dy) are supported */
  27715. standardDerivatives: boolean;
  27716. /** Defines if s3tc texture compression is supported */
  27717. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27718. /** Defines if pvrtc texture compression is supported */
  27719. pvrtc: any;
  27720. /** Defines if etc1 texture compression is supported */
  27721. etc1: any;
  27722. /** Defines if etc2 texture compression is supported */
  27723. etc2: any;
  27724. /** Defines if astc texture compression is supported */
  27725. astc: any;
  27726. /** Defines if float textures are supported */
  27727. textureFloat: boolean;
  27728. /** Defines if vertex array objects are supported */
  27729. vertexArrayObject: boolean;
  27730. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27731. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27732. /** Gets the maximum level of anisotropy supported */
  27733. maxAnisotropy: number;
  27734. /** Defines if instancing is supported */
  27735. instancedArrays: boolean;
  27736. /** Defines if 32 bits indices are supported */
  27737. uintIndices: boolean;
  27738. /** Defines if high precision shaders are supported */
  27739. highPrecisionShaderSupported: boolean;
  27740. /** Defines if depth reading in the fragment shader is supported */
  27741. fragmentDepthSupported: boolean;
  27742. /** Defines if float texture linear filtering is supported*/
  27743. textureFloatLinearFiltering: boolean;
  27744. /** Defines if rendering to float textures is supported */
  27745. textureFloatRender: boolean;
  27746. /** Defines if half float textures are supported*/
  27747. textureHalfFloat: boolean;
  27748. /** Defines if half float texture linear filtering is supported*/
  27749. textureHalfFloatLinearFiltering: boolean;
  27750. /** Defines if rendering to half float textures is supported */
  27751. textureHalfFloatRender: boolean;
  27752. /** Defines if textureLOD shader command is supported */
  27753. textureLOD: boolean;
  27754. /** Defines if draw buffers extension is supported */
  27755. drawBuffersExtension: boolean;
  27756. /** Defines if depth textures are supported */
  27757. depthTextureExtension: boolean;
  27758. /** Defines if float color buffer are supported */
  27759. colorBufferFloat: boolean;
  27760. /** Gets disjoint timer query extension (null if not supported) */
  27761. timerQuery: EXT_disjoint_timer_query;
  27762. /** Defines if timestamp can be used with timer query */
  27763. canUseTimestampForTimerQuery: boolean;
  27764. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27765. multiview: any;
  27766. /** Function used to let the system compiles shaders in background */
  27767. parallelShaderCompile: {
  27768. COMPLETION_STATUS_KHR: number;
  27769. };
  27770. }
  27771. /** Interface defining initialization parameters for Engine class */
  27772. export interface EngineOptions extends WebGLContextAttributes {
  27773. /**
  27774. * Defines if the engine should no exceed a specified device ratio
  27775. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27776. */
  27777. limitDeviceRatio?: number;
  27778. /**
  27779. * Defines if webvr should be enabled automatically
  27780. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27781. */
  27782. autoEnableWebVR?: boolean;
  27783. /**
  27784. * Defines if webgl2 should be turned off even if supported
  27785. * @see http://doc.babylonjs.com/features/webgl2
  27786. */
  27787. disableWebGL2Support?: boolean;
  27788. /**
  27789. * Defines if webaudio should be initialized as well
  27790. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27791. */
  27792. audioEngine?: boolean;
  27793. /**
  27794. * Defines if animations should run using a deterministic lock step
  27795. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27796. */
  27797. deterministicLockstep?: boolean;
  27798. /** Defines the maximum steps to use with deterministic lock step mode */
  27799. lockstepMaxSteps?: number;
  27800. /**
  27801. * Defines that engine should ignore context lost events
  27802. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27803. */
  27804. doNotHandleContextLost?: boolean;
  27805. /**
  27806. * Defines that engine should ignore modifying touch action attribute and style
  27807. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27808. */
  27809. doNotHandleTouchAction?: boolean;
  27810. /**
  27811. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27812. */
  27813. useHighPrecisionFloats?: boolean;
  27814. }
  27815. /**
  27816. * Defines the interface used by display changed events
  27817. */
  27818. export interface IDisplayChangedEventArgs {
  27819. /** Gets the vrDisplay object (if any) */
  27820. vrDisplay: Nullable<any>;
  27821. /** Gets a boolean indicating if webVR is supported */
  27822. vrSupported: boolean;
  27823. }
  27824. /**
  27825. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27826. */
  27827. export class Engine {
  27828. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27829. static ExceptionList: ({
  27830. key: string;
  27831. capture: string;
  27832. captureConstraint: number;
  27833. targets: string[];
  27834. } | {
  27835. key: string;
  27836. capture: null;
  27837. captureConstraint: null;
  27838. targets: string[];
  27839. })[];
  27840. /** Gets the list of created engines */
  27841. static readonly Instances: Engine[];
  27842. /**
  27843. * Gets the latest created engine
  27844. */
  27845. static readonly LastCreatedEngine: Nullable<Engine>;
  27846. /**
  27847. * Gets the latest created scene
  27848. */
  27849. static readonly LastCreatedScene: Nullable<Scene>;
  27850. /**
  27851. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27852. * @param flag defines which part of the materials must be marked as dirty
  27853. * @param predicate defines a predicate used to filter which materials should be affected
  27854. */
  27855. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27856. /**
  27857. * Hidden
  27858. */
  27859. static _TextureLoaders: IInternalTextureLoader[];
  27860. /** Defines that alpha blending is disabled */
  27861. static readonly ALPHA_DISABLE: number;
  27862. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27863. static readonly ALPHA_ADD: number;
  27864. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27865. static readonly ALPHA_COMBINE: number;
  27866. /** Defines that alpha blending to DEST - SRC * DEST */
  27867. static readonly ALPHA_SUBTRACT: number;
  27868. /** Defines that alpha blending to SRC * DEST */
  27869. static readonly ALPHA_MULTIPLY: number;
  27870. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27871. static readonly ALPHA_MAXIMIZED: number;
  27872. /** Defines that alpha blending to SRC + DEST */
  27873. static readonly ALPHA_ONEONE: number;
  27874. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27875. static readonly ALPHA_PREMULTIPLIED: number;
  27876. /**
  27877. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27878. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27879. */
  27880. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27881. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27882. static readonly ALPHA_INTERPOLATE: number;
  27883. /**
  27884. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27885. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27886. */
  27887. static readonly ALPHA_SCREENMODE: number;
  27888. /** Defines that the ressource is not delayed*/
  27889. static readonly DELAYLOADSTATE_NONE: number;
  27890. /** Defines that the ressource was successfully delay loaded */
  27891. static readonly DELAYLOADSTATE_LOADED: number;
  27892. /** Defines that the ressource is currently delay loading */
  27893. static readonly DELAYLOADSTATE_LOADING: number;
  27894. /** Defines that the ressource is delayed and has not started loading */
  27895. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27896. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27897. static readonly NEVER: number;
  27898. /** 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 */
  27899. static readonly ALWAYS: number;
  27900. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27901. static readonly LESS: number;
  27902. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27903. static readonly EQUAL: number;
  27904. /** 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 */
  27905. static readonly LEQUAL: number;
  27906. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27907. static readonly GREATER: number;
  27908. /** 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 */
  27909. static readonly GEQUAL: number;
  27910. /** 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 */
  27911. static readonly NOTEQUAL: number;
  27912. /** Passed to stencilOperation to specify that stencil value must be kept */
  27913. static readonly KEEP: number;
  27914. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27915. static readonly REPLACE: number;
  27916. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27917. static readonly INCR: number;
  27918. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27919. static readonly DECR: number;
  27920. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27921. static readonly INVERT: number;
  27922. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27923. static readonly INCR_WRAP: number;
  27924. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27925. static readonly DECR_WRAP: number;
  27926. /** Texture is not repeating outside of 0..1 UVs */
  27927. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27928. /** Texture is repeating outside of 0..1 UVs */
  27929. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27930. /** Texture is repeating and mirrored */
  27931. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27932. /** ALPHA */
  27933. static readonly TEXTUREFORMAT_ALPHA: number;
  27934. /** LUMINANCE */
  27935. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27936. /** LUMINANCE_ALPHA */
  27937. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27938. /** RGB */
  27939. static readonly TEXTUREFORMAT_RGB: number;
  27940. /** RGBA */
  27941. static readonly TEXTUREFORMAT_RGBA: number;
  27942. /** RED */
  27943. static readonly TEXTUREFORMAT_RED: number;
  27944. /** RED (2nd reference) */
  27945. static readonly TEXTUREFORMAT_R: number;
  27946. /** RG */
  27947. static readonly TEXTUREFORMAT_RG: number;
  27948. /** RED_INTEGER */
  27949. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27950. /** RED_INTEGER (2nd reference) */
  27951. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27952. /** RG_INTEGER */
  27953. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27954. /** RGB_INTEGER */
  27955. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27956. /** RGBA_INTEGER */
  27957. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27958. /** UNSIGNED_BYTE */
  27959. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27960. /** UNSIGNED_BYTE (2nd reference) */
  27961. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27962. /** FLOAT */
  27963. static readonly TEXTURETYPE_FLOAT: number;
  27964. /** HALF_FLOAT */
  27965. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27966. /** BYTE */
  27967. static readonly TEXTURETYPE_BYTE: number;
  27968. /** SHORT */
  27969. static readonly TEXTURETYPE_SHORT: number;
  27970. /** UNSIGNED_SHORT */
  27971. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27972. /** INT */
  27973. static readonly TEXTURETYPE_INT: number;
  27974. /** UNSIGNED_INT */
  27975. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27976. /** UNSIGNED_SHORT_4_4_4_4 */
  27977. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27978. /** UNSIGNED_SHORT_5_5_5_1 */
  27979. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27980. /** UNSIGNED_SHORT_5_6_5 */
  27981. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27982. /** UNSIGNED_INT_2_10_10_10_REV */
  27983. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27984. /** UNSIGNED_INT_24_8 */
  27985. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27986. /** UNSIGNED_INT_10F_11F_11F_REV */
  27987. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27988. /** UNSIGNED_INT_5_9_9_9_REV */
  27989. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27990. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27991. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27992. /** nearest is mag = nearest and min = nearest and mip = linear */
  27993. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27994. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27995. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27996. /** Trilinear is mag = linear and min = linear and mip = linear */
  27997. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27998. /** nearest is mag = nearest and min = nearest and mip = linear */
  27999. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28000. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28001. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28002. /** Trilinear is mag = linear and min = linear and mip = linear */
  28003. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28004. /** mag = nearest and min = nearest and mip = nearest */
  28005. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28006. /** mag = nearest and min = linear and mip = nearest */
  28007. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28008. /** mag = nearest and min = linear and mip = linear */
  28009. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28010. /** mag = nearest and min = linear and mip = none */
  28011. static readonly TEXTURE_NEAREST_LINEAR: number;
  28012. /** mag = nearest and min = nearest and mip = none */
  28013. static readonly TEXTURE_NEAREST_NEAREST: number;
  28014. /** mag = linear and min = nearest and mip = nearest */
  28015. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28016. /** mag = linear and min = nearest and mip = linear */
  28017. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28018. /** mag = linear and min = linear and mip = none */
  28019. static readonly TEXTURE_LINEAR_LINEAR: number;
  28020. /** mag = linear and min = nearest and mip = none */
  28021. static readonly TEXTURE_LINEAR_NEAREST: number;
  28022. /** Explicit coordinates mode */
  28023. static readonly TEXTURE_EXPLICIT_MODE: number;
  28024. /** Spherical coordinates mode */
  28025. static readonly TEXTURE_SPHERICAL_MODE: number;
  28026. /** Planar coordinates mode */
  28027. static readonly TEXTURE_PLANAR_MODE: number;
  28028. /** Cubic coordinates mode */
  28029. static readonly TEXTURE_CUBIC_MODE: number;
  28030. /** Projection coordinates mode */
  28031. static readonly TEXTURE_PROJECTION_MODE: number;
  28032. /** Skybox coordinates mode */
  28033. static readonly TEXTURE_SKYBOX_MODE: number;
  28034. /** Inverse Cubic coordinates mode */
  28035. static readonly TEXTURE_INVCUBIC_MODE: number;
  28036. /** Equirectangular coordinates mode */
  28037. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28038. /** Equirectangular Fixed coordinates mode */
  28039. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28040. /** Equirectangular Fixed Mirrored coordinates mode */
  28041. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28042. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28043. static readonly SCALEMODE_FLOOR: number;
  28044. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28045. static readonly SCALEMODE_NEAREST: number;
  28046. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28047. static readonly SCALEMODE_CEILING: number;
  28048. /**
  28049. * Returns the current npm package of the sdk
  28050. */
  28051. static readonly NpmPackage: string;
  28052. /**
  28053. * Returns the current version of the framework
  28054. */
  28055. static readonly Version: string;
  28056. /**
  28057. * Returns a string describing the current engine
  28058. */
  28059. readonly description: string;
  28060. /**
  28061. * Gets or sets the epsilon value used by collision engine
  28062. */
  28063. static CollisionsEpsilon: number;
  28064. /**
  28065. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28066. */
  28067. static ShadersRepository: string;
  28068. /**
  28069. * Method called to create the default loading screen.
  28070. * This can be overriden in your own app.
  28071. * @param canvas The rendering canvas element
  28072. * @returns The loading screen
  28073. */
  28074. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28075. /**
  28076. * Method called to create the default rescale post process on each engine.
  28077. */
  28078. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28079. /**
  28080. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28081. */
  28082. forcePOTTextures: boolean;
  28083. /**
  28084. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28085. */
  28086. isFullscreen: boolean;
  28087. /**
  28088. * Gets a boolean indicating if the pointer is currently locked
  28089. */
  28090. isPointerLock: boolean;
  28091. /**
  28092. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28093. */
  28094. cullBackFaces: boolean;
  28095. /**
  28096. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28097. */
  28098. renderEvenInBackground: boolean;
  28099. /**
  28100. * Gets or sets a boolean indicating that cache can be kept between frames
  28101. */
  28102. preventCacheWipeBetweenFrames: boolean;
  28103. /**
  28104. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28105. **/
  28106. enableOfflineSupport: boolean;
  28107. /**
  28108. * 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)
  28109. **/
  28110. disableManifestCheck: boolean;
  28111. /**
  28112. * Gets the list of created scenes
  28113. */
  28114. scenes: Scene[];
  28115. /**
  28116. * Event raised when a new scene is created
  28117. */
  28118. onNewSceneAddedObservable: Observable<Scene>;
  28119. /**
  28120. * Gets the list of created postprocesses
  28121. */
  28122. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28123. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28124. validateShaderPrograms: boolean;
  28125. /**
  28126. * Observable event triggered each time the rendering canvas is resized
  28127. */
  28128. onResizeObservable: Observable<Engine>;
  28129. /**
  28130. * Observable event triggered each time the canvas loses focus
  28131. */
  28132. onCanvasBlurObservable: Observable<Engine>;
  28133. /**
  28134. * Observable event triggered each time the canvas gains focus
  28135. */
  28136. onCanvasFocusObservable: Observable<Engine>;
  28137. /**
  28138. * Observable event triggered each time the canvas receives pointerout event
  28139. */
  28140. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28141. /**
  28142. * Observable event triggered before each texture is initialized
  28143. */
  28144. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28145. private _vrDisplay;
  28146. private _vrSupported;
  28147. private _oldSize;
  28148. private _oldHardwareScaleFactor;
  28149. private _vrExclusivePointerMode;
  28150. private _webVRInitPromise;
  28151. /**
  28152. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  28153. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  28154. */
  28155. readonly isInVRExclusivePointerMode: boolean;
  28156. /**
  28157. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28158. */
  28159. disableUniformBuffers: boolean;
  28160. /** @hidden */
  28161. _uniformBuffers: UniformBuffer[];
  28162. /**
  28163. * Gets a boolean indicating that the engine supports uniform buffers
  28164. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28165. */
  28166. readonly supportsUniformBuffers: boolean;
  28167. /**
  28168. * Observable raised when the engine begins a new frame
  28169. */
  28170. onBeginFrameObservable: Observable<Engine>;
  28171. /**
  28172. * If set, will be used to request the next animation frame for the render loop
  28173. */
  28174. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28175. /**
  28176. * Observable raised when the engine ends the current frame
  28177. */
  28178. onEndFrameObservable: Observable<Engine>;
  28179. /**
  28180. * Observable raised when the engine is about to compile a shader
  28181. */
  28182. onBeforeShaderCompilationObservable: Observable<Engine>;
  28183. /**
  28184. * Observable raised when the engine has jsut compiled a shader
  28185. */
  28186. onAfterShaderCompilationObservable: Observable<Engine>;
  28187. /** @hidden */
  28188. _gl: WebGLRenderingContext;
  28189. private _renderingCanvas;
  28190. private _windowIsBackground;
  28191. private _webGLVersion;
  28192. protected _highPrecisionShadersAllowed: boolean;
  28193. /** @hidden */
  28194. readonly _shouldUseHighPrecisionShader: boolean;
  28195. /**
  28196. * Gets a boolean indicating that only power of 2 textures are supported
  28197. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28198. */
  28199. readonly needPOTTextures: boolean;
  28200. /** @hidden */
  28201. _badOS: boolean;
  28202. /** @hidden */
  28203. _badDesktopOS: boolean;
  28204. /**
  28205. * Gets the audio engine
  28206. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28207. * @ignorenaming
  28208. */
  28209. static audioEngine: IAudioEngine;
  28210. /**
  28211. * Default AudioEngine factory responsible of creating the Audio Engine.
  28212. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28213. */
  28214. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28215. /**
  28216. * Default offline support factory responsible of creating a tool used to store data locally.
  28217. * By default, this will create a Database object if the workload has been embedded.
  28218. */
  28219. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28220. private _onFocus;
  28221. private _onBlur;
  28222. private _onCanvasPointerOut;
  28223. private _onCanvasBlur;
  28224. private _onCanvasFocus;
  28225. private _onFullscreenChange;
  28226. private _onPointerLockChange;
  28227. private _onVRDisplayPointerRestricted;
  28228. private _onVRDisplayPointerUnrestricted;
  28229. private _onVrDisplayConnect;
  28230. private _onVrDisplayDisconnect;
  28231. private _onVrDisplayPresentChange;
  28232. /**
  28233. * Observable signaled when VR display mode changes
  28234. */
  28235. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  28236. /**
  28237. * Observable signaled when VR request present is complete
  28238. */
  28239. onVRRequestPresentComplete: Observable<boolean>;
  28240. /**
  28241. * Observable signaled when VR request present starts
  28242. */
  28243. onVRRequestPresentStart: Observable<Engine>;
  28244. private _hardwareScalingLevel;
  28245. /** @hidden */
  28246. _caps: EngineCapabilities;
  28247. private _pointerLockRequested;
  28248. private _isStencilEnable;
  28249. private _colorWrite;
  28250. private _loadingScreen;
  28251. /** @hidden */
  28252. _drawCalls: PerfCounter;
  28253. private _glVersion;
  28254. private _glRenderer;
  28255. private _glVendor;
  28256. private _videoTextureSupported;
  28257. private _renderingQueueLaunched;
  28258. private _activeRenderLoops;
  28259. private _deterministicLockstep;
  28260. private _lockstepMaxSteps;
  28261. /**
  28262. * Observable signaled when a context lost event is raised
  28263. */
  28264. onContextLostObservable: Observable<Engine>;
  28265. /**
  28266. * Observable signaled when a context restored event is raised
  28267. */
  28268. onContextRestoredObservable: Observable<Engine>;
  28269. private _onContextLost;
  28270. private _onContextRestored;
  28271. private _contextWasLost;
  28272. /** @hidden */
  28273. _doNotHandleContextLost: boolean;
  28274. /**
  28275. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28276. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28277. */
  28278. doNotHandleContextLost: boolean;
  28279. private _performanceMonitor;
  28280. private _fps;
  28281. private _deltaTime;
  28282. /**
  28283. * Turn this value on if you want to pause FPS computation when in background
  28284. */
  28285. disablePerformanceMonitorInBackground: boolean;
  28286. /**
  28287. * Gets the performance monitor attached to this engine
  28288. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28289. */
  28290. readonly performanceMonitor: PerformanceMonitor;
  28291. /**
  28292. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28293. */
  28294. disableVertexArrayObjects: boolean;
  28295. /** @hidden */
  28296. protected _depthCullingState: _DepthCullingState;
  28297. /** @hidden */
  28298. protected _stencilState: _StencilState;
  28299. /** @hidden */
  28300. protected _alphaState: _AlphaState;
  28301. /** @hidden */
  28302. protected _alphaMode: number;
  28303. /** @hidden */
  28304. _internalTexturesCache: InternalTexture[];
  28305. /** @hidden */
  28306. protected _activeChannel: number;
  28307. private _currentTextureChannel;
  28308. /** @hidden */
  28309. protected _boundTexturesCache: {
  28310. [key: string]: Nullable<InternalTexture>;
  28311. };
  28312. /** @hidden */
  28313. protected _currentEffect: Nullable<Effect>;
  28314. /** @hidden */
  28315. protected _currentProgram: Nullable<WebGLProgram>;
  28316. private _compiledEffects;
  28317. private _vertexAttribArraysEnabled;
  28318. /** @hidden */
  28319. protected _cachedViewport: Nullable<Viewport>;
  28320. private _cachedVertexArrayObject;
  28321. /** @hidden */
  28322. protected _cachedVertexBuffers: any;
  28323. /** @hidden */
  28324. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28325. /** @hidden */
  28326. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28327. /** @hidden */
  28328. _currentRenderTarget: Nullable<InternalTexture>;
  28329. private _uintIndicesCurrentlySet;
  28330. private _currentBoundBuffer;
  28331. /** @hidden */
  28332. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28333. private _currentBufferPointers;
  28334. private _currentInstanceLocations;
  28335. private _currentInstanceBuffers;
  28336. private _textureUnits;
  28337. /** @hidden */
  28338. _workingCanvas: Nullable<HTMLCanvasElement>;
  28339. /** @hidden */
  28340. _workingContext: Nullable<CanvasRenderingContext2D>;
  28341. private _rescalePostProcess;
  28342. private _dummyFramebuffer;
  28343. private _externalData;
  28344. private _bindedRenderFunction;
  28345. private _vaoRecordInProgress;
  28346. private _mustWipeVertexAttributes;
  28347. private _emptyTexture;
  28348. private _emptyCubeTexture;
  28349. private _emptyTexture3D;
  28350. /** @hidden */
  28351. _frameHandler: number;
  28352. private _nextFreeTextureSlots;
  28353. private _maxSimultaneousTextures;
  28354. private _activeRequests;
  28355. private _texturesSupported;
  28356. /** @hidden */
  28357. _textureFormatInUse: Nullable<string>;
  28358. /**
  28359. * Gets the list of texture formats supported
  28360. */
  28361. readonly texturesSupported: Array<string>;
  28362. /**
  28363. * Gets the list of texture formats in use
  28364. */
  28365. readonly textureFormatInUse: Nullable<string>;
  28366. /**
  28367. * Gets the current viewport
  28368. */
  28369. readonly currentViewport: Nullable<Viewport>;
  28370. /**
  28371. * Gets the default empty texture
  28372. */
  28373. readonly emptyTexture: InternalTexture;
  28374. /**
  28375. * Gets the default empty 3D texture
  28376. */
  28377. readonly emptyTexture3D: InternalTexture;
  28378. /**
  28379. * Gets the default empty cube texture
  28380. */
  28381. readonly emptyCubeTexture: InternalTexture;
  28382. /**
  28383. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28384. */
  28385. readonly premultipliedAlpha: boolean;
  28386. /**
  28387. * Creates a new engine
  28388. * @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
  28389. * @param antialias defines enable antialiasing (default: false)
  28390. * @param options defines further options to be sent to the getContext() function
  28391. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28392. */
  28393. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28394. private _disableTouchAction;
  28395. private _rebuildInternalTextures;
  28396. private _rebuildEffects;
  28397. /**
  28398. * Gets a boolean indicating if all created effects are ready
  28399. * @returns true if all effects are ready
  28400. */
  28401. areAllEffectsReady(): boolean;
  28402. private _rebuildBuffers;
  28403. private _initGLContext;
  28404. /**
  28405. * Gets version of the current webGL context
  28406. */
  28407. readonly webGLVersion: number;
  28408. /**
  28409. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28410. */
  28411. readonly isStencilEnable: boolean;
  28412. /** @hidden */
  28413. _prepareWorkingCanvas(): void;
  28414. /**
  28415. * Reset the texture cache to empty state
  28416. */
  28417. resetTextureCache(): void;
  28418. /**
  28419. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28420. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28421. * @returns true if engine is in deterministic lock step mode
  28422. */
  28423. isDeterministicLockStep(): boolean;
  28424. /**
  28425. * Gets the max steps when engine is running in deterministic lock step
  28426. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28427. * @returns the max steps
  28428. */
  28429. getLockstepMaxSteps(): number;
  28430. /**
  28431. * Gets an object containing information about the current webGL context
  28432. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28433. */
  28434. getGlInfo(): {
  28435. vendor: string;
  28436. renderer: string;
  28437. version: string;
  28438. };
  28439. /**
  28440. * Gets current aspect ratio
  28441. * @param camera defines the camera to use to get the aspect ratio
  28442. * @param useScreen defines if screen size must be used (or the current render target if any)
  28443. * @returns a number defining the aspect ratio
  28444. */
  28445. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28446. /**
  28447. * Gets current screen aspect ratio
  28448. * @returns a number defining the aspect ratio
  28449. */
  28450. getScreenAspectRatio(): number;
  28451. /**
  28452. * Gets the current render width
  28453. * @param useScreen defines if screen size must be used (or the current render target if any)
  28454. * @returns a number defining the current render width
  28455. */
  28456. getRenderWidth(useScreen?: boolean): number;
  28457. /**
  28458. * Gets the current render height
  28459. * @param useScreen defines if screen size must be used (or the current render target if any)
  28460. * @returns a number defining the current render height
  28461. */
  28462. getRenderHeight(useScreen?: boolean): number;
  28463. /**
  28464. * Gets the HTML canvas attached with the current webGL context
  28465. * @returns a HTML canvas
  28466. */
  28467. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28468. /**
  28469. * Gets the client rect of the HTML canvas attached with the current webGL context
  28470. * @returns a client rectanglee
  28471. */
  28472. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28473. /**
  28474. * Defines the hardware scaling level.
  28475. * By default the hardware scaling level is computed from the window device ratio.
  28476. * 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.
  28477. * @param level defines the level to use
  28478. */
  28479. setHardwareScalingLevel(level: number): void;
  28480. /**
  28481. * Gets the current hardware scaling level.
  28482. * By default the hardware scaling level is computed from the window device ratio.
  28483. * 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.
  28484. * @returns a number indicating the current hardware scaling level
  28485. */
  28486. getHardwareScalingLevel(): number;
  28487. /**
  28488. * Gets the list of loaded textures
  28489. * @returns an array containing all loaded textures
  28490. */
  28491. getLoadedTexturesCache(): InternalTexture[];
  28492. /**
  28493. * Gets the object containing all engine capabilities
  28494. * @returns the EngineCapabilities object
  28495. */
  28496. getCaps(): EngineCapabilities;
  28497. /**
  28498. * Gets the current depth function
  28499. * @returns a number defining the depth function
  28500. */
  28501. getDepthFunction(): Nullable<number>;
  28502. /**
  28503. * Sets the current depth function
  28504. * @param depthFunc defines the function to use
  28505. */
  28506. setDepthFunction(depthFunc: number): void;
  28507. /**
  28508. * Sets the current depth function to GREATER
  28509. */
  28510. setDepthFunctionToGreater(): void;
  28511. /**
  28512. * Sets the current depth function to GEQUAL
  28513. */
  28514. setDepthFunctionToGreaterOrEqual(): void;
  28515. /**
  28516. * Sets the current depth function to LESS
  28517. */
  28518. setDepthFunctionToLess(): void;
  28519. private _cachedStencilBuffer;
  28520. private _cachedStencilFunction;
  28521. private _cachedStencilMask;
  28522. private _cachedStencilOperationPass;
  28523. private _cachedStencilOperationFail;
  28524. private _cachedStencilOperationDepthFail;
  28525. private _cachedStencilReference;
  28526. /**
  28527. * Caches the the state of the stencil buffer
  28528. */
  28529. cacheStencilState(): void;
  28530. /**
  28531. * Restores the state of the stencil buffer
  28532. */
  28533. restoreStencilState(): void;
  28534. /**
  28535. * Sets the current depth function to LEQUAL
  28536. */
  28537. setDepthFunctionToLessOrEqual(): void;
  28538. /**
  28539. * Gets a boolean indicating if stencil buffer is enabled
  28540. * @returns the current stencil buffer state
  28541. */
  28542. getStencilBuffer(): boolean;
  28543. /**
  28544. * Enable or disable the stencil buffer
  28545. * @param enable defines if the stencil buffer must be enabled or disabled
  28546. */
  28547. setStencilBuffer(enable: boolean): void;
  28548. /**
  28549. * Gets the current stencil mask
  28550. * @returns a number defining the new stencil mask to use
  28551. */
  28552. getStencilMask(): number;
  28553. /**
  28554. * Sets the current stencil mask
  28555. * @param mask defines the new stencil mask to use
  28556. */
  28557. setStencilMask(mask: number): void;
  28558. /**
  28559. * Gets the current stencil function
  28560. * @returns a number defining the stencil function to use
  28561. */
  28562. getStencilFunction(): number;
  28563. /**
  28564. * Gets the current stencil reference value
  28565. * @returns a number defining the stencil reference value to use
  28566. */
  28567. getStencilFunctionReference(): number;
  28568. /**
  28569. * Gets the current stencil mask
  28570. * @returns a number defining the stencil mask to use
  28571. */
  28572. getStencilFunctionMask(): number;
  28573. /**
  28574. * Sets the current stencil function
  28575. * @param stencilFunc defines the new stencil function to use
  28576. */
  28577. setStencilFunction(stencilFunc: number): void;
  28578. /**
  28579. * Sets the current stencil reference
  28580. * @param reference defines the new stencil reference to use
  28581. */
  28582. setStencilFunctionReference(reference: number): void;
  28583. /**
  28584. * Sets the current stencil mask
  28585. * @param mask defines the new stencil mask to use
  28586. */
  28587. setStencilFunctionMask(mask: number): void;
  28588. /**
  28589. * Gets the current stencil operation when stencil fails
  28590. * @returns a number defining stencil operation to use when stencil fails
  28591. */
  28592. getStencilOperationFail(): number;
  28593. /**
  28594. * Gets the current stencil operation when depth fails
  28595. * @returns a number defining stencil operation to use when depth fails
  28596. */
  28597. getStencilOperationDepthFail(): number;
  28598. /**
  28599. * Gets the current stencil operation when stencil passes
  28600. * @returns a number defining stencil operation to use when stencil passes
  28601. */
  28602. getStencilOperationPass(): number;
  28603. /**
  28604. * Sets the stencil operation to use when stencil fails
  28605. * @param operation defines the stencil operation to use when stencil fails
  28606. */
  28607. setStencilOperationFail(operation: number): void;
  28608. /**
  28609. * Sets the stencil operation to use when depth fails
  28610. * @param operation defines the stencil operation to use when depth fails
  28611. */
  28612. setStencilOperationDepthFail(operation: number): void;
  28613. /**
  28614. * Sets the stencil operation to use when stencil passes
  28615. * @param operation defines the stencil operation to use when stencil passes
  28616. */
  28617. setStencilOperationPass(operation: number): void;
  28618. /**
  28619. * Sets a boolean indicating if the dithering state is enabled or disabled
  28620. * @param value defines the dithering state
  28621. */
  28622. setDitheringState(value: boolean): void;
  28623. /**
  28624. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28625. * @param value defines the rasterizer state
  28626. */
  28627. setRasterizerState(value: boolean): void;
  28628. /**
  28629. * stop executing a render loop function and remove it from the execution array
  28630. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28631. */
  28632. stopRenderLoop(renderFunction?: () => void): void;
  28633. /** @hidden */
  28634. _renderLoop(): void;
  28635. /**
  28636. * Register and execute a render loop. The engine can have more than one render function
  28637. * @param renderFunction defines the function to continuously execute
  28638. */
  28639. runRenderLoop(renderFunction: () => void): void;
  28640. /**
  28641. * Toggle full screen mode
  28642. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28643. */
  28644. switchFullscreen(requestPointerLock: boolean): void;
  28645. /**
  28646. * Enters full screen mode
  28647. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28648. */
  28649. enterFullscreen(requestPointerLock: boolean): void;
  28650. /**
  28651. * Exits full screen mode
  28652. */
  28653. exitFullscreen(): void;
  28654. /**
  28655. * Clear the current render buffer or the current render target (if any is set up)
  28656. * @param color defines the color to use
  28657. * @param backBuffer defines if the back buffer must be cleared
  28658. * @param depth defines if the depth buffer must be cleared
  28659. * @param stencil defines if the stencil buffer must be cleared
  28660. */
  28661. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28662. /**
  28663. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28664. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28665. * @param y defines the y-coordinate of the corner of the clear rectangle
  28666. * @param width defines the width of the clear rectangle
  28667. * @param height defines the height of the clear rectangle
  28668. * @param clearColor defines the clear color
  28669. */
  28670. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28671. /**
  28672. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28673. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28674. * @param y defines the y-coordinate of the corner of the clear rectangle
  28675. * @param width defines the width of the clear rectangle
  28676. * @param height defines the height of the clear rectangle
  28677. */
  28678. enableScissor(x: number, y: number, width: number, height: number): void;
  28679. /**
  28680. * Disable previously set scissor test rectangle
  28681. */
  28682. disableScissor(): void;
  28683. private _viewportCached;
  28684. /** @hidden */
  28685. _viewport(x: number, y: number, width: number, height: number): void;
  28686. /**
  28687. * Set the WebGL's viewport
  28688. * @param viewport defines the viewport element to be used
  28689. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28690. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28691. */
  28692. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28693. /**
  28694. * Directly set the WebGL Viewport
  28695. * @param x defines the x coordinate of the viewport (in screen space)
  28696. * @param y defines the y coordinate of the viewport (in screen space)
  28697. * @param width defines the width of the viewport (in screen space)
  28698. * @param height defines the height of the viewport (in screen space)
  28699. * @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
  28700. */
  28701. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28702. /**
  28703. * Begin a new frame
  28704. */
  28705. beginFrame(): void;
  28706. /**
  28707. * Enf the current frame
  28708. */
  28709. endFrame(): void;
  28710. /**
  28711. * Resize the view according to the canvas' size
  28712. */
  28713. resize(): void;
  28714. /**
  28715. * Force a specific size of the canvas
  28716. * @param width defines the new canvas' width
  28717. * @param height defines the new canvas' height
  28718. */
  28719. setSize(width: number, height: number): void;
  28720. /**
  28721. * Gets a boolean indicating if a webVR device was detected
  28722. * @returns true if a webVR device was detected
  28723. */
  28724. isVRDevicePresent(): boolean;
  28725. /**
  28726. * Gets the current webVR device
  28727. * @returns the current webVR device (or null)
  28728. */
  28729. getVRDevice(): any;
  28730. /**
  28731. * Initializes a webVR display and starts listening to display change events
  28732. * The onVRDisplayChangedObservable will be notified upon these changes
  28733. * @returns The onVRDisplayChangedObservable
  28734. */
  28735. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28736. /**
  28737. * Initializes a webVR display and starts listening to display change events
  28738. * The onVRDisplayChangedObservable will be notified upon these changes
  28739. * @returns A promise containing a VRDisplay and if vr is supported
  28740. */
  28741. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28742. /**
  28743. * Call this function to switch to webVR mode
  28744. * Will do nothing if webVR is not supported or if there is no webVR device
  28745. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28746. */
  28747. enableVR(): void;
  28748. /**
  28749. * Call this function to leave webVR mode
  28750. * Will do nothing if webVR is not supported or if there is no webVR device
  28751. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28752. */
  28753. disableVR(): void;
  28754. private _onVRFullScreenTriggered;
  28755. private _getVRDisplaysAsync;
  28756. /**
  28757. * Binds the frame buffer to the specified texture.
  28758. * @param texture The texture to render to or null for the default canvas
  28759. * @param faceIndex The face of the texture to render to in case of cube texture
  28760. * @param requiredWidth The width of the target to render to
  28761. * @param requiredHeight The height of the target to render to
  28762. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28763. * @param depthStencilTexture The depth stencil texture to use to render
  28764. * @param lodLevel defines le lod level to bind to the frame buffer
  28765. */
  28766. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28767. /** @hidden */
  28768. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28769. /**
  28770. * Unbind the current render target texture from the webGL context
  28771. * @param texture defines the render target texture to unbind
  28772. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28773. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28774. */
  28775. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28776. /**
  28777. * Force the mipmap generation for the given render target texture
  28778. * @param texture defines the render target texture to use
  28779. */
  28780. generateMipMapsForCubemap(texture: InternalTexture): void;
  28781. /**
  28782. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28783. */
  28784. flushFramebuffer(): void;
  28785. /**
  28786. * Unbind the current render target and bind the default framebuffer
  28787. */
  28788. restoreDefaultFramebuffer(): void;
  28789. /**
  28790. * Create an uniform buffer
  28791. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28792. * @param elements defines the content of the uniform buffer
  28793. * @returns the webGL uniform buffer
  28794. */
  28795. createUniformBuffer(elements: FloatArray): DataBuffer;
  28796. /**
  28797. * Create a dynamic uniform buffer
  28798. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28799. * @param elements defines the content of the uniform buffer
  28800. * @returns the webGL uniform buffer
  28801. */
  28802. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28803. /**
  28804. * Update an existing uniform buffer
  28805. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28806. * @param uniformBuffer defines the target uniform buffer
  28807. * @param elements defines the content to update
  28808. * @param offset defines the offset in the uniform buffer where update should start
  28809. * @param count defines the size of the data to update
  28810. */
  28811. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28812. private _resetVertexBufferBinding;
  28813. /**
  28814. * Creates a vertex buffer
  28815. * @param data the data for the vertex buffer
  28816. * @returns the new WebGL static buffer
  28817. */
  28818. createVertexBuffer(data: DataArray): DataBuffer;
  28819. /**
  28820. * Creates a dynamic vertex buffer
  28821. * @param data the data for the dynamic vertex buffer
  28822. * @returns the new WebGL dynamic buffer
  28823. */
  28824. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28825. /**
  28826. * Update a dynamic index buffer
  28827. * @param indexBuffer defines the target index buffer
  28828. * @param indices defines the data to update
  28829. * @param offset defines the offset in the target index buffer where update should start
  28830. */
  28831. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28832. /**
  28833. * Updates a dynamic vertex buffer.
  28834. * @param vertexBuffer the vertex buffer to update
  28835. * @param data the data used to update the vertex buffer
  28836. * @param byteOffset the byte offset of the data
  28837. * @param byteLength the byte length of the data
  28838. */
  28839. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28840. private _resetIndexBufferBinding;
  28841. /**
  28842. * Creates a new index buffer
  28843. * @param indices defines the content of the index buffer
  28844. * @param updatable defines if the index buffer must be updatable
  28845. * @returns a new webGL buffer
  28846. */
  28847. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28848. /**
  28849. * Bind a webGL buffer to the webGL context
  28850. * @param buffer defines the buffer to bind
  28851. */
  28852. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28853. /**
  28854. * Bind an uniform buffer to the current webGL context
  28855. * @param buffer defines the buffer to bind
  28856. */
  28857. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28858. /**
  28859. * Bind a buffer to the current webGL context at a given location
  28860. * @param buffer defines the buffer to bind
  28861. * @param location defines the index where to bind the buffer
  28862. */
  28863. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28864. /**
  28865. * Bind a specific block at a given index in a specific shader program
  28866. * @param pipelineContext defines the pipeline context to use
  28867. * @param blockName defines the block name
  28868. * @param index defines the index where to bind the block
  28869. */
  28870. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28871. private bindIndexBuffer;
  28872. private bindBuffer;
  28873. /**
  28874. * update the bound buffer with the given data
  28875. * @param data defines the data to update
  28876. */
  28877. updateArrayBuffer(data: Float32Array): void;
  28878. private _vertexAttribPointer;
  28879. private _bindIndexBufferWithCache;
  28880. private _bindVertexBuffersAttributes;
  28881. /**
  28882. * Records a vertex array object
  28883. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28884. * @param vertexBuffers defines the list of vertex buffers to store
  28885. * @param indexBuffer defines the index buffer to store
  28886. * @param effect defines the effect to store
  28887. * @returns the new vertex array object
  28888. */
  28889. recordVertexArrayObject(vertexBuffers: {
  28890. [key: string]: VertexBuffer;
  28891. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28892. /**
  28893. * Bind a specific vertex array object
  28894. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28895. * @param vertexArrayObject defines the vertex array object to bind
  28896. * @param indexBuffer defines the index buffer to bind
  28897. */
  28898. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28899. /**
  28900. * Bind webGl buffers directly to the webGL context
  28901. * @param vertexBuffer defines the vertex buffer to bind
  28902. * @param indexBuffer defines the index buffer to bind
  28903. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28904. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28905. * @param effect defines the effect associated with the vertex buffer
  28906. */
  28907. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28908. private _unbindVertexArrayObject;
  28909. /**
  28910. * Bind a list of vertex buffers to the webGL context
  28911. * @param vertexBuffers defines the list of vertex buffers to bind
  28912. * @param indexBuffer defines the index buffer to bind
  28913. * @param effect defines the effect associated with the vertex buffers
  28914. */
  28915. bindBuffers(vertexBuffers: {
  28916. [key: string]: Nullable<VertexBuffer>;
  28917. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28918. /**
  28919. * Unbind all instance attributes
  28920. */
  28921. unbindInstanceAttributes(): void;
  28922. /**
  28923. * Release and free the memory of a vertex array object
  28924. * @param vao defines the vertex array object to delete
  28925. */
  28926. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28927. /** @hidden */
  28928. _releaseBuffer(buffer: DataBuffer): boolean;
  28929. /**
  28930. * Creates a webGL buffer to use with instanciation
  28931. * @param capacity defines the size of the buffer
  28932. * @returns the webGL buffer
  28933. */
  28934. createInstancesBuffer(capacity: number): DataBuffer;
  28935. /**
  28936. * Delete a webGL buffer used with instanciation
  28937. * @param buffer defines the webGL buffer to delete
  28938. */
  28939. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28940. /**
  28941. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28942. * @param instancesBuffer defines the webGL buffer to update and bind
  28943. * @param data defines the data to store in the buffer
  28944. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28945. */
  28946. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28947. /**
  28948. * Apply all cached states (depth, culling, stencil and alpha)
  28949. */
  28950. applyStates(): void;
  28951. /**
  28952. * Send a draw order
  28953. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28954. * @param indexStart defines the starting index
  28955. * @param indexCount defines the number of index to draw
  28956. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28957. */
  28958. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28959. /**
  28960. * Draw a list of points
  28961. * @param verticesStart defines the index of first vertex to draw
  28962. * @param verticesCount defines the count of vertices to draw
  28963. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28964. */
  28965. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28966. /**
  28967. * Draw a list of unindexed primitives
  28968. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28969. * @param verticesStart defines the index of first vertex to draw
  28970. * @param verticesCount defines the count of vertices to draw
  28971. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28972. */
  28973. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28974. /**
  28975. * Draw a list of indexed primitives
  28976. * @param fillMode defines the primitive to use
  28977. * @param indexStart defines the starting index
  28978. * @param indexCount defines the number of index to draw
  28979. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28980. */
  28981. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28982. /**
  28983. * Draw a list of unindexed primitives
  28984. * @param fillMode defines the primitive to use
  28985. * @param verticesStart defines the index of first vertex to draw
  28986. * @param verticesCount defines the count of vertices to draw
  28987. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28988. */
  28989. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28990. private _drawMode;
  28991. /** @hidden */
  28992. _releaseEffect(effect: Effect): void;
  28993. /** @hidden */
  28994. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  28995. /**
  28996. * Create a new effect (used to store vertex/fragment shaders)
  28997. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28998. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28999. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29000. * @param samplers defines an array of string used to represent textures
  29001. * @param defines defines the string containing the defines to use to compile the shaders
  29002. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29003. * @param onCompiled defines a function to call when the effect creation is successful
  29004. * @param onError defines a function to call when the effect creation has failed
  29005. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29006. * @returns the new Effect
  29007. */
  29008. 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;
  29009. private _compileShader;
  29010. private _compileRawShader;
  29011. /**
  29012. * Directly creates a webGL program
  29013. * @param pipelineContext defines the pipeline context to attach to
  29014. * @param vertexCode defines the vertex shader code to use
  29015. * @param fragmentCode defines the fragment shader code to use
  29016. * @param context defines the webGL context to use (if not set, the current one will be used)
  29017. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29018. * @returns the new webGL program
  29019. */
  29020. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29021. /**
  29022. * Creates a webGL program
  29023. * @param pipelineContext defines the pipeline context to attach to
  29024. * @param vertexCode defines the vertex shader code to use
  29025. * @param fragmentCode defines the fragment shader code to use
  29026. * @param defines defines the string containing the defines to use to compile the shaders
  29027. * @param context defines the webGL context to use (if not set, the current one will be used)
  29028. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29029. * @returns the new webGL program
  29030. */
  29031. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29032. /**
  29033. * Creates a new pipeline context
  29034. * @returns the new pipeline
  29035. */
  29036. createPipelineContext(): WebGLPipelineContext;
  29037. private _createShaderProgram;
  29038. private _finalizePipelineContext;
  29039. /** @hidden */
  29040. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29041. /** @hidden */
  29042. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29043. /** @hidden */
  29044. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29045. /**
  29046. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29047. * @param pipelineContext defines the pipeline context to use
  29048. * @param uniformsNames defines the list of uniform names
  29049. * @returns an array of webGL uniform locations
  29050. */
  29051. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29052. /**
  29053. * Gets the lsit of active attributes for a given webGL program
  29054. * @param pipelineContext defines the pipeline context to use
  29055. * @param attributesNames defines the list of attribute names to get
  29056. * @returns an array of indices indicating the offset of each attribute
  29057. */
  29058. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29059. /**
  29060. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29061. * @param effect defines the effect to activate
  29062. */
  29063. enableEffect(effect: Nullable<Effect>): void;
  29064. /**
  29065. * Set the value of an uniform to an array of int32
  29066. * @param uniform defines the webGL uniform location where to store the value
  29067. * @param array defines the array of int32 to store
  29068. */
  29069. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29070. /**
  29071. * Set the value of an uniform to an array of int32 (stored as vec2)
  29072. * @param uniform defines the webGL uniform location where to store the value
  29073. * @param array defines the array of int32 to store
  29074. */
  29075. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29076. /**
  29077. * Set the value of an uniform to an array of int32 (stored as vec3)
  29078. * @param uniform defines the webGL uniform location where to store the value
  29079. * @param array defines the array of int32 to store
  29080. */
  29081. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29082. /**
  29083. * Set the value of an uniform to an array of int32 (stored as vec4)
  29084. * @param uniform defines the webGL uniform location where to store the value
  29085. * @param array defines the array of int32 to store
  29086. */
  29087. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29088. /**
  29089. * Set the value of an uniform to an array of float32
  29090. * @param uniform defines the webGL uniform location where to store the value
  29091. * @param array defines the array of float32 to store
  29092. */
  29093. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29094. /**
  29095. * Set the value of an uniform to an array of float32 (stored as vec2)
  29096. * @param uniform defines the webGL uniform location where to store the value
  29097. * @param array defines the array of float32 to store
  29098. */
  29099. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29100. /**
  29101. * Set the value of an uniform to an array of float32 (stored as vec3)
  29102. * @param uniform defines the webGL uniform location where to store the value
  29103. * @param array defines the array of float32 to store
  29104. */
  29105. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29106. /**
  29107. * Set the value of an uniform to an array of float32 (stored as vec4)
  29108. * @param uniform defines the webGL uniform location where to store the value
  29109. * @param array defines the array of float32 to store
  29110. */
  29111. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29112. /**
  29113. * Set the value of an uniform to an array of number
  29114. * @param uniform defines the webGL uniform location where to store the value
  29115. * @param array defines the array of number to store
  29116. */
  29117. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29118. /**
  29119. * Set the value of an uniform to an array of number (stored as vec2)
  29120. * @param uniform defines the webGL uniform location where to store the value
  29121. * @param array defines the array of number to store
  29122. */
  29123. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29124. /**
  29125. * Set the value of an uniform to an array of number (stored as vec3)
  29126. * @param uniform defines the webGL uniform location where to store the value
  29127. * @param array defines the array of number to store
  29128. */
  29129. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29130. /**
  29131. * Set the value of an uniform to an array of number (stored as vec4)
  29132. * @param uniform defines the webGL uniform location where to store the value
  29133. * @param array defines the array of number to store
  29134. */
  29135. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29136. /**
  29137. * Set the value of an uniform to an array of float32 (stored as matrices)
  29138. * @param uniform defines the webGL uniform location where to store the value
  29139. * @param matrices defines the array of float32 to store
  29140. */
  29141. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29142. /**
  29143. * Set the value of an uniform to a matrix
  29144. * @param uniform defines the webGL uniform location where to store the value
  29145. * @param matrix defines the matrix to store
  29146. */
  29147. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29148. /**
  29149. * Set the value of an uniform to a matrix (3x3)
  29150. * @param uniform defines the webGL uniform location where to store the value
  29151. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29152. */
  29153. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29154. /**
  29155. * Set the value of an uniform to a matrix (2x2)
  29156. * @param uniform defines the webGL uniform location where to store the value
  29157. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29158. */
  29159. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29160. /**
  29161. * Set the value of an uniform to a number (int)
  29162. * @param uniform defines the webGL uniform location where to store the value
  29163. * @param value defines the int number to store
  29164. */
  29165. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29166. /**
  29167. * Set the value of an uniform to a number (float)
  29168. * @param uniform defines the webGL uniform location where to store the value
  29169. * @param value defines the float number to store
  29170. */
  29171. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29172. /**
  29173. * Set the value of an uniform to a vec2
  29174. * @param uniform defines the webGL uniform location where to store the value
  29175. * @param x defines the 1st component of the value
  29176. * @param y defines the 2nd component of the value
  29177. */
  29178. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29179. /**
  29180. * Set the value of an uniform to a vec3
  29181. * @param uniform defines the webGL uniform location where to store the value
  29182. * @param x defines the 1st component of the value
  29183. * @param y defines the 2nd component of the value
  29184. * @param z defines the 3rd component of the value
  29185. */
  29186. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29187. /**
  29188. * Set the value of an uniform to a boolean
  29189. * @param uniform defines the webGL uniform location where to store the value
  29190. * @param bool defines the boolean to store
  29191. */
  29192. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29193. /**
  29194. * Set the value of an uniform to a vec4
  29195. * @param uniform defines the webGL uniform location where to store the value
  29196. * @param x defines the 1st component of the value
  29197. * @param y defines the 2nd component of the value
  29198. * @param z defines the 3rd component of the value
  29199. * @param w defines the 4th component of the value
  29200. */
  29201. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29202. /**
  29203. * Set the value of an uniform to a Color3
  29204. * @param uniform defines the webGL uniform location where to store the value
  29205. * @param color3 defines the color to store
  29206. */
  29207. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29208. /**
  29209. * Set the value of an uniform to a Color3 and an alpha value
  29210. * @param uniform defines the webGL uniform location where to store the value
  29211. * @param color3 defines the color to store
  29212. * @param alpha defines the alpha component to store
  29213. */
  29214. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29215. /**
  29216. * Sets a Color4 on a uniform variable
  29217. * @param uniform defines the uniform location
  29218. * @param color4 defines the value to be set
  29219. */
  29220. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29221. /**
  29222. * Set various states to the webGL context
  29223. * @param culling defines backface culling state
  29224. * @param zOffset defines the value to apply to zOffset (0 by default)
  29225. * @param force defines if states must be applied even if cache is up to date
  29226. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29227. */
  29228. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29229. /**
  29230. * Set the z offset to apply to current rendering
  29231. * @param value defines the offset to apply
  29232. */
  29233. setZOffset(value: number): void;
  29234. /**
  29235. * Gets the current value of the zOffset
  29236. * @returns the current zOffset state
  29237. */
  29238. getZOffset(): number;
  29239. /**
  29240. * Enable or disable depth buffering
  29241. * @param enable defines the state to set
  29242. */
  29243. setDepthBuffer(enable: boolean): void;
  29244. /**
  29245. * Gets a boolean indicating if depth writing is enabled
  29246. * @returns the current depth writing state
  29247. */
  29248. getDepthWrite(): boolean;
  29249. /**
  29250. * Enable or disable depth writing
  29251. * @param enable defines the state to set
  29252. */
  29253. setDepthWrite(enable: boolean): void;
  29254. /**
  29255. * Enable or disable color writing
  29256. * @param enable defines the state to set
  29257. */
  29258. setColorWrite(enable: boolean): void;
  29259. /**
  29260. * Gets a boolean indicating if color writing is enabled
  29261. * @returns the current color writing state
  29262. */
  29263. getColorWrite(): boolean;
  29264. /**
  29265. * Sets alpha constants used by some alpha blending modes
  29266. * @param r defines the red component
  29267. * @param g defines the green component
  29268. * @param b defines the blue component
  29269. * @param a defines the alpha component
  29270. */
  29271. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29272. /**
  29273. * Sets the current alpha mode
  29274. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29275. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29276. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29277. */
  29278. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29279. /**
  29280. * Gets the current alpha mode
  29281. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29282. * @returns the current alpha mode
  29283. */
  29284. getAlphaMode(): number;
  29285. /**
  29286. * Clears the list of texture accessible through engine.
  29287. * This can help preventing texture load conflict due to name collision.
  29288. */
  29289. clearInternalTexturesCache(): void;
  29290. /**
  29291. * Force the entire cache to be cleared
  29292. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29293. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29294. */
  29295. wipeCaches(bruteForce?: boolean): void;
  29296. /**
  29297. * Set the compressed texture format to use, based on the formats you have, and the formats
  29298. * supported by the hardware / browser.
  29299. *
  29300. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29301. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29302. * to API arguments needed to compressed textures. This puts the burden on the container
  29303. * generator to house the arcane code for determining these for current & future formats.
  29304. *
  29305. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29306. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29307. *
  29308. * Note: The result of this call is not taken into account when a texture is base64.
  29309. *
  29310. * @param formatsAvailable defines the list of those format families you have created
  29311. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29312. *
  29313. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29314. * @returns The extension selected.
  29315. */
  29316. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29317. /** @hidden */
  29318. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29319. min: number;
  29320. mag: number;
  29321. };
  29322. /** @hidden */
  29323. _createTexture(): WebGLTexture;
  29324. /**
  29325. * Usually called from Texture.ts.
  29326. * Passed information to create a WebGLTexture
  29327. * @param urlArg defines a value which contains one of the following:
  29328. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29329. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29330. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29331. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29332. * @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)
  29333. * @param scene needed for loading to the correct scene
  29334. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29335. * @param onLoad optional callback to be called upon successful completion
  29336. * @param onError optional callback to be called upon failure
  29337. * @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
  29338. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29339. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29340. * @param forcedExtension defines the extension to use to pick the right loader
  29341. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29342. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29343. */
  29344. 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;
  29345. private _rescaleTexture;
  29346. private _unpackFlipYCached;
  29347. /**
  29348. * In case you are sharing the context with other applications, it might
  29349. * be interested to not cache the unpack flip y state to ensure a consistent
  29350. * value would be set.
  29351. */
  29352. enableUnpackFlipYCached: boolean;
  29353. /** @hidden */
  29354. _unpackFlipY(value: boolean): void;
  29355. /** @hidden */
  29356. _getUnpackAlignement(): number;
  29357. /**
  29358. * Creates a dynamic texture
  29359. * @param width defines the width of the texture
  29360. * @param height defines the height of the texture
  29361. * @param generateMipMaps defines if the engine should generate the mip levels
  29362. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29363. * @returns the dynamic texture inside an InternalTexture
  29364. */
  29365. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29366. /**
  29367. * Update the sampling mode of a given texture
  29368. * @param samplingMode defines the required sampling mode
  29369. * @param texture defines the texture to update
  29370. */
  29371. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29372. /**
  29373. * Update the content of a dynamic texture
  29374. * @param texture defines the texture to update
  29375. * @param canvas defines the canvas containing the source
  29376. * @param invertY defines if data must be stored with Y axis inverted
  29377. * @param premulAlpha defines if alpha is stored as premultiplied
  29378. * @param format defines the format of the data
  29379. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29380. */
  29381. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29382. /**
  29383. * Update a video texture
  29384. * @param texture defines the texture to update
  29385. * @param video defines the video element to use
  29386. * @param invertY defines if data must be stored with Y axis inverted
  29387. */
  29388. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29389. /**
  29390. * Updates a depth texture Comparison Mode and Function.
  29391. * If the comparison Function is equal to 0, the mode will be set to none.
  29392. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29393. * @param texture The texture to set the comparison function for
  29394. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29395. */
  29396. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29397. /** @hidden */
  29398. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29399. width: number;
  29400. height: number;
  29401. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29402. /**
  29403. * Creates a depth stencil texture.
  29404. * This is only available in WebGL 2 or with the depth texture extension available.
  29405. * @param size The size of face edge in the texture.
  29406. * @param options The options defining the texture.
  29407. * @returns The texture
  29408. */
  29409. createDepthStencilTexture(size: number | {
  29410. width: number;
  29411. height: number;
  29412. }, options: DepthTextureCreationOptions): InternalTexture;
  29413. /**
  29414. * Creates a depth stencil texture.
  29415. * This is only available in WebGL 2 or with the depth texture extension available.
  29416. * @param size The size of face edge in the texture.
  29417. * @param options The options defining the texture.
  29418. * @returns The texture
  29419. */
  29420. private _createDepthStencilTexture;
  29421. /**
  29422. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29423. * @param renderTarget The render target to set the frame buffer for
  29424. */
  29425. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29426. /**
  29427. * Creates a new render target texture
  29428. * @param size defines the size of the texture
  29429. * @param options defines the options used to create the texture
  29430. * @returns a new render target texture stored in an InternalTexture
  29431. */
  29432. createRenderTargetTexture(size: number | {
  29433. width: number;
  29434. height: number;
  29435. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29436. /** @hidden */
  29437. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29438. /**
  29439. * Updates the sample count of a render target texture
  29440. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29441. * @param texture defines the texture to update
  29442. * @param samples defines the sample count to set
  29443. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29444. */
  29445. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29446. /** @hidden */
  29447. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29448. /** @hidden */
  29449. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29450. /** @hidden */
  29451. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29452. /** @hidden */
  29453. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29454. /**
  29455. * @hidden
  29456. */
  29457. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29458. private _prepareWebGLTextureContinuation;
  29459. private _prepareWebGLTexture;
  29460. /** @hidden */
  29461. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29462. /** @hidden */
  29463. _releaseFramebufferObjects(texture: InternalTexture): void;
  29464. /** @hidden */
  29465. _releaseTexture(texture: InternalTexture): void;
  29466. private setProgram;
  29467. private _boundUniforms;
  29468. /**
  29469. * Binds an effect to the webGL context
  29470. * @param effect defines the effect to bind
  29471. */
  29472. bindSamplers(effect: Effect): void;
  29473. private _activateCurrentTexture;
  29474. /** @hidden */
  29475. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29476. /** @hidden */
  29477. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29478. /**
  29479. * Sets a texture to the webGL context from a postprocess
  29480. * @param channel defines the channel to use
  29481. * @param postProcess defines the source postprocess
  29482. */
  29483. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29484. /**
  29485. * Binds the output of the passed in post process to the texture channel specified
  29486. * @param channel The channel the texture should be bound to
  29487. * @param postProcess The post process which's output should be bound
  29488. */
  29489. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29490. /**
  29491. * Unbind all textures from the webGL context
  29492. */
  29493. unbindAllTextures(): void;
  29494. /**
  29495. * Sets a texture to the according uniform.
  29496. * @param channel The texture channel
  29497. * @param uniform The uniform to set
  29498. * @param texture The texture to apply
  29499. */
  29500. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29501. /**
  29502. * Sets a depth stencil texture from a render target to the according uniform.
  29503. * @param channel The texture channel
  29504. * @param uniform The uniform to set
  29505. * @param texture The render target texture containing the depth stencil texture to apply
  29506. */
  29507. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29508. private _bindSamplerUniformToChannel;
  29509. private _getTextureWrapMode;
  29510. private _setTexture;
  29511. /**
  29512. * Sets an array of texture to the webGL context
  29513. * @param channel defines the channel where the texture array must be set
  29514. * @param uniform defines the associated uniform location
  29515. * @param textures defines the array of textures to bind
  29516. */
  29517. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29518. /** @hidden */
  29519. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29520. private _setTextureParameterFloat;
  29521. private _setTextureParameterInteger;
  29522. /**
  29523. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29524. * @param x defines the x coordinate of the rectangle where pixels must be read
  29525. * @param y defines the y coordinate of the rectangle where pixels must be read
  29526. * @param width defines the width of the rectangle where pixels must be read
  29527. * @param height defines the height of the rectangle where pixels must be read
  29528. * @returns a Uint8Array containing RGBA colors
  29529. */
  29530. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29531. /**
  29532. * Add an externaly attached data from its key.
  29533. * This method call will fail and return false, if such key already exists.
  29534. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29535. * @param key the unique key that identifies the data
  29536. * @param data the data object to associate to the key for this Engine instance
  29537. * @return true if no such key were already present and the data was added successfully, false otherwise
  29538. */
  29539. addExternalData<T>(key: string, data: T): boolean;
  29540. /**
  29541. * Get an externaly attached data from its key
  29542. * @param key the unique key that identifies the data
  29543. * @return the associated data, if present (can be null), or undefined if not present
  29544. */
  29545. getExternalData<T>(key: string): T;
  29546. /**
  29547. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29548. * @param key the unique key that identifies the data
  29549. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29550. * @return the associated data, can be null if the factory returned null.
  29551. */
  29552. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29553. /**
  29554. * Remove an externaly attached data from the Engine instance
  29555. * @param key the unique key that identifies the data
  29556. * @return true if the data was successfully removed, false if it doesn't exist
  29557. */
  29558. removeExternalData(key: string): boolean;
  29559. /**
  29560. * Unbind all vertex attributes from the webGL context
  29561. */
  29562. unbindAllAttributes(): void;
  29563. /**
  29564. * 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
  29565. */
  29566. releaseEffects(): void;
  29567. /**
  29568. * Dispose and release all associated resources
  29569. */
  29570. dispose(): void;
  29571. /**
  29572. * Display the loading screen
  29573. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29574. */
  29575. displayLoadingUI(): void;
  29576. /**
  29577. * Hide the loading screen
  29578. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29579. */
  29580. hideLoadingUI(): void;
  29581. /**
  29582. * Gets the current loading screen object
  29583. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29584. */
  29585. /**
  29586. * Sets the current loading screen object
  29587. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29588. */
  29589. loadingScreen: ILoadingScreen;
  29590. /**
  29591. * Sets the current loading screen text
  29592. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29593. */
  29594. loadingUIText: string;
  29595. /**
  29596. * Sets the current loading screen background color
  29597. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29598. */
  29599. loadingUIBackgroundColor: string;
  29600. /**
  29601. * Attach a new callback raised when context lost event is fired
  29602. * @param callback defines the callback to call
  29603. */
  29604. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29605. /**
  29606. * Attach a new callback raised when context restored event is fired
  29607. * @param callback defines the callback to call
  29608. */
  29609. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29610. /**
  29611. * Gets the source code of the vertex shader associated with a specific webGL program
  29612. * @param program defines the program to use
  29613. * @returns a string containing the source code of the vertex shader associated with the program
  29614. */
  29615. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29616. /**
  29617. * Gets the source code of the fragment shader associated with a specific webGL program
  29618. * @param program defines the program to use
  29619. * @returns a string containing the source code of the fragment shader associated with the program
  29620. */
  29621. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29622. /**
  29623. * Get the current error code of the webGL context
  29624. * @returns the error code
  29625. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29626. */
  29627. getError(): number;
  29628. /**
  29629. * Gets the current framerate
  29630. * @returns a number representing the framerate
  29631. */
  29632. getFps(): number;
  29633. /**
  29634. * Gets the time spent between current and previous frame
  29635. * @returns a number representing the delta time in ms
  29636. */
  29637. getDeltaTime(): number;
  29638. private _measureFps;
  29639. /** @hidden */
  29640. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29641. private _canRenderToFloatFramebuffer;
  29642. private _canRenderToHalfFloatFramebuffer;
  29643. private _canRenderToFramebuffer;
  29644. /** @hidden */
  29645. _getWebGLTextureType(type: number): number;
  29646. /** @hidden */
  29647. _getInternalFormat(format: number): number;
  29648. /** @hidden */
  29649. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29650. /** @hidden */
  29651. _getRGBAMultiSampleBufferFormat(type: number): number;
  29652. /** @hidden */
  29653. _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;
  29654. /** @hidden */
  29655. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29656. /**
  29657. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29658. * @returns true if the engine can be created
  29659. * @ignorenaming
  29660. */
  29661. static isSupported(): boolean;
  29662. }
  29663. }
  29664. declare module "babylonjs/Materials/effect" {
  29665. import { Observable } from "babylonjs/Misc/observable";
  29666. import { Nullable } from "babylonjs/types";
  29667. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29668. import { IDisposable } from "babylonjs/scene";
  29669. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29670. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29671. import { Engine } from "babylonjs/Engines/engine";
  29672. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29673. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29674. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29675. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29677. /**
  29678. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29679. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29680. */
  29681. export class EffectFallbacks {
  29682. private _defines;
  29683. private _currentRank;
  29684. private _maxRank;
  29685. private _mesh;
  29686. /**
  29687. * Removes the fallback from the bound mesh.
  29688. */
  29689. unBindMesh(): void;
  29690. /**
  29691. * Adds a fallback on the specified property.
  29692. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29693. * @param define The name of the define in the shader
  29694. */
  29695. addFallback(rank: number, define: string): void;
  29696. /**
  29697. * Sets the mesh to use CPU skinning when needing to fallback.
  29698. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29699. * @param mesh The mesh to use the fallbacks.
  29700. */
  29701. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29702. /**
  29703. * Checks to see if more fallbacks are still availible.
  29704. */
  29705. readonly isMoreFallbacks: boolean;
  29706. /**
  29707. * Removes the defines that shoould be removed when falling back.
  29708. * @param currentDefines defines the current define statements for the shader.
  29709. * @param effect defines the current effect we try to compile
  29710. * @returns The resulting defines with defines of the current rank removed.
  29711. */
  29712. reduce(currentDefines: string, effect: Effect): string;
  29713. }
  29714. /**
  29715. * Options to be used when creating an effect.
  29716. */
  29717. export class EffectCreationOptions {
  29718. /**
  29719. * Atrributes that will be used in the shader.
  29720. */
  29721. attributes: string[];
  29722. /**
  29723. * Uniform varible names that will be set in the shader.
  29724. */
  29725. uniformsNames: string[];
  29726. /**
  29727. * Uniform buffer varible names that will be set in the shader.
  29728. */
  29729. uniformBuffersNames: string[];
  29730. /**
  29731. * Sampler texture variable names that will be set in the shader.
  29732. */
  29733. samplers: string[];
  29734. /**
  29735. * Define statements that will be set in the shader.
  29736. */
  29737. defines: any;
  29738. /**
  29739. * Possible fallbacks for this effect to improve performance when needed.
  29740. */
  29741. fallbacks: Nullable<EffectFallbacks>;
  29742. /**
  29743. * Callback that will be called when the shader is compiled.
  29744. */
  29745. onCompiled: Nullable<(effect: Effect) => void>;
  29746. /**
  29747. * Callback that will be called if an error occurs during shader compilation.
  29748. */
  29749. onError: Nullable<(effect: Effect, errors: string) => void>;
  29750. /**
  29751. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29752. */
  29753. indexParameters: any;
  29754. /**
  29755. * Max number of lights that can be used in the shader.
  29756. */
  29757. maxSimultaneousLights: number;
  29758. /**
  29759. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29760. */
  29761. transformFeedbackVaryings: Nullable<string[]>;
  29762. }
  29763. /**
  29764. * Effect containing vertex and fragment shader that can be executed on an object.
  29765. */
  29766. export class Effect implements IDisposable {
  29767. /**
  29768. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29769. */
  29770. static ShadersRepository: string;
  29771. /**
  29772. * Name of the effect.
  29773. */
  29774. name: any;
  29775. /**
  29776. * String container all the define statements that should be set on the shader.
  29777. */
  29778. defines: string;
  29779. /**
  29780. * Callback that will be called when the shader is compiled.
  29781. */
  29782. onCompiled: Nullable<(effect: Effect) => void>;
  29783. /**
  29784. * Callback that will be called if an error occurs during shader compilation.
  29785. */
  29786. onError: Nullable<(effect: Effect, errors: string) => void>;
  29787. /**
  29788. * Callback that will be called when effect is bound.
  29789. */
  29790. onBind: Nullable<(effect: Effect) => void>;
  29791. /**
  29792. * Unique ID of the effect.
  29793. */
  29794. uniqueId: number;
  29795. /**
  29796. * Observable that will be called when the shader is compiled.
  29797. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29798. */
  29799. onCompileObservable: Observable<Effect>;
  29800. /**
  29801. * Observable that will be called if an error occurs during shader compilation.
  29802. */
  29803. onErrorObservable: Observable<Effect>;
  29804. /** @hidden */
  29805. _onBindObservable: Nullable<Observable<Effect>>;
  29806. /**
  29807. * Observable that will be called when effect is bound.
  29808. */
  29809. readonly onBindObservable: Observable<Effect>;
  29810. /** @hidden */
  29811. _bonesComputationForcedToCPU: boolean;
  29812. private static _uniqueIdSeed;
  29813. private _engine;
  29814. private _uniformBuffersNames;
  29815. private _uniformsNames;
  29816. private _samplerList;
  29817. private _samplers;
  29818. private _isReady;
  29819. private _compilationError;
  29820. private _attributesNames;
  29821. private _attributes;
  29822. private _uniforms;
  29823. /**
  29824. * Key for the effect.
  29825. * @hidden
  29826. */
  29827. _key: string;
  29828. private _indexParameters;
  29829. private _fallbacks;
  29830. private _vertexSourceCode;
  29831. private _fragmentSourceCode;
  29832. private _vertexSourceCodeOverride;
  29833. private _fragmentSourceCodeOverride;
  29834. private _transformFeedbackVaryings;
  29835. /**
  29836. * Compiled shader to webGL program.
  29837. * @hidden
  29838. */
  29839. _pipelineContext: IPipelineContext;
  29840. private _valueCache;
  29841. private static _baseCache;
  29842. /**
  29843. * Instantiates an effect.
  29844. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29845. * @param baseName Name of the effect.
  29846. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29847. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29848. * @param samplers List of sampler variables that will be passed to the shader.
  29849. * @param engine Engine to be used to render the effect
  29850. * @param defines Define statements to be added to the shader.
  29851. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29852. * @param onCompiled Callback that will be called when the shader is compiled.
  29853. * @param onError Callback that will be called if an error occurs during shader compilation.
  29854. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29855. */
  29856. 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);
  29857. /**
  29858. * Unique key for this effect
  29859. */
  29860. readonly key: string;
  29861. /**
  29862. * If the effect has been compiled and prepared.
  29863. * @returns if the effect is compiled and prepared.
  29864. */
  29865. isReady(): boolean;
  29866. /**
  29867. * The engine the effect was initialized with.
  29868. * @returns the engine.
  29869. */
  29870. getEngine(): Engine;
  29871. /**
  29872. * The pipeline context for this effect
  29873. * @returns the associated pipeline context
  29874. */
  29875. getPipelineContext(): IPipelineContext;
  29876. /**
  29877. * The set of names of attribute variables for the shader.
  29878. * @returns An array of attribute names.
  29879. */
  29880. getAttributesNames(): string[];
  29881. /**
  29882. * Returns the attribute at the given index.
  29883. * @param index The index of the attribute.
  29884. * @returns The location of the attribute.
  29885. */
  29886. getAttributeLocation(index: number): number;
  29887. /**
  29888. * Returns the attribute based on the name of the variable.
  29889. * @param name of the attribute to look up.
  29890. * @returns the attribute location.
  29891. */
  29892. getAttributeLocationByName(name: string): number;
  29893. /**
  29894. * The number of attributes.
  29895. * @returns the numnber of attributes.
  29896. */
  29897. getAttributesCount(): number;
  29898. /**
  29899. * Gets the index of a uniform variable.
  29900. * @param uniformName of the uniform to look up.
  29901. * @returns the index.
  29902. */
  29903. getUniformIndex(uniformName: string): number;
  29904. /**
  29905. * Returns the attribute based on the name of the variable.
  29906. * @param uniformName of the uniform to look up.
  29907. * @returns the location of the uniform.
  29908. */
  29909. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29910. /**
  29911. * Returns an array of sampler variable names
  29912. * @returns The array of sampler variable neames.
  29913. */
  29914. getSamplers(): string[];
  29915. /**
  29916. * The error from the last compilation.
  29917. * @returns the error string.
  29918. */
  29919. getCompilationError(): string;
  29920. /**
  29921. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29922. * @param func The callback to be used.
  29923. */
  29924. executeWhenCompiled(func: (effect: Effect) => void): void;
  29925. private _checkIsReady;
  29926. /** @hidden */
  29927. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29928. /** @hidden */
  29929. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29930. /** @hidden */
  29931. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29932. private _processShaderConversion;
  29933. private _processIncludes;
  29934. private _processPrecision;
  29935. /**
  29936. * Recompiles the webGL program
  29937. * @param vertexSourceCode The source code for the vertex shader.
  29938. * @param fragmentSourceCode The source code for the fragment shader.
  29939. * @param onCompiled Callback called when completed.
  29940. * @param onError Callback called on error.
  29941. * @hidden
  29942. */
  29943. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29944. /**
  29945. * Prepares the effect
  29946. * @hidden
  29947. */
  29948. _prepareEffect(): void;
  29949. /**
  29950. * Checks if the effect is supported. (Must be called after compilation)
  29951. */
  29952. readonly isSupported: boolean;
  29953. /**
  29954. * Binds a texture to the engine to be used as output of the shader.
  29955. * @param channel Name of the output variable.
  29956. * @param texture Texture to bind.
  29957. * @hidden
  29958. */
  29959. _bindTexture(channel: string, texture: InternalTexture): void;
  29960. /**
  29961. * Sets a texture on the engine to be used in the shader.
  29962. * @param channel Name of the sampler variable.
  29963. * @param texture Texture to set.
  29964. */
  29965. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29966. /**
  29967. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29968. * @param channel Name of the sampler variable.
  29969. * @param texture Texture to set.
  29970. */
  29971. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29972. /**
  29973. * Sets an array of textures on the engine to be used in the shader.
  29974. * @param channel Name of the variable.
  29975. * @param textures Textures to set.
  29976. */
  29977. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29978. /**
  29979. * 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)
  29980. * @param channel Name of the sampler variable.
  29981. * @param postProcess Post process to get the input texture from.
  29982. */
  29983. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29984. /**
  29985. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29986. * 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)
  29987. * @param channel Name of the sampler variable.
  29988. * @param postProcess Post process to get the output texture from.
  29989. */
  29990. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29991. /** @hidden */
  29992. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29993. /** @hidden */
  29994. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29995. /** @hidden */
  29996. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29997. /** @hidden */
  29998. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29999. /**
  30000. * Binds a buffer to a uniform.
  30001. * @param buffer Buffer to bind.
  30002. * @param name Name of the uniform variable to bind to.
  30003. */
  30004. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30005. /**
  30006. * Binds block to a uniform.
  30007. * @param blockName Name of the block to bind.
  30008. * @param index Index to bind.
  30009. */
  30010. bindUniformBlock(blockName: string, index: number): void;
  30011. /**
  30012. * Sets an interger value on a uniform variable.
  30013. * @param uniformName Name of the variable.
  30014. * @param value Value to be set.
  30015. * @returns this effect.
  30016. */
  30017. setInt(uniformName: string, value: number): Effect;
  30018. /**
  30019. * Sets an int array on a uniform variable.
  30020. * @param uniformName Name of the variable.
  30021. * @param array array to be set.
  30022. * @returns this effect.
  30023. */
  30024. setIntArray(uniformName: string, array: Int32Array): Effect;
  30025. /**
  30026. * 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)
  30027. * @param uniformName Name of the variable.
  30028. * @param array array to be set.
  30029. * @returns this effect.
  30030. */
  30031. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30032. /**
  30033. * 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)
  30034. * @param uniformName Name of the variable.
  30035. * @param array array to be set.
  30036. * @returns this effect.
  30037. */
  30038. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30039. /**
  30040. * 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)
  30041. * @param uniformName Name of the variable.
  30042. * @param array array to be set.
  30043. * @returns this effect.
  30044. */
  30045. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30046. /**
  30047. * Sets an float array on a uniform variable.
  30048. * @param uniformName Name of the variable.
  30049. * @param array array to be set.
  30050. * @returns this effect.
  30051. */
  30052. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30053. /**
  30054. * 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)
  30055. * @param uniformName Name of the variable.
  30056. * @param array array to be set.
  30057. * @returns this effect.
  30058. */
  30059. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30060. /**
  30061. * 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)
  30062. * @param uniformName Name of the variable.
  30063. * @param array array to be set.
  30064. * @returns this effect.
  30065. */
  30066. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30067. /**
  30068. * 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)
  30069. * @param uniformName Name of the variable.
  30070. * @param array array to be set.
  30071. * @returns this effect.
  30072. */
  30073. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30074. /**
  30075. * Sets an array on a uniform variable.
  30076. * @param uniformName Name of the variable.
  30077. * @param array array to be set.
  30078. * @returns this effect.
  30079. */
  30080. setArray(uniformName: string, array: number[]): Effect;
  30081. /**
  30082. * 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)
  30083. * @param uniformName Name of the variable.
  30084. * @param array array to be set.
  30085. * @returns this effect.
  30086. */
  30087. setArray2(uniformName: string, array: number[]): Effect;
  30088. /**
  30089. * 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)
  30090. * @param uniformName Name of the variable.
  30091. * @param array array to be set.
  30092. * @returns this effect.
  30093. */
  30094. setArray3(uniformName: string, array: number[]): Effect;
  30095. /**
  30096. * 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)
  30097. * @param uniformName Name of the variable.
  30098. * @param array array to be set.
  30099. * @returns this effect.
  30100. */
  30101. setArray4(uniformName: string, array: number[]): Effect;
  30102. /**
  30103. * Sets matrices on a uniform variable.
  30104. * @param uniformName Name of the variable.
  30105. * @param matrices matrices to be set.
  30106. * @returns this effect.
  30107. */
  30108. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30109. /**
  30110. * Sets matrix on a uniform variable.
  30111. * @param uniformName Name of the variable.
  30112. * @param matrix matrix to be set.
  30113. * @returns this effect.
  30114. */
  30115. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30116. /**
  30117. * 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)
  30118. * @param uniformName Name of the variable.
  30119. * @param matrix matrix to be set.
  30120. * @returns this effect.
  30121. */
  30122. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30123. /**
  30124. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30125. * @param uniformName Name of the variable.
  30126. * @param matrix matrix to be set.
  30127. * @returns this effect.
  30128. */
  30129. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30130. /**
  30131. * Sets a float on a uniform variable.
  30132. * @param uniformName Name of the variable.
  30133. * @param value value to be set.
  30134. * @returns this effect.
  30135. */
  30136. setFloat(uniformName: string, value: number): Effect;
  30137. /**
  30138. * Sets a boolean on a uniform variable.
  30139. * @param uniformName Name of the variable.
  30140. * @param bool value to be set.
  30141. * @returns this effect.
  30142. */
  30143. setBool(uniformName: string, bool: boolean): Effect;
  30144. /**
  30145. * Sets a Vector2 on a uniform variable.
  30146. * @param uniformName Name of the variable.
  30147. * @param vector2 vector2 to be set.
  30148. * @returns this effect.
  30149. */
  30150. setVector2(uniformName: string, vector2: Vector2): Effect;
  30151. /**
  30152. * Sets a float2 on a uniform variable.
  30153. * @param uniformName Name of the variable.
  30154. * @param x First float in float2.
  30155. * @param y Second float in float2.
  30156. * @returns this effect.
  30157. */
  30158. setFloat2(uniformName: string, x: number, y: number): Effect;
  30159. /**
  30160. * Sets a Vector3 on a uniform variable.
  30161. * @param uniformName Name of the variable.
  30162. * @param vector3 Value to be set.
  30163. * @returns this effect.
  30164. */
  30165. setVector3(uniformName: string, vector3: Vector3): Effect;
  30166. /**
  30167. * Sets a float3 on a uniform variable.
  30168. * @param uniformName Name of the variable.
  30169. * @param x First float in float3.
  30170. * @param y Second float in float3.
  30171. * @param z Third float in float3.
  30172. * @returns this effect.
  30173. */
  30174. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30175. /**
  30176. * Sets a Vector4 on a uniform variable.
  30177. * @param uniformName Name of the variable.
  30178. * @param vector4 Value to be set.
  30179. * @returns this effect.
  30180. */
  30181. setVector4(uniformName: string, vector4: Vector4): Effect;
  30182. /**
  30183. * Sets a float4 on a uniform variable.
  30184. * @param uniformName Name of the variable.
  30185. * @param x First float in float4.
  30186. * @param y Second float in float4.
  30187. * @param z Third float in float4.
  30188. * @param w Fourth float in float4.
  30189. * @returns this effect.
  30190. */
  30191. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30192. /**
  30193. * Sets a Color3 on a uniform variable.
  30194. * @param uniformName Name of the variable.
  30195. * @param color3 Value to be set.
  30196. * @returns this effect.
  30197. */
  30198. setColor3(uniformName: string, color3: Color3): Effect;
  30199. /**
  30200. * Sets a Color4 on a uniform variable.
  30201. * @param uniformName Name of the variable.
  30202. * @param color3 Value to be set.
  30203. * @param alpha Alpha value to be set.
  30204. * @returns this effect.
  30205. */
  30206. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30207. /**
  30208. * Sets a Color4 on a uniform variable
  30209. * @param uniformName defines the name of the variable
  30210. * @param color4 defines the value to be set
  30211. * @returns this effect.
  30212. */
  30213. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30214. /** Release all associated resources */
  30215. dispose(): void;
  30216. /**
  30217. * This function will add a new shader to the shader store
  30218. * @param name the name of the shader
  30219. * @param pixelShader optional pixel shader content
  30220. * @param vertexShader optional vertex shader content
  30221. */
  30222. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30223. /**
  30224. * Store of each shader (The can be looked up using effect.key)
  30225. */
  30226. static ShadersStore: {
  30227. [key: string]: string;
  30228. };
  30229. /**
  30230. * Store of each included file for a shader (The can be looked up using effect.key)
  30231. */
  30232. static IncludesShadersStore: {
  30233. [key: string]: string;
  30234. };
  30235. /**
  30236. * Resets the cache of effects.
  30237. */
  30238. static ResetCache(): void;
  30239. }
  30240. }
  30241. declare module "babylonjs/Materials/colorCurves" {
  30242. import { Effect } from "babylonjs/Materials/effect";
  30243. /**
  30244. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30245. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30246. * 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;
  30247. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30248. */
  30249. export class ColorCurves {
  30250. private _dirty;
  30251. private _tempColor;
  30252. private _globalCurve;
  30253. private _highlightsCurve;
  30254. private _midtonesCurve;
  30255. private _shadowsCurve;
  30256. private _positiveCurve;
  30257. private _negativeCurve;
  30258. private _globalHue;
  30259. private _globalDensity;
  30260. private _globalSaturation;
  30261. private _globalExposure;
  30262. /**
  30263. * Gets the global Hue value.
  30264. * 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).
  30265. */
  30266. /**
  30267. * Sets the global Hue value.
  30268. * 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).
  30269. */
  30270. globalHue: number;
  30271. /**
  30272. * Gets the global Density value.
  30273. * 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.
  30274. * Values less than zero provide a filter of opposite hue.
  30275. */
  30276. /**
  30277. * Sets the global Density value.
  30278. * 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.
  30279. * Values less than zero provide a filter of opposite hue.
  30280. */
  30281. globalDensity: number;
  30282. /**
  30283. * Gets the global Saturation value.
  30284. * 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.
  30285. */
  30286. /**
  30287. * Sets the global Saturation value.
  30288. * 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.
  30289. */
  30290. globalSaturation: number;
  30291. /**
  30292. * Gets the global Exposure value.
  30293. * 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.
  30294. */
  30295. /**
  30296. * Sets the global Exposure value.
  30297. * 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.
  30298. */
  30299. globalExposure: number;
  30300. private _highlightsHue;
  30301. private _highlightsDensity;
  30302. private _highlightsSaturation;
  30303. private _highlightsExposure;
  30304. /**
  30305. * Gets the highlights Hue value.
  30306. * 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).
  30307. */
  30308. /**
  30309. * Sets the highlights Hue value.
  30310. * 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).
  30311. */
  30312. highlightsHue: number;
  30313. /**
  30314. * Gets the highlights Density value.
  30315. * 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.
  30316. * Values less than zero provide a filter of opposite hue.
  30317. */
  30318. /**
  30319. * Sets the highlights Density value.
  30320. * 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.
  30321. * Values less than zero provide a filter of opposite hue.
  30322. */
  30323. highlightsDensity: number;
  30324. /**
  30325. * Gets the highlights Saturation value.
  30326. * 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.
  30327. */
  30328. /**
  30329. * Sets the highlights Saturation value.
  30330. * 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.
  30331. */
  30332. highlightsSaturation: number;
  30333. /**
  30334. * Gets the highlights Exposure value.
  30335. * 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.
  30336. */
  30337. /**
  30338. * Sets the highlights Exposure value.
  30339. * 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.
  30340. */
  30341. highlightsExposure: number;
  30342. private _midtonesHue;
  30343. private _midtonesDensity;
  30344. private _midtonesSaturation;
  30345. private _midtonesExposure;
  30346. /**
  30347. * Gets the midtones Hue value.
  30348. * 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).
  30349. */
  30350. /**
  30351. * Sets the midtones Hue value.
  30352. * 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).
  30353. */
  30354. midtonesHue: number;
  30355. /**
  30356. * Gets the midtones Density value.
  30357. * 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.
  30358. * Values less than zero provide a filter of opposite hue.
  30359. */
  30360. /**
  30361. * Sets the midtones Density value.
  30362. * 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.
  30363. * Values less than zero provide a filter of opposite hue.
  30364. */
  30365. midtonesDensity: number;
  30366. /**
  30367. * Gets the midtones Saturation value.
  30368. * 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.
  30369. */
  30370. /**
  30371. * Sets the midtones Saturation value.
  30372. * 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.
  30373. */
  30374. midtonesSaturation: number;
  30375. /**
  30376. * Gets the midtones Exposure value.
  30377. * 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.
  30378. */
  30379. /**
  30380. * Sets the midtones Exposure value.
  30381. * 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.
  30382. */
  30383. midtonesExposure: number;
  30384. private _shadowsHue;
  30385. private _shadowsDensity;
  30386. private _shadowsSaturation;
  30387. private _shadowsExposure;
  30388. /**
  30389. * Gets the shadows Hue value.
  30390. * 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).
  30391. */
  30392. /**
  30393. * Sets the shadows Hue value.
  30394. * 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).
  30395. */
  30396. shadowsHue: number;
  30397. /**
  30398. * Gets the shadows Density value.
  30399. * 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.
  30400. * Values less than zero provide a filter of opposite hue.
  30401. */
  30402. /**
  30403. * Sets the shadows Density value.
  30404. * 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.
  30405. * Values less than zero provide a filter of opposite hue.
  30406. */
  30407. shadowsDensity: number;
  30408. /**
  30409. * Gets the shadows Saturation value.
  30410. * 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.
  30411. */
  30412. /**
  30413. * Sets the shadows Saturation value.
  30414. * 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.
  30415. */
  30416. shadowsSaturation: number;
  30417. /**
  30418. * Gets the shadows Exposure value.
  30419. * 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.
  30420. */
  30421. /**
  30422. * Sets the shadows Exposure value.
  30423. * 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.
  30424. */
  30425. shadowsExposure: number;
  30426. /**
  30427. * Returns the class name
  30428. * @returns The class name
  30429. */
  30430. getClassName(): string;
  30431. /**
  30432. * Binds the color curves to the shader.
  30433. * @param colorCurves The color curve to bind
  30434. * @param effect The effect to bind to
  30435. * @param positiveUniform The positive uniform shader parameter
  30436. * @param neutralUniform The neutral uniform shader parameter
  30437. * @param negativeUniform The negative uniform shader parameter
  30438. */
  30439. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30440. /**
  30441. * Prepare the list of uniforms associated with the ColorCurves effects.
  30442. * @param uniformsList The list of uniforms used in the effect
  30443. */
  30444. static PrepareUniforms(uniformsList: string[]): void;
  30445. /**
  30446. * Returns color grading data based on a hue, density, saturation and exposure value.
  30447. * @param filterHue The hue of the color filter.
  30448. * @param filterDensity The density of the color filter.
  30449. * @param saturation The saturation.
  30450. * @param exposure The exposure.
  30451. * @param result The result data container.
  30452. */
  30453. private getColorGradingDataToRef;
  30454. /**
  30455. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30456. * @param value The input slider value in range [-100,100].
  30457. * @returns Adjusted value.
  30458. */
  30459. private static applyColorGradingSliderNonlinear;
  30460. /**
  30461. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30462. * @param hue The hue (H) input.
  30463. * @param saturation The saturation (S) input.
  30464. * @param brightness The brightness (B) input.
  30465. * @result An RGBA color represented as Vector4.
  30466. */
  30467. private static fromHSBToRef;
  30468. /**
  30469. * Returns a value clamped between min and max
  30470. * @param value The value to clamp
  30471. * @param min The minimum of value
  30472. * @param max The maximum of value
  30473. * @returns The clamped value.
  30474. */
  30475. private static clamp;
  30476. /**
  30477. * Clones the current color curve instance.
  30478. * @return The cloned curves
  30479. */
  30480. clone(): ColorCurves;
  30481. /**
  30482. * Serializes the current color curve instance to a json representation.
  30483. * @return a JSON representation
  30484. */
  30485. serialize(): any;
  30486. /**
  30487. * Parses the color curve from a json representation.
  30488. * @param source the JSON source to parse
  30489. * @return The parsed curves
  30490. */
  30491. static Parse(source: any): ColorCurves;
  30492. }
  30493. }
  30494. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30495. import { Observable } from "babylonjs/Misc/observable";
  30496. import { Nullable } from "babylonjs/types";
  30497. import { Color4 } from "babylonjs/Maths/math";
  30498. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30499. import { Effect } from "babylonjs/Materials/effect";
  30500. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30501. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30502. /**
  30503. * Interface to follow in your material defines to integrate easily the
  30504. * Image proccessing functions.
  30505. * @hidden
  30506. */
  30507. export interface IImageProcessingConfigurationDefines {
  30508. IMAGEPROCESSING: boolean;
  30509. VIGNETTE: boolean;
  30510. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30511. VIGNETTEBLENDMODEOPAQUE: boolean;
  30512. TONEMAPPING: boolean;
  30513. TONEMAPPING_ACES: boolean;
  30514. CONTRAST: boolean;
  30515. EXPOSURE: boolean;
  30516. COLORCURVES: boolean;
  30517. COLORGRADING: boolean;
  30518. COLORGRADING3D: boolean;
  30519. SAMPLER3DGREENDEPTH: boolean;
  30520. SAMPLER3DBGRMAP: boolean;
  30521. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30522. }
  30523. /**
  30524. * @hidden
  30525. */
  30526. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30527. IMAGEPROCESSING: boolean;
  30528. VIGNETTE: boolean;
  30529. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30530. VIGNETTEBLENDMODEOPAQUE: boolean;
  30531. TONEMAPPING: boolean;
  30532. TONEMAPPING_ACES: boolean;
  30533. CONTRAST: boolean;
  30534. COLORCURVES: boolean;
  30535. COLORGRADING: boolean;
  30536. COLORGRADING3D: boolean;
  30537. SAMPLER3DGREENDEPTH: boolean;
  30538. SAMPLER3DBGRMAP: boolean;
  30539. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30540. EXPOSURE: boolean;
  30541. constructor();
  30542. }
  30543. /**
  30544. * This groups together the common properties used for image processing either in direct forward pass
  30545. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30546. * or not.
  30547. */
  30548. export class ImageProcessingConfiguration {
  30549. /**
  30550. * Default tone mapping applied in BabylonJS.
  30551. */
  30552. static readonly TONEMAPPING_STANDARD: number;
  30553. /**
  30554. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30555. * to other engines rendering to increase portability.
  30556. */
  30557. static readonly TONEMAPPING_ACES: number;
  30558. /**
  30559. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30560. */
  30561. colorCurves: Nullable<ColorCurves>;
  30562. private _colorCurvesEnabled;
  30563. /**
  30564. * Gets wether the color curves effect is enabled.
  30565. */
  30566. /**
  30567. * Sets wether the color curves effect is enabled.
  30568. */
  30569. colorCurvesEnabled: boolean;
  30570. private _colorGradingTexture;
  30571. /**
  30572. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30573. */
  30574. /**
  30575. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30576. */
  30577. colorGradingTexture: Nullable<BaseTexture>;
  30578. private _colorGradingEnabled;
  30579. /**
  30580. * Gets wether the color grading effect is enabled.
  30581. */
  30582. /**
  30583. * Sets wether the color grading effect is enabled.
  30584. */
  30585. colorGradingEnabled: boolean;
  30586. private _colorGradingWithGreenDepth;
  30587. /**
  30588. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30589. */
  30590. /**
  30591. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30592. */
  30593. colorGradingWithGreenDepth: boolean;
  30594. private _colorGradingBGR;
  30595. /**
  30596. * Gets wether the color grading texture contains BGR values.
  30597. */
  30598. /**
  30599. * Sets wether the color grading texture contains BGR values.
  30600. */
  30601. colorGradingBGR: boolean;
  30602. /** @hidden */
  30603. _exposure: number;
  30604. /**
  30605. * Gets the Exposure used in the effect.
  30606. */
  30607. /**
  30608. * Sets the Exposure used in the effect.
  30609. */
  30610. exposure: number;
  30611. private _toneMappingEnabled;
  30612. /**
  30613. * Gets wether the tone mapping effect is enabled.
  30614. */
  30615. /**
  30616. * Sets wether the tone mapping effect is enabled.
  30617. */
  30618. toneMappingEnabled: boolean;
  30619. private _toneMappingType;
  30620. /**
  30621. * Gets the type of tone mapping effect.
  30622. */
  30623. /**
  30624. * Sets the type of tone mapping effect used in BabylonJS.
  30625. */
  30626. toneMappingType: number;
  30627. protected _contrast: number;
  30628. /**
  30629. * Gets the contrast used in the effect.
  30630. */
  30631. /**
  30632. * Sets the contrast used in the effect.
  30633. */
  30634. contrast: number;
  30635. /**
  30636. * Vignette stretch size.
  30637. */
  30638. vignetteStretch: number;
  30639. /**
  30640. * Vignette centre X Offset.
  30641. */
  30642. vignetteCentreX: number;
  30643. /**
  30644. * Vignette centre Y Offset.
  30645. */
  30646. vignetteCentreY: number;
  30647. /**
  30648. * Vignette weight or intensity of the vignette effect.
  30649. */
  30650. vignetteWeight: number;
  30651. /**
  30652. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30653. * if vignetteEnabled is set to true.
  30654. */
  30655. vignetteColor: Color4;
  30656. /**
  30657. * Camera field of view used by the Vignette effect.
  30658. */
  30659. vignetteCameraFov: number;
  30660. private _vignetteBlendMode;
  30661. /**
  30662. * Gets the vignette blend mode allowing different kind of effect.
  30663. */
  30664. /**
  30665. * Sets the vignette blend mode allowing different kind of effect.
  30666. */
  30667. vignetteBlendMode: number;
  30668. private _vignetteEnabled;
  30669. /**
  30670. * Gets wether the vignette effect is enabled.
  30671. */
  30672. /**
  30673. * Sets wether the vignette effect is enabled.
  30674. */
  30675. vignetteEnabled: boolean;
  30676. private _applyByPostProcess;
  30677. /**
  30678. * Gets wether the image processing is applied through a post process or not.
  30679. */
  30680. /**
  30681. * Sets wether the image processing is applied through a post process or not.
  30682. */
  30683. applyByPostProcess: boolean;
  30684. private _isEnabled;
  30685. /**
  30686. * Gets wether the image processing is enabled or not.
  30687. */
  30688. /**
  30689. * Sets wether the image processing is enabled or not.
  30690. */
  30691. isEnabled: boolean;
  30692. /**
  30693. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30694. */
  30695. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30696. /**
  30697. * Method called each time the image processing information changes requires to recompile the effect.
  30698. */
  30699. protected _updateParameters(): void;
  30700. /**
  30701. * Gets the current class name.
  30702. * @return "ImageProcessingConfiguration"
  30703. */
  30704. getClassName(): string;
  30705. /**
  30706. * Prepare the list of uniforms associated with the Image Processing effects.
  30707. * @param uniforms The list of uniforms used in the effect
  30708. * @param defines the list of defines currently in use
  30709. */
  30710. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30711. /**
  30712. * Prepare the list of samplers associated with the Image Processing effects.
  30713. * @param samplersList The list of uniforms used in the effect
  30714. * @param defines the list of defines currently in use
  30715. */
  30716. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30717. /**
  30718. * Prepare the list of defines associated to the shader.
  30719. * @param defines the list of defines to complete
  30720. * @param forPostProcess Define if we are currently in post process mode or not
  30721. */
  30722. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30723. /**
  30724. * Returns true if all the image processing information are ready.
  30725. * @returns True if ready, otherwise, false
  30726. */
  30727. isReady(): boolean;
  30728. /**
  30729. * Binds the image processing to the shader.
  30730. * @param effect The effect to bind to
  30731. * @param aspectRatio Define the current aspect ratio of the effect
  30732. */
  30733. bind(effect: Effect, aspectRatio?: number): void;
  30734. /**
  30735. * Clones the current image processing instance.
  30736. * @return The cloned image processing
  30737. */
  30738. clone(): ImageProcessingConfiguration;
  30739. /**
  30740. * Serializes the current image processing instance to a json representation.
  30741. * @return a JSON representation
  30742. */
  30743. serialize(): any;
  30744. /**
  30745. * Parses the image processing from a json representation.
  30746. * @param source the JSON source to parse
  30747. * @return The parsed image processing
  30748. */
  30749. static Parse(source: any): ImageProcessingConfiguration;
  30750. private static _VIGNETTEMODE_MULTIPLY;
  30751. private static _VIGNETTEMODE_OPAQUE;
  30752. /**
  30753. * Used to apply the vignette as a mix with the pixel color.
  30754. */
  30755. static readonly VIGNETTEMODE_MULTIPLY: number;
  30756. /**
  30757. * Used to apply the vignette as a replacement of the pixel color.
  30758. */
  30759. static readonly VIGNETTEMODE_OPAQUE: number;
  30760. }
  30761. }
  30762. declare module "babylonjs/Materials/fresnelParameters" {
  30763. import { Color3 } from "babylonjs/Maths/math";
  30764. /**
  30765. * This represents all the required information to add a fresnel effect on a material:
  30766. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30767. */
  30768. export class FresnelParameters {
  30769. private _isEnabled;
  30770. /**
  30771. * Define if the fresnel effect is enable or not.
  30772. */
  30773. isEnabled: boolean;
  30774. /**
  30775. * Define the color used on edges (grazing angle)
  30776. */
  30777. leftColor: Color3;
  30778. /**
  30779. * Define the color used on center
  30780. */
  30781. rightColor: Color3;
  30782. /**
  30783. * Define bias applied to computed fresnel term
  30784. */
  30785. bias: number;
  30786. /**
  30787. * Defined the power exponent applied to fresnel term
  30788. */
  30789. power: number;
  30790. /**
  30791. * Clones the current fresnel and its valuues
  30792. * @returns a clone fresnel configuration
  30793. */
  30794. clone(): FresnelParameters;
  30795. /**
  30796. * Serializes the current fresnel parameters to a JSON representation.
  30797. * @return the JSON serialization
  30798. */
  30799. serialize(): any;
  30800. /**
  30801. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30802. * @param parsedFresnelParameters Define the JSON representation
  30803. * @returns the parsed parameters
  30804. */
  30805. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30806. }
  30807. }
  30808. declare module "babylonjs/Misc/decorators" {
  30809. import { Nullable } from "babylonjs/types";
  30810. import { Scene } from "babylonjs/scene";
  30811. import { IAnimatable } from "babylonjs/Misc/tools";
  30812. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30813. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30814. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30815. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30816. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30817. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30818. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30819. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30820. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30821. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30822. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30823. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30824. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30825. /**
  30826. * Decorator used to define property that can be serialized as reference to a camera
  30827. * @param sourceName defines the name of the property to decorate
  30828. */
  30829. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30830. /**
  30831. * Class used to help serialization objects
  30832. */
  30833. export class SerializationHelper {
  30834. /** hidden */
  30835. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30836. /** hidden */
  30837. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30838. /** hidden */
  30839. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30840. /** hidden */
  30841. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30842. /**
  30843. * Appends the serialized animations from the source animations
  30844. * @param source Source containing the animations
  30845. * @param destination Target to store the animations
  30846. */
  30847. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30848. /**
  30849. * Static function used to serialized a specific entity
  30850. * @param entity defines the entity to serialize
  30851. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30852. * @returns a JSON compatible object representing the serialization of the entity
  30853. */
  30854. static Serialize<T>(entity: T, serializationObject?: any): any;
  30855. /**
  30856. * Creates a new entity from a serialization data object
  30857. * @param creationFunction defines a function used to instanciated the new entity
  30858. * @param source defines the source serialization data
  30859. * @param scene defines the hosting scene
  30860. * @param rootUrl defines the root url for resources
  30861. * @returns a new entity
  30862. */
  30863. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30864. /**
  30865. * Clones an object
  30866. * @param creationFunction defines the function used to instanciate the new object
  30867. * @param source defines the source object
  30868. * @returns the cloned object
  30869. */
  30870. static Clone<T>(creationFunction: () => T, source: T): T;
  30871. /**
  30872. * Instanciates a new object based on a source one (some data will be shared between both object)
  30873. * @param creationFunction defines the function used to instanciate the new object
  30874. * @param source defines the source object
  30875. * @returns the new object
  30876. */
  30877. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30878. }
  30879. }
  30880. declare module "babylonjs/Cameras/camera" {
  30881. import { SmartArray } from "babylonjs/Misc/smartArray";
  30882. import { Observable } from "babylonjs/Misc/observable";
  30883. import { Nullable } from "babylonjs/types";
  30884. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30885. import { Scene } from "babylonjs/scene";
  30886. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30887. import { Node } from "babylonjs/node";
  30888. import { Mesh } from "babylonjs/Meshes/mesh";
  30889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30890. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30891. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30892. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30893. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30894. import { Ray } from "babylonjs/Culling/ray";
  30895. /**
  30896. * This is the base class of all the camera used in the application.
  30897. * @see http://doc.babylonjs.com/features/cameras
  30898. */
  30899. export class Camera extends Node {
  30900. /** @hidden */
  30901. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30902. /**
  30903. * This is the default projection mode used by the cameras.
  30904. * It helps recreating a feeling of perspective and better appreciate depth.
  30905. * This is the best way to simulate real life cameras.
  30906. */
  30907. static readonly PERSPECTIVE_CAMERA: number;
  30908. /**
  30909. * This helps creating camera with an orthographic mode.
  30910. * 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.
  30911. */
  30912. static readonly ORTHOGRAPHIC_CAMERA: number;
  30913. /**
  30914. * This is the default FOV mode for perspective cameras.
  30915. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30916. */
  30917. static readonly FOVMODE_VERTICAL_FIXED: number;
  30918. /**
  30919. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30920. */
  30921. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30922. /**
  30923. * This specifies ther is no need for a camera rig.
  30924. * Basically only one eye is rendered corresponding to the camera.
  30925. */
  30926. static readonly RIG_MODE_NONE: number;
  30927. /**
  30928. * Simulates a camera Rig with one blue eye and one red eye.
  30929. * This can be use with 3d blue and red glasses.
  30930. */
  30931. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30932. /**
  30933. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30934. */
  30935. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30936. /**
  30937. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30938. */
  30939. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30940. /**
  30941. * Defines that both eyes of the camera will be rendered over under each other.
  30942. */
  30943. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30944. /**
  30945. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30946. */
  30947. static readonly RIG_MODE_VR: number;
  30948. /**
  30949. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30950. */
  30951. static readonly RIG_MODE_WEBVR: number;
  30952. /**
  30953. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30954. */
  30955. static readonly RIG_MODE_CUSTOM: number;
  30956. /**
  30957. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30958. */
  30959. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30960. /**
  30961. * Define the input manager associated with the camera.
  30962. */
  30963. inputs: CameraInputsManager<Camera>;
  30964. /** @hidden */
  30965. _position: Vector3;
  30966. /**
  30967. * Define the current local position of the camera in the scene
  30968. */
  30969. position: Vector3;
  30970. /**
  30971. * The vector the camera should consider as up.
  30972. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30973. */
  30974. upVector: Vector3;
  30975. /**
  30976. * Define the current limit on the left side for an orthographic camera
  30977. * In scene unit
  30978. */
  30979. orthoLeft: Nullable<number>;
  30980. /**
  30981. * Define the current limit on the right side for an orthographic camera
  30982. * In scene unit
  30983. */
  30984. orthoRight: Nullable<number>;
  30985. /**
  30986. * Define the current limit on the bottom side for an orthographic camera
  30987. * In scene unit
  30988. */
  30989. orthoBottom: Nullable<number>;
  30990. /**
  30991. * Define the current limit on the top side for an orthographic camera
  30992. * In scene unit
  30993. */
  30994. orthoTop: Nullable<number>;
  30995. /**
  30996. * Field Of View is set in Radians. (default is 0.8)
  30997. */
  30998. fov: number;
  30999. /**
  31000. * Define the minimum distance the camera can see from.
  31001. * This is important to note that the depth buffer are not infinite and the closer it starts
  31002. * the more your scene might encounter depth fighting issue.
  31003. */
  31004. minZ: number;
  31005. /**
  31006. * Define the maximum distance the camera can see to.
  31007. * This is important to note that the depth buffer are not infinite and the further it end
  31008. * the more your scene might encounter depth fighting issue.
  31009. */
  31010. maxZ: number;
  31011. /**
  31012. * Define the default inertia of the camera.
  31013. * This helps giving a smooth feeling to the camera movement.
  31014. */
  31015. inertia: number;
  31016. /**
  31017. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  31018. */
  31019. mode: number;
  31020. /**
  31021. * Define wether the camera is intermediate.
  31022. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31023. */
  31024. isIntermediate: boolean;
  31025. /**
  31026. * Define the viewport of the camera.
  31027. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31028. */
  31029. viewport: Viewport;
  31030. /**
  31031. * Restricts the camera to viewing objects with the same layerMask.
  31032. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31033. */
  31034. layerMask: number;
  31035. /**
  31036. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31037. */
  31038. fovMode: number;
  31039. /**
  31040. * Rig mode of the camera.
  31041. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31042. * This is normally controlled byt the camera themselves as internal use.
  31043. */
  31044. cameraRigMode: number;
  31045. /**
  31046. * Defines the distance between both "eyes" in case of a RIG
  31047. */
  31048. interaxialDistance: number;
  31049. /**
  31050. * Defines if stereoscopic rendering is done side by side or over under.
  31051. */
  31052. isStereoscopicSideBySide: boolean;
  31053. /**
  31054. * 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
  31055. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31056. * else in the scene.
  31057. */
  31058. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31059. /**
  31060. * When set, the camera will render to this render target instead of the default canvas
  31061. */
  31062. outputRenderTarget: Nullable<RenderTargetTexture>;
  31063. /**
  31064. * Observable triggered when the camera view matrix has changed.
  31065. */
  31066. onViewMatrixChangedObservable: Observable<Camera>;
  31067. /**
  31068. * Observable triggered when the camera Projection matrix has changed.
  31069. */
  31070. onProjectionMatrixChangedObservable: Observable<Camera>;
  31071. /**
  31072. * Observable triggered when the inputs have been processed.
  31073. */
  31074. onAfterCheckInputsObservable: Observable<Camera>;
  31075. /**
  31076. * Observable triggered when reset has been called and applied to the camera.
  31077. */
  31078. onRestoreStateObservable: Observable<Camera>;
  31079. /** @hidden */
  31080. _cameraRigParams: any;
  31081. /** @hidden */
  31082. _rigCameras: Camera[];
  31083. /** @hidden */
  31084. _rigPostProcess: Nullable<PostProcess>;
  31085. protected _webvrViewMatrix: Matrix;
  31086. /** @hidden */
  31087. _skipRendering: boolean;
  31088. /** @hidden */
  31089. _projectionMatrix: Matrix;
  31090. /** @hidden */
  31091. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31092. /** @hidden */
  31093. _activeMeshes: SmartArray<AbstractMesh>;
  31094. protected _globalPosition: Vector3;
  31095. /** hidden */
  31096. _computedViewMatrix: Matrix;
  31097. private _doNotComputeProjectionMatrix;
  31098. private _transformMatrix;
  31099. private _frustumPlanes;
  31100. private _refreshFrustumPlanes;
  31101. private _storedFov;
  31102. private _stateStored;
  31103. /**
  31104. * Instantiates a new camera object.
  31105. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31106. * @see http://doc.babylonjs.com/features/cameras
  31107. * @param name Defines the name of the camera in the scene
  31108. * @param position Defines the position of the camera
  31109. * @param scene Defines the scene the camera belongs too
  31110. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31111. */
  31112. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31113. /**
  31114. * Store current camera state (fov, position, etc..)
  31115. * @returns the camera
  31116. */
  31117. storeState(): Camera;
  31118. /**
  31119. * Restores the camera state values if it has been stored. You must call storeState() first
  31120. */
  31121. protected _restoreStateValues(): boolean;
  31122. /**
  31123. * Restored camera state. You must call storeState() first.
  31124. * @returns true if restored and false otherwise
  31125. */
  31126. restoreState(): boolean;
  31127. /**
  31128. * Gets the class name of the camera.
  31129. * @returns the class name
  31130. */
  31131. getClassName(): string;
  31132. /** @hidden */
  31133. readonly _isCamera: boolean;
  31134. /**
  31135. * Gets a string representation of the camera useful for debug purpose.
  31136. * @param fullDetails Defines that a more verboe level of logging is required
  31137. * @returns the string representation
  31138. */
  31139. toString(fullDetails?: boolean): string;
  31140. /**
  31141. * Gets the current world space position of the camera.
  31142. */
  31143. readonly globalPosition: Vector3;
  31144. /**
  31145. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31146. * @returns the active meshe list
  31147. */
  31148. getActiveMeshes(): SmartArray<AbstractMesh>;
  31149. /**
  31150. * Check wether a mesh is part of the current active mesh list of the camera
  31151. * @param mesh Defines the mesh to check
  31152. * @returns true if active, false otherwise
  31153. */
  31154. isActiveMesh(mesh: Mesh): boolean;
  31155. /**
  31156. * Is this camera ready to be used/rendered
  31157. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31158. * @return true if the camera is ready
  31159. */
  31160. isReady(completeCheck?: boolean): boolean;
  31161. /** @hidden */
  31162. _initCache(): void;
  31163. /** @hidden */
  31164. _updateCache(ignoreParentClass?: boolean): void;
  31165. /** @hidden */
  31166. _isSynchronized(): boolean;
  31167. /** @hidden */
  31168. _isSynchronizedViewMatrix(): boolean;
  31169. /** @hidden */
  31170. _isSynchronizedProjectionMatrix(): boolean;
  31171. /**
  31172. * Attach the input controls to a specific dom element to get the input from.
  31173. * @param element Defines the element the controls should be listened from
  31174. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31175. */
  31176. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31177. /**
  31178. * Detach the current controls from the specified dom element.
  31179. * @param element Defines the element to stop listening the inputs from
  31180. */
  31181. detachControl(element: HTMLElement): void;
  31182. /**
  31183. * Update the camera state according to the different inputs gathered during the frame.
  31184. */
  31185. update(): void;
  31186. /** @hidden */
  31187. _checkInputs(): void;
  31188. /** @hidden */
  31189. readonly rigCameras: Camera[];
  31190. /**
  31191. * Gets the post process used by the rig cameras
  31192. */
  31193. readonly rigPostProcess: Nullable<PostProcess>;
  31194. /**
  31195. * Internal, gets the first post proces.
  31196. * @returns the first post process to be run on this camera.
  31197. */
  31198. _getFirstPostProcess(): Nullable<PostProcess>;
  31199. private _cascadePostProcessesToRigCams;
  31200. /**
  31201. * Attach a post process to the camera.
  31202. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31203. * @param postProcess The post process to attach to the camera
  31204. * @param insertAt The position of the post process in case several of them are in use in the scene
  31205. * @returns the position the post process has been inserted at
  31206. */
  31207. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31208. /**
  31209. * Detach a post process to the camera.
  31210. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31211. * @param postProcess The post process to detach from the camera
  31212. */
  31213. detachPostProcess(postProcess: PostProcess): void;
  31214. /**
  31215. * Gets the current world matrix of the camera
  31216. */
  31217. getWorldMatrix(): Matrix;
  31218. /** @hidden */
  31219. _getViewMatrix(): Matrix;
  31220. /**
  31221. * Gets the current view matrix of the camera.
  31222. * @param force forces the camera to recompute the matrix without looking at the cached state
  31223. * @returns the view matrix
  31224. */
  31225. getViewMatrix(force?: boolean): Matrix;
  31226. /**
  31227. * Freeze the projection matrix.
  31228. * It will prevent the cache check of the camera projection compute and can speed up perf
  31229. * if no parameter of the camera are meant to change
  31230. * @param projection Defines manually a projection if necessary
  31231. */
  31232. freezeProjectionMatrix(projection?: Matrix): void;
  31233. /**
  31234. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31235. */
  31236. unfreezeProjectionMatrix(): void;
  31237. /**
  31238. * Gets the current projection matrix of the camera.
  31239. * @param force forces the camera to recompute the matrix without looking at the cached state
  31240. * @returns the projection matrix
  31241. */
  31242. getProjectionMatrix(force?: boolean): Matrix;
  31243. /**
  31244. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31245. * @returns a Matrix
  31246. */
  31247. getTransformationMatrix(): Matrix;
  31248. private _updateFrustumPlanes;
  31249. /**
  31250. * Checks if a cullable object (mesh...) is in the camera frustum
  31251. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31252. * @param target The object to check
  31253. * @returns true if the object is in frustum otherwise false
  31254. */
  31255. isInFrustum(target: ICullable): boolean;
  31256. /**
  31257. * Checks if a cullable object (mesh...) is in the camera frustum
  31258. * Unlike isInFrustum this cheks the full bounding box
  31259. * @param target The object to check
  31260. * @returns true if the object is in frustum otherwise false
  31261. */
  31262. isCompletelyInFrustum(target: ICullable): boolean;
  31263. /**
  31264. * Gets a ray in the forward direction from the camera.
  31265. * @param length Defines the length of the ray to create
  31266. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31267. * @param origin Defines the start point of the ray which defaults to the camera position
  31268. * @returns the forward ray
  31269. */
  31270. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31271. /**
  31272. * Releases resources associated with this node.
  31273. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31274. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31275. */
  31276. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31277. /** @hidden */
  31278. _isLeftCamera: boolean;
  31279. /**
  31280. * Gets the left camera of a rig setup in case of Rigged Camera
  31281. */
  31282. readonly isLeftCamera: boolean;
  31283. /** @hidden */
  31284. _isRightCamera: boolean;
  31285. /**
  31286. * Gets the right camera of a rig setup in case of Rigged Camera
  31287. */
  31288. readonly isRightCamera: boolean;
  31289. /**
  31290. * Gets the left camera of a rig setup in case of Rigged Camera
  31291. */
  31292. readonly leftCamera: Nullable<FreeCamera>;
  31293. /**
  31294. * Gets the right camera of a rig setup in case of Rigged Camera
  31295. */
  31296. readonly rightCamera: Nullable<FreeCamera>;
  31297. /**
  31298. * Gets the left camera target of a rig setup in case of Rigged Camera
  31299. * @returns the target position
  31300. */
  31301. getLeftTarget(): Nullable<Vector3>;
  31302. /**
  31303. * Gets the right camera target of a rig setup in case of Rigged Camera
  31304. * @returns the target position
  31305. */
  31306. getRightTarget(): Nullable<Vector3>;
  31307. /**
  31308. * @hidden
  31309. */
  31310. setCameraRigMode(mode: number, rigParams: any): void;
  31311. /** @hidden */
  31312. static _setStereoscopicRigMode(camera: Camera): void;
  31313. /** @hidden */
  31314. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31315. /** @hidden */
  31316. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31317. /** @hidden */
  31318. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31319. /** @hidden */
  31320. _getVRProjectionMatrix(): Matrix;
  31321. protected _updateCameraRotationMatrix(): void;
  31322. protected _updateWebVRCameraRotationMatrix(): void;
  31323. /**
  31324. * This function MUST be overwritten by the different WebVR cameras available.
  31325. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31326. * @hidden
  31327. */
  31328. _getWebVRProjectionMatrix(): Matrix;
  31329. /**
  31330. * This function MUST be overwritten by the different WebVR cameras available.
  31331. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31332. * @hidden
  31333. */
  31334. _getWebVRViewMatrix(): Matrix;
  31335. /** @hidden */
  31336. setCameraRigParameter(name: string, value: any): void;
  31337. /**
  31338. * needs to be overridden by children so sub has required properties to be copied
  31339. * @hidden
  31340. */
  31341. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31342. /**
  31343. * May need to be overridden by children
  31344. * @hidden
  31345. */
  31346. _updateRigCameras(): void;
  31347. /** @hidden */
  31348. _setupInputs(): void;
  31349. /**
  31350. * Serialiaze the camera setup to a json represention
  31351. * @returns the JSON representation
  31352. */
  31353. serialize(): any;
  31354. /**
  31355. * Clones the current camera.
  31356. * @param name The cloned camera name
  31357. * @returns the cloned camera
  31358. */
  31359. clone(name: string): Camera;
  31360. /**
  31361. * Gets the direction of the camera relative to a given local axis.
  31362. * @param localAxis Defines the reference axis to provide a relative direction.
  31363. * @return the direction
  31364. */
  31365. getDirection(localAxis: Vector3): Vector3;
  31366. /**
  31367. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31368. * @param localAxis Defines the reference axis to provide a relative direction.
  31369. * @param result Defines the vector to store the result in
  31370. */
  31371. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31372. /**
  31373. * Gets a camera constructor for a given camera type
  31374. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31375. * @param name The name of the camera the result will be able to instantiate
  31376. * @param scene The scene the result will construct the camera in
  31377. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31378. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31379. * @returns a factory method to construc the camera
  31380. */
  31381. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31382. /**
  31383. * Compute the world matrix of the camera.
  31384. * @returns the camera workd matrix
  31385. */
  31386. computeWorldMatrix(): Matrix;
  31387. /**
  31388. * Parse a JSON and creates the camera from the parsed information
  31389. * @param parsedCamera The JSON to parse
  31390. * @param scene The scene to instantiate the camera in
  31391. * @returns the newly constructed camera
  31392. */
  31393. static Parse(parsedCamera: any, scene: Scene): Camera;
  31394. }
  31395. }
  31396. declare module "babylonjs/Misc/tools" {
  31397. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31398. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31399. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31400. import { Observable } from "babylonjs/Misc/observable";
  31401. import { DomManagement } from "babylonjs/Misc/domManagement";
  31402. import { WebRequest } from "babylonjs/Misc/webRequest";
  31403. import { Camera } from "babylonjs/Cameras/camera";
  31404. import { Engine } from "babylonjs/Engines/engine";
  31405. import { Animation } from "babylonjs/Animations/animation";
  31406. /**
  31407. * Interface for any object that can request an animation frame
  31408. */
  31409. export interface ICustomAnimationFrameRequester {
  31410. /**
  31411. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31412. */
  31413. renderFunction?: Function;
  31414. /**
  31415. * Called to request the next frame to render to
  31416. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31417. */
  31418. requestAnimationFrame: Function;
  31419. /**
  31420. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31421. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31422. */
  31423. requestID?: number;
  31424. }
  31425. /**
  31426. * Interface containing an array of animations
  31427. */
  31428. export interface IAnimatable {
  31429. /**
  31430. * Array of animations
  31431. */
  31432. animations: Nullable<Array<Animation>>;
  31433. }
  31434. /** Interface used by value gradients (color, factor, ...) */
  31435. export interface IValueGradient {
  31436. /**
  31437. * Gets or sets the gradient value (between 0 and 1)
  31438. */
  31439. gradient: number;
  31440. }
  31441. /** Class used to store color4 gradient */
  31442. export class ColorGradient implements IValueGradient {
  31443. /**
  31444. * Gets or sets the gradient value (between 0 and 1)
  31445. */
  31446. gradient: number;
  31447. /**
  31448. * Gets or sets first associated color
  31449. */
  31450. color1: Color4;
  31451. /**
  31452. * Gets or sets second associated color
  31453. */
  31454. color2?: Color4;
  31455. /**
  31456. * Will get a color picked randomly between color1 and color2.
  31457. * If color2 is undefined then color1 will be used
  31458. * @param result defines the target Color4 to store the result in
  31459. */
  31460. getColorToRef(result: Color4): void;
  31461. }
  31462. /** Class used to store color 3 gradient */
  31463. export class Color3Gradient implements IValueGradient {
  31464. /**
  31465. * Gets or sets the gradient value (between 0 and 1)
  31466. */
  31467. gradient: number;
  31468. /**
  31469. * Gets or sets the associated color
  31470. */
  31471. color: Color3;
  31472. }
  31473. /** Class used to store factor gradient */
  31474. export class FactorGradient implements IValueGradient {
  31475. /**
  31476. * Gets or sets the gradient value (between 0 and 1)
  31477. */
  31478. gradient: number;
  31479. /**
  31480. * Gets or sets first associated factor
  31481. */
  31482. factor1: number;
  31483. /**
  31484. * Gets or sets second associated factor
  31485. */
  31486. factor2?: number;
  31487. /**
  31488. * Will get a number picked randomly between factor1 and factor2.
  31489. * If factor2 is undefined then factor1 will be used
  31490. * @returns the picked number
  31491. */
  31492. getFactor(): number;
  31493. }
  31494. /**
  31495. * @ignore
  31496. * Application error to support additional information when loading a file
  31497. */
  31498. export class LoadFileError extends Error {
  31499. /** defines the optional web request */
  31500. request?: WebRequest | undefined;
  31501. private static _setPrototypeOf;
  31502. /**
  31503. * Creates a new LoadFileError
  31504. * @param message defines the message of the error
  31505. * @param request defines the optional web request
  31506. */
  31507. constructor(message: string,
  31508. /** defines the optional web request */
  31509. request?: WebRequest | undefined);
  31510. }
  31511. /**
  31512. * Class used to define a retry strategy when error happens while loading assets
  31513. */
  31514. export class RetryStrategy {
  31515. /**
  31516. * Function used to defines an exponential back off strategy
  31517. * @param maxRetries defines the maximum number of retries (3 by default)
  31518. * @param baseInterval defines the interval between retries
  31519. * @returns the strategy function to use
  31520. */
  31521. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31522. }
  31523. /**
  31524. * File request interface
  31525. */
  31526. export interface IFileRequest {
  31527. /**
  31528. * Raised when the request is complete (success or error).
  31529. */
  31530. onCompleteObservable: Observable<IFileRequest>;
  31531. /**
  31532. * Aborts the request for a file.
  31533. */
  31534. abort: () => void;
  31535. }
  31536. /**
  31537. * Class containing a set of static utilities functions
  31538. */
  31539. export class Tools {
  31540. /**
  31541. * Gets or sets the base URL to use to load assets
  31542. */
  31543. static BaseUrl: string;
  31544. /**
  31545. * Enable/Disable Custom HTTP Request Headers globally.
  31546. * default = false
  31547. * @see CustomRequestHeaders
  31548. */
  31549. static UseCustomRequestHeaders: boolean;
  31550. /**
  31551. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31552. * i.e. when loading files, where the server/service expects an Authorization header
  31553. */
  31554. static CustomRequestHeaders: {
  31555. [key: string]: string;
  31556. };
  31557. /**
  31558. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31559. */
  31560. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31561. /**
  31562. * Default behaviour for cors in the application.
  31563. * It can be a string if the expected behavior is identical in the entire app.
  31564. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31565. */
  31566. static CorsBehavior: string | ((url: string | string[]) => string);
  31567. /**
  31568. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31569. * @ignorenaming
  31570. */
  31571. static UseFallbackTexture: boolean;
  31572. /**
  31573. * Use this object to register external classes like custom textures or material
  31574. * to allow the laoders to instantiate them
  31575. */
  31576. static RegisteredExternalClasses: {
  31577. [key: string]: Object;
  31578. };
  31579. /**
  31580. * Texture content used if a texture cannot loaded
  31581. * @ignorenaming
  31582. */
  31583. static fallbackTexture: string;
  31584. /**
  31585. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31586. * @param u defines the coordinate on X axis
  31587. * @param v defines the coordinate on Y axis
  31588. * @param width defines the width of the source data
  31589. * @param height defines the height of the source data
  31590. * @param pixels defines the source byte array
  31591. * @param color defines the output color
  31592. */
  31593. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31594. /**
  31595. * Interpolates between a and b via alpha
  31596. * @param a The lower value (returned when alpha = 0)
  31597. * @param b The upper value (returned when alpha = 1)
  31598. * @param alpha The interpolation-factor
  31599. * @return The mixed value
  31600. */
  31601. static Mix(a: number, b: number, alpha: number): number;
  31602. /**
  31603. * Tries to instantiate a new object from a given class name
  31604. * @param className defines the class name to instantiate
  31605. * @returns the new object or null if the system was not able to do the instantiation
  31606. */
  31607. static Instantiate(className: string): any;
  31608. /**
  31609. * Provides a slice function that will work even on IE
  31610. * @param data defines the array to slice
  31611. * @param start defines the start of the data (optional)
  31612. * @param end defines the end of the data (optional)
  31613. * @returns the new sliced array
  31614. */
  31615. static Slice<T>(data: T, start?: number, end?: number): T;
  31616. /**
  31617. * Polyfill for setImmediate
  31618. * @param action defines the action to execute after the current execution block
  31619. */
  31620. static SetImmediate(action: () => void): void;
  31621. /**
  31622. * Function indicating if a number is an exponent of 2
  31623. * @param value defines the value to test
  31624. * @returns true if the value is an exponent of 2
  31625. */
  31626. static IsExponentOfTwo(value: number): boolean;
  31627. private static _tmpFloatArray;
  31628. /**
  31629. * Returns the nearest 32-bit single precision float representation of a Number
  31630. * @param value A Number. If the parameter is of a different type, it will get converted
  31631. * to a number or to NaN if it cannot be converted
  31632. * @returns number
  31633. */
  31634. static FloatRound(value: number): number;
  31635. /**
  31636. * Find the next highest power of two.
  31637. * @param x Number to start search from.
  31638. * @return Next highest power of two.
  31639. */
  31640. static CeilingPOT(x: number): number;
  31641. /**
  31642. * Find the next lowest power of two.
  31643. * @param x Number to start search from.
  31644. * @return Next lowest power of two.
  31645. */
  31646. static FloorPOT(x: number): number;
  31647. /**
  31648. * Find the nearest power of two.
  31649. * @param x Number to start search from.
  31650. * @return Next nearest power of two.
  31651. */
  31652. static NearestPOT(x: number): number;
  31653. /**
  31654. * Get the closest exponent of two
  31655. * @param value defines the value to approximate
  31656. * @param max defines the maximum value to return
  31657. * @param mode defines how to define the closest value
  31658. * @returns closest exponent of two of the given value
  31659. */
  31660. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31661. /**
  31662. * Extracts the filename from a path
  31663. * @param path defines the path to use
  31664. * @returns the filename
  31665. */
  31666. static GetFilename(path: string): string;
  31667. /**
  31668. * Extracts the "folder" part of a path (everything before the filename).
  31669. * @param uri The URI to extract the info from
  31670. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31671. * @returns The "folder" part of the path
  31672. */
  31673. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31674. /**
  31675. * Extracts text content from a DOM element hierarchy
  31676. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31677. */
  31678. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31679. /**
  31680. * Convert an angle in radians to degrees
  31681. * @param angle defines the angle to convert
  31682. * @returns the angle in degrees
  31683. */
  31684. static ToDegrees(angle: number): number;
  31685. /**
  31686. * Convert an angle in degrees to radians
  31687. * @param angle defines the angle to convert
  31688. * @returns the angle in radians
  31689. */
  31690. static ToRadians(angle: number): number;
  31691. /**
  31692. * Encode a buffer to a base64 string
  31693. * @param buffer defines the buffer to encode
  31694. * @returns the encoded string
  31695. */
  31696. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31697. /**
  31698. * Extracts minimum and maximum values from a list of indexed positions
  31699. * @param positions defines the positions to use
  31700. * @param indices defines the indices to the positions
  31701. * @param indexStart defines the start index
  31702. * @param indexCount defines the end index
  31703. * @param bias defines bias value to add to the result
  31704. * @return minimum and maximum values
  31705. */
  31706. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31707. minimum: Vector3;
  31708. maximum: Vector3;
  31709. };
  31710. /**
  31711. * Extracts minimum and maximum values from a list of positions
  31712. * @param positions defines the positions to use
  31713. * @param start defines the start index in the positions array
  31714. * @param count defines the number of positions to handle
  31715. * @param bias defines bias value to add to the result
  31716. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31717. * @return minimum and maximum values
  31718. */
  31719. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31720. minimum: Vector3;
  31721. maximum: Vector3;
  31722. };
  31723. /**
  31724. * Returns an array if obj is not an array
  31725. * @param obj defines the object to evaluate as an array
  31726. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31727. * @returns either obj directly if obj is an array or a new array containing obj
  31728. */
  31729. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31730. /**
  31731. * Gets the pointer prefix to use
  31732. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31733. */
  31734. static GetPointerPrefix(): string;
  31735. /**
  31736. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31737. * @param func - the function to be called
  31738. * @param requester - the object that will request the next frame. Falls back to window.
  31739. * @returns frame number
  31740. */
  31741. static QueueNewFrame(func: () => void, requester?: any): number;
  31742. /**
  31743. * Ask the browser to promote the current element to fullscreen rendering mode
  31744. * @param element defines the DOM element to promote
  31745. */
  31746. static RequestFullscreen(element: HTMLElement): void;
  31747. /**
  31748. * Asks the browser to exit fullscreen mode
  31749. */
  31750. static ExitFullscreen(): void;
  31751. /**
  31752. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31753. * @param url define the url we are trying
  31754. * @param element define the dom element where to configure the cors policy
  31755. */
  31756. static SetCorsBehavior(url: string | string[], element: {
  31757. crossOrigin: string | null;
  31758. }): void;
  31759. /**
  31760. * Removes unwanted characters from an url
  31761. * @param url defines the url to clean
  31762. * @returns the cleaned url
  31763. */
  31764. static CleanUrl(url: string): string;
  31765. /**
  31766. * Gets or sets a function used to pre-process url before using them to load assets
  31767. */
  31768. static PreprocessUrl: (url: string) => string;
  31769. /**
  31770. * Loads an image as an HTMLImageElement.
  31771. * @param input url string, ArrayBuffer, or Blob to load
  31772. * @param onLoad callback called when the image successfully loads
  31773. * @param onError callback called when the image fails to load
  31774. * @param offlineProvider offline provider for caching
  31775. * @returns the HTMLImageElement of the loaded image
  31776. */
  31777. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31778. /**
  31779. * Loads a file
  31780. * @param url url string, ArrayBuffer, or Blob to load
  31781. * @param onSuccess callback called when the file successfully loads
  31782. * @param onProgress callback called while file is loading (if the server supports this mode)
  31783. * @param offlineProvider defines the offline provider for caching
  31784. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31785. * @param onError callback called when the file fails to load
  31786. * @returns a file request object
  31787. */
  31788. 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;
  31789. /**
  31790. * Load a script (identified by an url). When the url returns, the
  31791. * content of this file is added into a new script element, attached to the DOM (body element)
  31792. * @param scriptUrl defines the url of the script to laod
  31793. * @param onSuccess defines the callback called when the script is loaded
  31794. * @param onError defines the callback to call if an error occurs
  31795. * @param scriptId defines the id of the script element
  31796. */
  31797. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31798. /**
  31799. * Load an asynchronous script (identified by an url). When the url returns, the
  31800. * content of this file is added into a new script element, attached to the DOM (body element)
  31801. * @param scriptUrl defines the url of the script to laod
  31802. * @param scriptId defines the id of the script element
  31803. * @returns a promise request object
  31804. */
  31805. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31806. /**
  31807. * Loads a file from a blob
  31808. * @param fileToLoad defines the blob to use
  31809. * @param callback defines the callback to call when data is loaded
  31810. * @param progressCallback defines the callback to call during loading process
  31811. * @returns a file request object
  31812. */
  31813. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31814. /**
  31815. * Loads a file
  31816. * @param fileToLoad defines the file to load
  31817. * @param callback defines the callback to call when data is loaded
  31818. * @param progressCallBack defines the callback to call during loading process
  31819. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31820. * @returns a file request object
  31821. */
  31822. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31823. /**
  31824. * Creates a data url from a given string content
  31825. * @param content defines the content to convert
  31826. * @returns the new data url link
  31827. */
  31828. static FileAsURL(content: string): string;
  31829. /**
  31830. * Format the given number to a specific decimal format
  31831. * @param value defines the number to format
  31832. * @param decimals defines the number of decimals to use
  31833. * @returns the formatted string
  31834. */
  31835. static Format(value: number, decimals?: number): string;
  31836. /**
  31837. * Checks if a given vector is inside a specific range
  31838. * @param v defines the vector to test
  31839. * @param min defines the minimum range
  31840. * @param max defines the maximum range
  31841. */
  31842. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31843. /**
  31844. * Tries to copy an object by duplicating every property
  31845. * @param source defines the source object
  31846. * @param destination defines the target object
  31847. * @param doNotCopyList defines a list of properties to avoid
  31848. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31849. */
  31850. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31851. /**
  31852. * Gets a boolean indicating if the given object has no own property
  31853. * @param obj defines the object to test
  31854. * @returns true if object has no own property
  31855. */
  31856. static IsEmpty(obj: any): boolean;
  31857. /**
  31858. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31859. * @param str Source string
  31860. * @param suffix Suffix to search for in the source string
  31861. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31862. */
  31863. static EndsWith(str: string, suffix: string): boolean;
  31864. /**
  31865. * Function used to register events at window level
  31866. * @param events defines the events to register
  31867. */
  31868. static RegisterTopRootEvents(events: {
  31869. name: string;
  31870. handler: Nullable<(e: FocusEvent) => any>;
  31871. }[]): void;
  31872. /**
  31873. * Function used to unregister events from window level
  31874. * @param events defines the events to unregister
  31875. */
  31876. static UnregisterTopRootEvents(events: {
  31877. name: string;
  31878. handler: Nullable<(e: FocusEvent) => any>;
  31879. }[]): void;
  31880. /**
  31881. * @ignore
  31882. */
  31883. static _ScreenshotCanvas: HTMLCanvasElement;
  31884. /**
  31885. * Dumps the current bound framebuffer
  31886. * @param width defines the rendering width
  31887. * @param height defines the rendering height
  31888. * @param engine defines the hosting engine
  31889. * @param successCallback defines the callback triggered once the data are available
  31890. * @param mimeType defines the mime type of the result
  31891. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31892. */
  31893. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31894. /**
  31895. * Converts the canvas data to blob.
  31896. * This acts as a polyfill for browsers not supporting the to blob function.
  31897. * @param canvas Defines the canvas to extract the data from
  31898. * @param successCallback Defines the callback triggered once the data are available
  31899. * @param mimeType Defines the mime type of the result
  31900. */
  31901. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31902. /**
  31903. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31904. * @param successCallback defines the callback triggered once the data are available
  31905. * @param mimeType defines the mime type of the result
  31906. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31907. */
  31908. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31909. /**
  31910. * Downloads a blob in the browser
  31911. * @param blob defines the blob to download
  31912. * @param fileName defines the name of the downloaded file
  31913. */
  31914. static Download(blob: Blob, fileName: string): void;
  31915. /**
  31916. * Captures a screenshot of the current rendering
  31917. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31918. * @param engine defines the rendering engine
  31919. * @param camera defines the source camera
  31920. * @param size This parameter can be set to a single number or to an object with the
  31921. * following (optional) properties: precision, width, height. If a single number is passed,
  31922. * it will be used for both width and height. If an object is passed, the screenshot size
  31923. * will be derived from the parameters. The precision property is a multiplier allowing
  31924. * rendering at a higher or lower resolution
  31925. * @param successCallback defines the callback receives a single parameter which contains the
  31926. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31927. * src parameter of an <img> to display it
  31928. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31929. * Check your browser for supported MIME types
  31930. */
  31931. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31932. /**
  31933. * Generates an image screenshot from the specified camera.
  31934. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31935. * @param engine The engine to use for rendering
  31936. * @param camera The camera to use for rendering
  31937. * @param size This parameter can be set to a single number or to an object with the
  31938. * following (optional) properties: precision, width, height. If a single number is passed,
  31939. * it will be used for both width and height. If an object is passed, the screenshot size
  31940. * will be derived from the parameters. The precision property is a multiplier allowing
  31941. * rendering at a higher or lower resolution
  31942. * @param successCallback The callback receives a single parameter which contains the
  31943. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31944. * src parameter of an <img> to display it
  31945. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31946. * Check your browser for supported MIME types
  31947. * @param samples Texture samples (default: 1)
  31948. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31949. * @param fileName A name for for the downloaded file.
  31950. */
  31951. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31952. /**
  31953. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31954. * Be aware Math.random() could cause collisions, but:
  31955. * "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"
  31956. * @returns a pseudo random id
  31957. */
  31958. static RandomId(): string;
  31959. /**
  31960. * Test if the given uri is a base64 string
  31961. * @param uri The uri to test
  31962. * @return True if the uri is a base64 string or false otherwise
  31963. */
  31964. static IsBase64(uri: string): boolean;
  31965. /**
  31966. * Decode the given base64 uri.
  31967. * @param uri The uri to decode
  31968. * @return The decoded base64 data.
  31969. */
  31970. static DecodeBase64(uri: string): ArrayBuffer;
  31971. /**
  31972. * Gets the absolute url.
  31973. * @param url the input url
  31974. * @return the absolute url
  31975. */
  31976. static GetAbsoluteUrl(url: string): string;
  31977. /**
  31978. * No log
  31979. */
  31980. static readonly NoneLogLevel: number;
  31981. /**
  31982. * Only message logs
  31983. */
  31984. static readonly MessageLogLevel: number;
  31985. /**
  31986. * Only warning logs
  31987. */
  31988. static readonly WarningLogLevel: number;
  31989. /**
  31990. * Only error logs
  31991. */
  31992. static readonly ErrorLogLevel: number;
  31993. /**
  31994. * All logs
  31995. */
  31996. static readonly AllLogLevel: number;
  31997. /**
  31998. * Gets a value indicating the number of loading errors
  31999. * @ignorenaming
  32000. */
  32001. static readonly errorsCount: number;
  32002. /**
  32003. * Callback called when a new log is added
  32004. */
  32005. static OnNewCacheEntry: (entry: string) => void;
  32006. /**
  32007. * Log a message to the console
  32008. * @param message defines the message to log
  32009. */
  32010. static Log(message: string): void;
  32011. /**
  32012. * Write a warning message to the console
  32013. * @param message defines the message to log
  32014. */
  32015. static Warn(message: string): void;
  32016. /**
  32017. * Write an error message to the console
  32018. * @param message defines the message to log
  32019. */
  32020. static Error(message: string): void;
  32021. /**
  32022. * Gets current log cache (list of logs)
  32023. */
  32024. static readonly LogCache: string;
  32025. /**
  32026. * Clears the log cache
  32027. */
  32028. static ClearLogCache(): void;
  32029. /**
  32030. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32031. */
  32032. static LogLevels: number;
  32033. /**
  32034. * Checks if the loaded document was accessed via `file:`-Protocol.
  32035. * @returns boolean
  32036. */
  32037. static IsFileURL(): boolean;
  32038. /**
  32039. * Checks if the window object exists
  32040. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32041. */
  32042. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32043. /**
  32044. * No performance log
  32045. */
  32046. static readonly PerformanceNoneLogLevel: number;
  32047. /**
  32048. * Use user marks to log performance
  32049. */
  32050. static readonly PerformanceUserMarkLogLevel: number;
  32051. /**
  32052. * Log performance to the console
  32053. */
  32054. static readonly PerformanceConsoleLogLevel: number;
  32055. private static _performance;
  32056. /**
  32057. * Sets the current performance log level
  32058. */
  32059. static PerformanceLogLevel: number;
  32060. private static _StartPerformanceCounterDisabled;
  32061. private static _EndPerformanceCounterDisabled;
  32062. private static _StartUserMark;
  32063. private static _EndUserMark;
  32064. private static _StartPerformanceConsole;
  32065. private static _EndPerformanceConsole;
  32066. /**
  32067. * Starts a performance counter
  32068. */
  32069. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32070. /**
  32071. * Ends a specific performance coutner
  32072. */
  32073. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32074. /**
  32075. * Gets either window.performance.now() if supported or Date.now() else
  32076. */
  32077. static readonly Now: number;
  32078. /**
  32079. * This method will return the name of the class used to create the instance of the given object.
  32080. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32081. * @param object the object to get the class name from
  32082. * @param isType defines if the object is actually a type
  32083. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32084. */
  32085. static GetClassName(object: any, isType?: boolean): string;
  32086. /**
  32087. * Gets the first element of an array satisfying a given predicate
  32088. * @param array defines the array to browse
  32089. * @param predicate defines the predicate to use
  32090. * @returns null if not found or the element
  32091. */
  32092. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32093. /**
  32094. * This method will return the name of the full name of the class, including its owning module (if any).
  32095. * 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).
  32096. * @param object the object to get the class name from
  32097. * @param isType defines if the object is actually a type
  32098. * @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.
  32099. * @ignorenaming
  32100. */
  32101. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32102. /**
  32103. * Returns a promise that resolves after the given amount of time.
  32104. * @param delay Number of milliseconds to delay
  32105. * @returns Promise that resolves after the given amount of time
  32106. */
  32107. static DelayAsync(delay: number): Promise<void>;
  32108. /**
  32109. * Gets the current gradient from an array of IValueGradient
  32110. * @param ratio defines the current ratio to get
  32111. * @param gradients defines the array of IValueGradient
  32112. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32113. */
  32114. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32115. }
  32116. /**
  32117. * This class is used to track a performance counter which is number based.
  32118. * The user has access to many properties which give statistics of different nature.
  32119. *
  32120. * The implementer can track two kinds of Performance Counter: time and count.
  32121. * 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.
  32122. * 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.
  32123. */
  32124. export class PerfCounter {
  32125. /**
  32126. * Gets or sets a global boolean to turn on and off all the counters
  32127. */
  32128. static Enabled: boolean;
  32129. /**
  32130. * Returns the smallest value ever
  32131. */
  32132. readonly min: number;
  32133. /**
  32134. * Returns the biggest value ever
  32135. */
  32136. readonly max: number;
  32137. /**
  32138. * Returns the average value since the performance counter is running
  32139. */
  32140. readonly average: number;
  32141. /**
  32142. * Returns the average value of the last second the counter was monitored
  32143. */
  32144. readonly lastSecAverage: number;
  32145. /**
  32146. * Returns the current value
  32147. */
  32148. readonly current: number;
  32149. /**
  32150. * Gets the accumulated total
  32151. */
  32152. readonly total: number;
  32153. /**
  32154. * Gets the total value count
  32155. */
  32156. readonly count: number;
  32157. /**
  32158. * Creates a new counter
  32159. */
  32160. constructor();
  32161. /**
  32162. * Call this method to start monitoring a new frame.
  32163. * 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.
  32164. */
  32165. fetchNewFrame(): void;
  32166. /**
  32167. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32168. * @param newCount the count value to add to the monitored count
  32169. * @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.
  32170. */
  32171. addCount(newCount: number, fetchResult: boolean): void;
  32172. /**
  32173. * Start monitoring this performance counter
  32174. */
  32175. beginMonitoring(): void;
  32176. /**
  32177. * Compute the time lapsed since the previous beginMonitoring() call.
  32178. * @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
  32179. */
  32180. endMonitoring(newFrame?: boolean): void;
  32181. private _fetchResult;
  32182. private _startMonitoringTime;
  32183. private _min;
  32184. private _max;
  32185. private _average;
  32186. private _current;
  32187. private _totalValueCount;
  32188. private _totalAccumulated;
  32189. private _lastSecAverage;
  32190. private _lastSecAccumulated;
  32191. private _lastSecTime;
  32192. private _lastSecValueCount;
  32193. }
  32194. /**
  32195. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32196. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32197. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32198. * @param name The name of the class, case should be preserved
  32199. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32200. */
  32201. export function className(name: string, module?: string): (target: Object) => void;
  32202. /**
  32203. * An implementation of a loop for asynchronous functions.
  32204. */
  32205. export class AsyncLoop {
  32206. /**
  32207. * Defines the number of iterations for the loop
  32208. */
  32209. iterations: number;
  32210. /**
  32211. * Defines the current index of the loop.
  32212. */
  32213. index: number;
  32214. private _done;
  32215. private _fn;
  32216. private _successCallback;
  32217. /**
  32218. * Constructor.
  32219. * @param iterations the number of iterations.
  32220. * @param func the function to run each iteration
  32221. * @param successCallback the callback that will be called upon succesful execution
  32222. * @param offset starting offset.
  32223. */
  32224. constructor(
  32225. /**
  32226. * Defines the number of iterations for the loop
  32227. */
  32228. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32229. /**
  32230. * Execute the next iteration. Must be called after the last iteration was finished.
  32231. */
  32232. executeNext(): void;
  32233. /**
  32234. * Break the loop and run the success callback.
  32235. */
  32236. breakLoop(): void;
  32237. /**
  32238. * Create and run an async loop.
  32239. * @param iterations the number of iterations.
  32240. * @param fn the function to run each iteration
  32241. * @param successCallback the callback that will be called upon succesful execution
  32242. * @param offset starting offset.
  32243. * @returns the created async loop object
  32244. */
  32245. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32246. /**
  32247. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32248. * @param iterations total number of iterations
  32249. * @param syncedIterations number of synchronous iterations in each async iteration.
  32250. * @param fn the function to call each iteration.
  32251. * @param callback a success call back that will be called when iterating stops.
  32252. * @param breakFunction a break condition (optional)
  32253. * @param timeout timeout settings for the setTimeout function. default - 0.
  32254. * @returns the created async loop object
  32255. */
  32256. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32257. }
  32258. }
  32259. declare module "babylonjs/Collisions/collisionCoordinator" {
  32260. import { Nullable } from "babylonjs/types";
  32261. import { Scene } from "babylonjs/scene";
  32262. import { Vector3 } from "babylonjs/Maths/math";
  32263. import { Collider } from "babylonjs/Collisions/collider";
  32264. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32265. /** @hidden */
  32266. export interface ICollisionCoordinator {
  32267. createCollider(): Collider;
  32268. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32269. init(scene: Scene): void;
  32270. }
  32271. /** @hidden */
  32272. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32273. private _scene;
  32274. private _scaledPosition;
  32275. private _scaledVelocity;
  32276. private _finalPosition;
  32277. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32278. createCollider(): Collider;
  32279. init(scene: Scene): void;
  32280. private _collideWithWorld;
  32281. }
  32282. }
  32283. declare module "babylonjs/Animations/animationGroup" {
  32284. import { Animatable } from "babylonjs/Animations/animatable";
  32285. import { Animation } from "babylonjs/Animations/animation";
  32286. import { Scene, IDisposable } from "babylonjs/scene";
  32287. import { Observable } from "babylonjs/Misc/observable";
  32288. import { Nullable } from "babylonjs/types";
  32289. /**
  32290. * This class defines the direct association between an animation and a target
  32291. */
  32292. export class TargetedAnimation {
  32293. /**
  32294. * Animation to perform
  32295. */
  32296. animation: Animation;
  32297. /**
  32298. * Target to animate
  32299. */
  32300. target: any;
  32301. }
  32302. /**
  32303. * Use this class to create coordinated animations on multiple targets
  32304. */
  32305. export class AnimationGroup implements IDisposable {
  32306. /** The name of the animation group */
  32307. name: string;
  32308. private _scene;
  32309. private _targetedAnimations;
  32310. private _animatables;
  32311. private _from;
  32312. private _to;
  32313. private _isStarted;
  32314. private _isPaused;
  32315. private _speedRatio;
  32316. /**
  32317. * Gets or sets the unique id of the node
  32318. */
  32319. uniqueId: number;
  32320. /**
  32321. * This observable will notify when one animation have ended
  32322. */
  32323. onAnimationEndObservable: Observable<TargetedAnimation>;
  32324. /**
  32325. * Observer raised when one animation loops
  32326. */
  32327. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32328. /**
  32329. * This observable will notify when all animations have ended.
  32330. */
  32331. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32332. /**
  32333. * This observable will notify when all animations have paused.
  32334. */
  32335. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32336. /**
  32337. * This observable will notify when all animations are playing.
  32338. */
  32339. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32340. /**
  32341. * Gets the first frame
  32342. */
  32343. readonly from: number;
  32344. /**
  32345. * Gets the last frame
  32346. */
  32347. readonly to: number;
  32348. /**
  32349. * Define if the animations are started
  32350. */
  32351. readonly isStarted: boolean;
  32352. /**
  32353. * Gets a value indicating that the current group is playing
  32354. */
  32355. readonly isPlaying: boolean;
  32356. /**
  32357. * Gets or sets the speed ratio to use for all animations
  32358. */
  32359. /**
  32360. * Gets or sets the speed ratio to use for all animations
  32361. */
  32362. speedRatio: number;
  32363. /**
  32364. * Gets the targeted animations for this animation group
  32365. */
  32366. readonly targetedAnimations: Array<TargetedAnimation>;
  32367. /**
  32368. * returning the list of animatables controlled by this animation group.
  32369. */
  32370. readonly animatables: Array<Animatable>;
  32371. /**
  32372. * Instantiates a new Animation Group.
  32373. * This helps managing several animations at once.
  32374. * @see http://doc.babylonjs.com/how_to/group
  32375. * @param name Defines the name of the group
  32376. * @param scene Defines the scene the group belongs to
  32377. */
  32378. constructor(
  32379. /** The name of the animation group */
  32380. name: string, scene?: Nullable<Scene>);
  32381. /**
  32382. * Add an animation (with its target) in the group
  32383. * @param animation defines the animation we want to add
  32384. * @param target defines the target of the animation
  32385. * @returns the TargetedAnimation object
  32386. */
  32387. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32388. /**
  32389. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32390. * It can add constant keys at begin or end
  32391. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32392. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32393. * @returns the animation group
  32394. */
  32395. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32396. /**
  32397. * Start all animations on given targets
  32398. * @param loop defines if animations must loop
  32399. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32400. * @param from defines the from key (optional)
  32401. * @param to defines the to key (optional)
  32402. * @returns the current animation group
  32403. */
  32404. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32405. /**
  32406. * Pause all animations
  32407. * @returns the animation group
  32408. */
  32409. pause(): AnimationGroup;
  32410. /**
  32411. * Play all animations to initial state
  32412. * This function will start() the animations if they were not started or will restart() them if they were paused
  32413. * @param loop defines if animations must loop
  32414. * @returns the animation group
  32415. */
  32416. play(loop?: boolean): AnimationGroup;
  32417. /**
  32418. * Reset all animations to initial state
  32419. * @returns the animation group
  32420. */
  32421. reset(): AnimationGroup;
  32422. /**
  32423. * Restart animations from key 0
  32424. * @returns the animation group
  32425. */
  32426. restart(): AnimationGroup;
  32427. /**
  32428. * Stop all animations
  32429. * @returns the animation group
  32430. */
  32431. stop(): AnimationGroup;
  32432. /**
  32433. * Set animation weight for all animatables
  32434. * @param weight defines the weight to use
  32435. * @return the animationGroup
  32436. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32437. */
  32438. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32439. /**
  32440. * Synchronize and normalize all animatables with a source animatable
  32441. * @param root defines the root animatable to synchronize with
  32442. * @return the animationGroup
  32443. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32444. */
  32445. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32446. /**
  32447. * Goes to a specific frame in this animation group
  32448. * @param frame the frame number to go to
  32449. * @return the animationGroup
  32450. */
  32451. goToFrame(frame: number): AnimationGroup;
  32452. /**
  32453. * Dispose all associated resources
  32454. */
  32455. dispose(): void;
  32456. private _checkAnimationGroupEnded;
  32457. /**
  32458. * Clone the current animation group and returns a copy
  32459. * @param newName defines the name of the new group
  32460. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32461. * @returns the new aniamtion group
  32462. */
  32463. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32464. /**
  32465. * Returns a new AnimationGroup object parsed from the source provided.
  32466. * @param parsedAnimationGroup defines the source
  32467. * @param scene defines the scene that will receive the animationGroup
  32468. * @returns a new AnimationGroup
  32469. */
  32470. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32471. /**
  32472. * Returns the string "AnimationGroup"
  32473. * @returns "AnimationGroup"
  32474. */
  32475. getClassName(): string;
  32476. /**
  32477. * Creates a detailled string about the object
  32478. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32479. * @returns a string representing the object
  32480. */
  32481. toString(fullDetails?: boolean): string;
  32482. }
  32483. }
  32484. declare module "babylonjs/scene" {
  32485. import { Nullable } from "babylonjs/types";
  32486. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32487. import { Observable } from "babylonjs/Misc/observable";
  32488. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32489. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32490. import { Geometry } from "babylonjs/Meshes/geometry";
  32491. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32492. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32494. import { Mesh } from "babylonjs/Meshes/mesh";
  32495. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32496. import { Bone } from "babylonjs/Bones/bone";
  32497. import { Skeleton } from "babylonjs/Bones/skeleton";
  32498. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32499. import { Camera } from "babylonjs/Cameras/camera";
  32500. import { AbstractScene } from "babylonjs/abstractScene";
  32501. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32502. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32503. import { Material } from "babylonjs/Materials/material";
  32504. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32505. import { Effect } from "babylonjs/Materials/effect";
  32506. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32507. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32508. import { Light } from "babylonjs/Lights/light";
  32509. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32510. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32511. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32512. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32513. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32514. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32515. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32516. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32517. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  32518. import { Engine } from "babylonjs/Engines/engine";
  32519. import { Node } from "babylonjs/node";
  32520. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32521. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32522. import { WebRequest } from "babylonjs/Misc/webRequest";
  32523. import { Ray } from "babylonjs/Culling/ray";
  32524. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32525. import { Animation } from "babylonjs/Animations/animation";
  32526. import { Animatable } from "babylonjs/Animations/animatable";
  32527. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32528. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32529. import { Collider } from "babylonjs/Collisions/collider";
  32530. /**
  32531. * Define an interface for all classes that will hold resources
  32532. */
  32533. export interface IDisposable {
  32534. /**
  32535. * Releases all held resources
  32536. */
  32537. dispose(): void;
  32538. }
  32539. /** Interface defining initialization parameters for Scene class */
  32540. export interface SceneOptions {
  32541. /**
  32542. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32543. * It will improve performance when the number of geometries becomes important.
  32544. */
  32545. useGeometryUniqueIdsMap?: boolean;
  32546. /**
  32547. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32548. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32549. */
  32550. useMaterialMeshMap?: boolean;
  32551. /**
  32552. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32553. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32554. */
  32555. useClonedMeshhMap?: boolean;
  32556. }
  32557. /**
  32558. * Represents a scene to be rendered by the engine.
  32559. * @see http://doc.babylonjs.com/features/scene
  32560. */
  32561. export class Scene extends AbstractScene implements IAnimatable {
  32562. private static _uniqueIdCounter;
  32563. /** The fog is deactivated */
  32564. static readonly FOGMODE_NONE: number;
  32565. /** The fog density is following an exponential function */
  32566. static readonly FOGMODE_EXP: number;
  32567. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32568. static readonly FOGMODE_EXP2: number;
  32569. /** The fog density is following a linear function. */
  32570. static readonly FOGMODE_LINEAR: number;
  32571. /**
  32572. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32573. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32574. */
  32575. static MinDeltaTime: number;
  32576. /**
  32577. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32578. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32579. */
  32580. static MaxDeltaTime: number;
  32581. /**
  32582. * Factory used to create the default material.
  32583. * @param name The name of the material to create
  32584. * @param scene The scene to create the material for
  32585. * @returns The default material
  32586. */
  32587. static DefaultMaterialFactory(scene: Scene): Material;
  32588. /**
  32589. * Factory used to create the a collision coordinator.
  32590. * @returns The collision coordinator
  32591. */
  32592. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32593. /** @hidden */
  32594. readonly _isScene: boolean;
  32595. /**
  32596. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32597. */
  32598. autoClear: boolean;
  32599. /**
  32600. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32601. */
  32602. autoClearDepthAndStencil: boolean;
  32603. /**
  32604. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32605. */
  32606. clearColor: Color4;
  32607. /**
  32608. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32609. */
  32610. ambientColor: Color3;
  32611. /**
  32612. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32613. * It should only be one of the following (if not the default embedded one):
  32614. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32615. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32616. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32617. * The material properties need to be setup according to the type of texture in use.
  32618. */
  32619. environmentBRDFTexture: BaseTexture;
  32620. /** @hidden */
  32621. protected _environmentTexture: Nullable<BaseTexture>;
  32622. /**
  32623. * Texture used in all pbr material as the reflection texture.
  32624. * As in the majority of the scene they are the same (exception for multi room and so on),
  32625. * this is easier to reference from here than from all the materials.
  32626. */
  32627. /**
  32628. * Texture used in all pbr material as the reflection texture.
  32629. * As in the majority of the scene they are the same (exception for multi room and so on),
  32630. * this is easier to set here than in all the materials.
  32631. */
  32632. environmentTexture: Nullable<BaseTexture>;
  32633. /** @hidden */
  32634. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32635. /**
  32636. * Default image processing configuration used either in the rendering
  32637. * Forward main pass or through the imageProcessingPostProcess if present.
  32638. * As in the majority of the scene they are the same (exception for multi camera),
  32639. * this is easier to reference from here than from all the materials and post process.
  32640. *
  32641. * No setter as we it is a shared configuration, you can set the values instead.
  32642. */
  32643. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32644. private _forceWireframe;
  32645. /**
  32646. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32647. */
  32648. forceWireframe: boolean;
  32649. private _forcePointsCloud;
  32650. /**
  32651. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32652. */
  32653. forcePointsCloud: boolean;
  32654. /**
  32655. * Gets or sets the active clipplane 1
  32656. */
  32657. clipPlane: Nullable<Plane>;
  32658. /**
  32659. * Gets or sets the active clipplane 2
  32660. */
  32661. clipPlane2: Nullable<Plane>;
  32662. /**
  32663. * Gets or sets the active clipplane 3
  32664. */
  32665. clipPlane3: Nullable<Plane>;
  32666. /**
  32667. * Gets or sets the active clipplane 4
  32668. */
  32669. clipPlane4: Nullable<Plane>;
  32670. /**
  32671. * Gets or sets a boolean indicating if animations are enabled
  32672. */
  32673. animationsEnabled: boolean;
  32674. private _animationPropertiesOverride;
  32675. /**
  32676. * Gets or sets the animation properties override
  32677. */
  32678. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32679. /**
  32680. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32681. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32682. */
  32683. useConstantAnimationDeltaTime: boolean;
  32684. /**
  32685. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32686. * Please note that it requires to run a ray cast through the scene on every frame
  32687. */
  32688. constantlyUpdateMeshUnderPointer: boolean;
  32689. /**
  32690. * Defines the HTML cursor to use when hovering over interactive elements
  32691. */
  32692. hoverCursor: string;
  32693. /**
  32694. * Defines the HTML default cursor to use (empty by default)
  32695. */
  32696. defaultCursor: string;
  32697. /**
  32698. * This is used to call preventDefault() on pointer down
  32699. * in order to block unwanted artifacts like system double clicks
  32700. */
  32701. preventDefaultOnPointerDown: boolean;
  32702. /**
  32703. * This is used to call preventDefault() on pointer up
  32704. * in order to block unwanted artifacts like system double clicks
  32705. */
  32706. preventDefaultOnPointerUp: boolean;
  32707. /**
  32708. * Gets or sets user defined metadata
  32709. */
  32710. metadata: any;
  32711. /**
  32712. * For internal use only. Please do not use.
  32713. */
  32714. reservedDataStore: any;
  32715. /**
  32716. * Gets the name of the plugin used to load this scene (null by default)
  32717. */
  32718. loadingPluginName: string;
  32719. /**
  32720. * Use this array to add regular expressions used to disable offline support for specific urls
  32721. */
  32722. disableOfflineSupportExceptionRules: RegExp[];
  32723. /**
  32724. * An event triggered when the scene is disposed.
  32725. */
  32726. onDisposeObservable: Observable<Scene>;
  32727. private _onDisposeObserver;
  32728. /** Sets a function to be executed when this scene is disposed. */
  32729. onDispose: () => void;
  32730. /**
  32731. * An event triggered before rendering the scene (right after animations and physics)
  32732. */
  32733. onBeforeRenderObservable: Observable<Scene>;
  32734. private _onBeforeRenderObserver;
  32735. /** Sets a function to be executed before rendering this scene */
  32736. beforeRender: Nullable<() => void>;
  32737. /**
  32738. * An event triggered after rendering the scene
  32739. */
  32740. onAfterRenderObservable: Observable<Scene>;
  32741. private _onAfterRenderObserver;
  32742. /** Sets a function to be executed after rendering this scene */
  32743. afterRender: Nullable<() => void>;
  32744. /**
  32745. * An event triggered before animating the scene
  32746. */
  32747. onBeforeAnimationsObservable: Observable<Scene>;
  32748. /**
  32749. * An event triggered after animations processing
  32750. */
  32751. onAfterAnimationsObservable: Observable<Scene>;
  32752. /**
  32753. * An event triggered before draw calls are ready to be sent
  32754. */
  32755. onBeforeDrawPhaseObservable: Observable<Scene>;
  32756. /**
  32757. * An event triggered after draw calls have been sent
  32758. */
  32759. onAfterDrawPhaseObservable: Observable<Scene>;
  32760. /**
  32761. * An event triggered when the scene is ready
  32762. */
  32763. onReadyObservable: Observable<Scene>;
  32764. /**
  32765. * An event triggered before rendering a camera
  32766. */
  32767. onBeforeCameraRenderObservable: Observable<Camera>;
  32768. private _onBeforeCameraRenderObserver;
  32769. /** Sets a function to be executed before rendering a camera*/
  32770. beforeCameraRender: () => void;
  32771. /**
  32772. * An event triggered after rendering a camera
  32773. */
  32774. onAfterCameraRenderObservable: Observable<Camera>;
  32775. private _onAfterCameraRenderObserver;
  32776. /** Sets a function to be executed after rendering a camera*/
  32777. afterCameraRender: () => void;
  32778. /**
  32779. * An event triggered when active meshes evaluation is about to start
  32780. */
  32781. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32782. /**
  32783. * An event triggered when active meshes evaluation is done
  32784. */
  32785. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32786. /**
  32787. * An event triggered when particles rendering is about to start
  32788. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32789. */
  32790. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32791. /**
  32792. * An event triggered when particles rendering is done
  32793. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32794. */
  32795. onAfterParticlesRenderingObservable: Observable<Scene>;
  32796. /**
  32797. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32798. */
  32799. onDataLoadedObservable: Observable<Scene>;
  32800. /**
  32801. * An event triggered when a camera is created
  32802. */
  32803. onNewCameraAddedObservable: Observable<Camera>;
  32804. /**
  32805. * An event triggered when a camera is removed
  32806. */
  32807. onCameraRemovedObservable: Observable<Camera>;
  32808. /**
  32809. * An event triggered when a light is created
  32810. */
  32811. onNewLightAddedObservable: Observable<Light>;
  32812. /**
  32813. * An event triggered when a light is removed
  32814. */
  32815. onLightRemovedObservable: Observable<Light>;
  32816. /**
  32817. * An event triggered when a geometry is created
  32818. */
  32819. onNewGeometryAddedObservable: Observable<Geometry>;
  32820. /**
  32821. * An event triggered when a geometry is removed
  32822. */
  32823. onGeometryRemovedObservable: Observable<Geometry>;
  32824. /**
  32825. * An event triggered when a transform node is created
  32826. */
  32827. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32828. /**
  32829. * An event triggered when a transform node is removed
  32830. */
  32831. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32832. /**
  32833. * An event triggered when a mesh is created
  32834. */
  32835. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32836. /**
  32837. * An event triggered when a mesh is removed
  32838. */
  32839. onMeshRemovedObservable: Observable<AbstractMesh>;
  32840. /**
  32841. * An event triggered when a skeleton is created
  32842. */
  32843. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32844. /**
  32845. * An event triggered when a skeleton is removed
  32846. */
  32847. onSkeletonRemovedObservable: Observable<Skeleton>;
  32848. /**
  32849. * An event triggered when a material is created
  32850. */
  32851. onNewMaterialAddedObservable: Observable<Material>;
  32852. /**
  32853. * An event triggered when a material is removed
  32854. */
  32855. onMaterialRemovedObservable: Observable<Material>;
  32856. /**
  32857. * An event triggered when a texture is created
  32858. */
  32859. onNewTextureAddedObservable: Observable<BaseTexture>;
  32860. /**
  32861. * An event triggered when a texture is removed
  32862. */
  32863. onTextureRemovedObservable: Observable<BaseTexture>;
  32864. /**
  32865. * An event triggered when render targets are about to be rendered
  32866. * Can happen multiple times per frame.
  32867. */
  32868. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32869. /**
  32870. * An event triggered when render targets were rendered.
  32871. * Can happen multiple times per frame.
  32872. */
  32873. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32874. /**
  32875. * An event triggered before calculating deterministic simulation step
  32876. */
  32877. onBeforeStepObservable: Observable<Scene>;
  32878. /**
  32879. * An event triggered after calculating deterministic simulation step
  32880. */
  32881. onAfterStepObservable: Observable<Scene>;
  32882. /**
  32883. * An event triggered when the activeCamera property is updated
  32884. */
  32885. onActiveCameraChanged: Observable<Scene>;
  32886. /**
  32887. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32888. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32889. * 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)
  32890. */
  32891. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32892. /**
  32893. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32894. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32895. * 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)
  32896. */
  32897. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32898. /**
  32899. * This Observable will when a mesh has been imported into the scene.
  32900. */
  32901. onMeshImportedObservable: Observable<AbstractMesh>;
  32902. /**
  32903. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32904. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32905. */
  32906. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32907. /** @hidden */
  32908. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32909. /**
  32910. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32911. */
  32912. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32913. /**
  32914. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32915. */
  32916. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32917. /**
  32918. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32919. */
  32920. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32921. private _onPointerMove;
  32922. private _onPointerDown;
  32923. private _onPointerUp;
  32924. /** Callback called when a pointer move is detected */
  32925. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32926. /** Callback called when a pointer down is detected */
  32927. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32928. /** Callback called when a pointer up is detected */
  32929. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32930. /** Callback called when a pointer pick is detected */
  32931. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32932. /**
  32933. * 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).
  32934. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32935. */
  32936. onPrePointerObservable: Observable<PointerInfoPre>;
  32937. /**
  32938. * Observable event triggered each time an input event is received from the rendering canvas
  32939. */
  32940. onPointerObservable: Observable<PointerInfo>;
  32941. /**
  32942. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32943. */
  32944. readonly unTranslatedPointer: Vector2;
  32945. /** The distance in pixel that you have to move to prevent some events */
  32946. static DragMovementThreshold: number;
  32947. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32948. static LongPressDelay: number;
  32949. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32950. static DoubleClickDelay: number;
  32951. /** If you need to check double click without raising a single click at first click, enable this flag */
  32952. static ExclusiveDoubleClickMode: boolean;
  32953. private _initClickEvent;
  32954. private _initActionManager;
  32955. private _delayedSimpleClick;
  32956. private _delayedSimpleClickTimeout;
  32957. private _previousDelayedSimpleClickTimeout;
  32958. private _meshPickProceed;
  32959. private _previousButtonPressed;
  32960. private _currentPickResult;
  32961. private _previousPickResult;
  32962. private _totalPointersPressed;
  32963. private _doubleClickOccured;
  32964. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32965. cameraToUseForPointers: Nullable<Camera>;
  32966. private _pointerX;
  32967. private _pointerY;
  32968. private _unTranslatedPointerX;
  32969. private _unTranslatedPointerY;
  32970. private _startingPointerPosition;
  32971. private _previousStartingPointerPosition;
  32972. private _startingPointerTime;
  32973. private _previousStartingPointerTime;
  32974. private _pointerCaptures;
  32975. private _timeAccumulator;
  32976. private _currentStepId;
  32977. private _currentInternalStep;
  32978. /** @hidden */
  32979. _mirroredCameraPosition: Nullable<Vector3>;
  32980. /**
  32981. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32982. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32983. */
  32984. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32985. /**
  32986. * Observable event triggered each time an keyboard event is received from the hosting window
  32987. */
  32988. onKeyboardObservable: Observable<KeyboardInfo>;
  32989. private _onKeyDown;
  32990. private _onKeyUp;
  32991. private _onCanvasFocusObserver;
  32992. private _onCanvasBlurObserver;
  32993. private _useRightHandedSystem;
  32994. /**
  32995. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32996. */
  32997. useRightHandedSystem: boolean;
  32998. /**
  32999. * Sets the step Id used by deterministic lock step
  33000. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33001. * @param newStepId defines the step Id
  33002. */
  33003. setStepId(newStepId: number): void;
  33004. /**
  33005. * Gets the step Id used by deterministic lock step
  33006. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33007. * @returns the step Id
  33008. */
  33009. getStepId(): number;
  33010. /**
  33011. * Gets the internal step used by deterministic lock step
  33012. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33013. * @returns the internal step
  33014. */
  33015. getInternalStep(): number;
  33016. private _fogEnabled;
  33017. /**
  33018. * Gets or sets a boolean indicating if fog is enabled on this scene
  33019. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33020. * (Default is true)
  33021. */
  33022. fogEnabled: boolean;
  33023. private _fogMode;
  33024. /**
  33025. * Gets or sets the fog mode to use
  33026. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33027. * | mode | value |
  33028. * | --- | --- |
  33029. * | FOGMODE_NONE | 0 |
  33030. * | FOGMODE_EXP | 1 |
  33031. * | FOGMODE_EXP2 | 2 |
  33032. * | FOGMODE_LINEAR | 3 |
  33033. */
  33034. fogMode: number;
  33035. /**
  33036. * Gets or sets the fog color to use
  33037. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33038. * (Default is Color3(0.2, 0.2, 0.3))
  33039. */
  33040. fogColor: Color3;
  33041. /**
  33042. * Gets or sets the fog density to use
  33043. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33044. * (Default is 0.1)
  33045. */
  33046. fogDensity: number;
  33047. /**
  33048. * Gets or sets the fog start distance to use
  33049. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33050. * (Default is 0)
  33051. */
  33052. fogStart: number;
  33053. /**
  33054. * Gets or sets the fog end distance to use
  33055. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33056. * (Default is 1000)
  33057. */
  33058. fogEnd: number;
  33059. private _shadowsEnabled;
  33060. /**
  33061. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33062. */
  33063. shadowsEnabled: boolean;
  33064. private _lightsEnabled;
  33065. /**
  33066. * Gets or sets a boolean indicating if lights are enabled on this scene
  33067. */
  33068. lightsEnabled: boolean;
  33069. /** All of the active cameras added to this scene. */
  33070. activeCameras: Camera[];
  33071. /** @hidden */
  33072. _activeCamera: Nullable<Camera>;
  33073. /** Gets or sets the current active camera */
  33074. activeCamera: Nullable<Camera>;
  33075. private _defaultMaterial;
  33076. /** The default material used on meshes when no material is affected */
  33077. /** The default material used on meshes when no material is affected */
  33078. defaultMaterial: Material;
  33079. private _texturesEnabled;
  33080. /**
  33081. * Gets or sets a boolean indicating if textures are enabled on this scene
  33082. */
  33083. texturesEnabled: boolean;
  33084. /**
  33085. * Gets or sets a boolean indicating if particles are enabled on this scene
  33086. */
  33087. particlesEnabled: boolean;
  33088. /**
  33089. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33090. */
  33091. spritesEnabled: boolean;
  33092. private _skeletonsEnabled;
  33093. /**
  33094. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33095. */
  33096. skeletonsEnabled: boolean;
  33097. /**
  33098. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33099. */
  33100. lensFlaresEnabled: boolean;
  33101. /**
  33102. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33103. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33104. */
  33105. collisionsEnabled: boolean;
  33106. private _collisionCoordinator;
  33107. /** @hidden */
  33108. readonly collisionCoordinator: ICollisionCoordinator;
  33109. /**
  33110. * Defines the gravity applied to this scene (used only for collisions)
  33111. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33112. */
  33113. gravity: Vector3;
  33114. /**
  33115. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33116. */
  33117. postProcessesEnabled: boolean;
  33118. /**
  33119. * The list of postprocesses added to the scene
  33120. */
  33121. postProcesses: PostProcess[];
  33122. /**
  33123. * Gets the current postprocess manager
  33124. */
  33125. postProcessManager: PostProcessManager;
  33126. /**
  33127. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33128. */
  33129. renderTargetsEnabled: boolean;
  33130. /**
  33131. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33132. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33133. */
  33134. dumpNextRenderTargets: boolean;
  33135. /**
  33136. * The list of user defined render targets added to the scene
  33137. */
  33138. customRenderTargets: RenderTargetTexture[];
  33139. /**
  33140. * Defines if texture loading must be delayed
  33141. * If true, textures will only be loaded when they need to be rendered
  33142. */
  33143. useDelayedTextureLoading: boolean;
  33144. /**
  33145. * Gets the list of meshes imported to the scene through SceneLoader
  33146. */
  33147. importedMeshesFiles: String[];
  33148. /**
  33149. * Gets or sets a boolean indicating if probes are enabled on this scene
  33150. */
  33151. probesEnabled: boolean;
  33152. /**
  33153. * Gets or sets the current offline provider to use to store scene data
  33154. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33155. */
  33156. offlineProvider: IOfflineProvider;
  33157. /**
  33158. * Gets or sets the action manager associated with the scene
  33159. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33160. */
  33161. actionManager: AbstractActionManager;
  33162. private _meshesForIntersections;
  33163. /**
  33164. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33165. */
  33166. proceduralTexturesEnabled: boolean;
  33167. private _engine;
  33168. private _totalVertices;
  33169. /** @hidden */
  33170. _activeIndices: PerfCounter;
  33171. /** @hidden */
  33172. _activeParticles: PerfCounter;
  33173. /** @hidden */
  33174. _activeBones: PerfCounter;
  33175. private _animationRatio;
  33176. /** @hidden */
  33177. _animationTimeLast: number;
  33178. /** @hidden */
  33179. _animationTime: number;
  33180. /**
  33181. * Gets or sets a general scale for animation speed
  33182. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33183. */
  33184. animationTimeScale: number;
  33185. /** @hidden */
  33186. _cachedMaterial: Nullable<Material>;
  33187. /** @hidden */
  33188. _cachedEffect: Nullable<Effect>;
  33189. /** @hidden */
  33190. _cachedVisibility: Nullable<number>;
  33191. private _renderId;
  33192. private _frameId;
  33193. private _executeWhenReadyTimeoutId;
  33194. private _intermediateRendering;
  33195. private _viewUpdateFlag;
  33196. private _projectionUpdateFlag;
  33197. /** @hidden */
  33198. _toBeDisposed: Nullable<IDisposable>[];
  33199. private _activeRequests;
  33200. /** @hidden */
  33201. _pendingData: any[];
  33202. private _isDisposed;
  33203. /**
  33204. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33205. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33206. */
  33207. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33208. private _activeMeshes;
  33209. private _processedMaterials;
  33210. private _renderTargets;
  33211. /** @hidden */
  33212. _activeParticleSystems: SmartArray<IParticleSystem>;
  33213. private _activeSkeletons;
  33214. private _softwareSkinnedMeshes;
  33215. private _renderingManager;
  33216. /** @hidden */
  33217. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33218. private _transformMatrix;
  33219. private _sceneUbo;
  33220. /** @hidden */
  33221. _viewMatrix: Matrix;
  33222. private _projectionMatrix;
  33223. private _wheelEventName;
  33224. /** @hidden */
  33225. _forcedViewPosition: Nullable<Vector3>;
  33226. /** @hidden */
  33227. _frustumPlanes: Plane[];
  33228. /**
  33229. * Gets the list of frustum planes (built from the active camera)
  33230. */
  33231. readonly frustumPlanes: Plane[];
  33232. /**
  33233. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33234. * This is useful if there are more lights that the maximum simulteanous authorized
  33235. */
  33236. requireLightSorting: boolean;
  33237. /** @hidden */
  33238. readonly useMaterialMeshMap: boolean;
  33239. /** @hidden */
  33240. readonly useClonedMeshhMap: boolean;
  33241. private _pointerOverMesh;
  33242. private _pickedDownMesh;
  33243. private _pickedUpMesh;
  33244. private _externalData;
  33245. private _uid;
  33246. /**
  33247. * @hidden
  33248. * Backing store of defined scene components.
  33249. */
  33250. _components: ISceneComponent[];
  33251. /**
  33252. * @hidden
  33253. * Backing store of defined scene components.
  33254. */
  33255. _serializableComponents: ISceneSerializableComponent[];
  33256. /**
  33257. * List of components to register on the next registration step.
  33258. */
  33259. private _transientComponents;
  33260. /**
  33261. * Registers the transient components if needed.
  33262. */
  33263. private _registerTransientComponents;
  33264. /**
  33265. * @hidden
  33266. * Add a component to the scene.
  33267. * Note that the ccomponent could be registered on th next frame if this is called after
  33268. * the register component stage.
  33269. * @param component Defines the component to add to the scene
  33270. */
  33271. _addComponent(component: ISceneComponent): void;
  33272. /**
  33273. * @hidden
  33274. * Gets a component from the scene.
  33275. * @param name defines the name of the component to retrieve
  33276. * @returns the component or null if not present
  33277. */
  33278. _getComponent(name: string): Nullable<ISceneComponent>;
  33279. /**
  33280. * @hidden
  33281. * Defines the actions happening before camera updates.
  33282. */
  33283. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33284. /**
  33285. * @hidden
  33286. * Defines the actions happening before clear the canvas.
  33287. */
  33288. _beforeClearStage: Stage<SimpleStageAction>;
  33289. /**
  33290. * @hidden
  33291. * Defines the actions when collecting render targets for the frame.
  33292. */
  33293. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33294. /**
  33295. * @hidden
  33296. * Defines the actions happening for one camera in the frame.
  33297. */
  33298. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33299. /**
  33300. * @hidden
  33301. * Defines the actions happening during the per mesh ready checks.
  33302. */
  33303. _isReadyForMeshStage: Stage<MeshStageAction>;
  33304. /**
  33305. * @hidden
  33306. * Defines the actions happening before evaluate active mesh checks.
  33307. */
  33308. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33309. /**
  33310. * @hidden
  33311. * Defines the actions happening during the evaluate sub mesh checks.
  33312. */
  33313. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33314. /**
  33315. * @hidden
  33316. * Defines the actions happening during the active mesh stage.
  33317. */
  33318. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33319. /**
  33320. * @hidden
  33321. * Defines the actions happening during the per camera render target step.
  33322. */
  33323. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33324. /**
  33325. * @hidden
  33326. * Defines the actions happening just before the active camera is drawing.
  33327. */
  33328. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33329. /**
  33330. * @hidden
  33331. * Defines the actions happening just before a render target is drawing.
  33332. */
  33333. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33334. /**
  33335. * @hidden
  33336. * Defines the actions happening just before a rendering group is drawing.
  33337. */
  33338. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33339. /**
  33340. * @hidden
  33341. * Defines the actions happening just before a mesh is drawing.
  33342. */
  33343. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33344. /**
  33345. * @hidden
  33346. * Defines the actions happening just after a mesh has been drawn.
  33347. */
  33348. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33349. /**
  33350. * @hidden
  33351. * Defines the actions happening just after a rendering group has been drawn.
  33352. */
  33353. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33354. /**
  33355. * @hidden
  33356. * Defines the actions happening just after the active camera has been drawn.
  33357. */
  33358. _afterCameraDrawStage: Stage<CameraStageAction>;
  33359. /**
  33360. * @hidden
  33361. * Defines the actions happening just after a render target has been drawn.
  33362. */
  33363. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33364. /**
  33365. * @hidden
  33366. * Defines the actions happening just after rendering all cameras and computing intersections.
  33367. */
  33368. _afterRenderStage: Stage<SimpleStageAction>;
  33369. /**
  33370. * @hidden
  33371. * Defines the actions happening when a pointer move event happens.
  33372. */
  33373. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33374. /**
  33375. * @hidden
  33376. * Defines the actions happening when a pointer down event happens.
  33377. */
  33378. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33379. /**
  33380. * @hidden
  33381. * Defines the actions happening when a pointer up event happens.
  33382. */
  33383. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33384. /**
  33385. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33386. */
  33387. private geometriesByUniqueId;
  33388. /**
  33389. * Creates a new Scene
  33390. * @param engine defines the engine to use to render this scene
  33391. * @param options defines the scene options
  33392. */
  33393. constructor(engine: Engine, options?: SceneOptions);
  33394. /**
  33395. * Gets a string idenfifying the name of the class
  33396. * @returns "Scene" string
  33397. */
  33398. getClassName(): string;
  33399. private _defaultMeshCandidates;
  33400. /**
  33401. * @hidden
  33402. */
  33403. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33404. private _defaultSubMeshCandidates;
  33405. /**
  33406. * @hidden
  33407. */
  33408. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33409. /**
  33410. * Sets the default candidate providers for the scene.
  33411. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33412. * and getCollidingSubMeshCandidates to their default function
  33413. */
  33414. setDefaultCandidateProviders(): void;
  33415. /**
  33416. * Gets the mesh that is currently under the pointer
  33417. */
  33418. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33419. /**
  33420. * Gets or sets the current on-screen X position of the pointer
  33421. */
  33422. pointerX: number;
  33423. /**
  33424. * Gets or sets the current on-screen Y position of the pointer
  33425. */
  33426. pointerY: number;
  33427. /**
  33428. * Gets the cached material (ie. the latest rendered one)
  33429. * @returns the cached material
  33430. */
  33431. getCachedMaterial(): Nullable<Material>;
  33432. /**
  33433. * Gets the cached effect (ie. the latest rendered one)
  33434. * @returns the cached effect
  33435. */
  33436. getCachedEffect(): Nullable<Effect>;
  33437. /**
  33438. * Gets the cached visibility state (ie. the latest rendered one)
  33439. * @returns the cached visibility state
  33440. */
  33441. getCachedVisibility(): Nullable<number>;
  33442. /**
  33443. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33444. * @param material defines the current material
  33445. * @param effect defines the current effect
  33446. * @param visibility defines the current visibility state
  33447. * @returns true if one parameter is not cached
  33448. */
  33449. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33450. /**
  33451. * Gets the engine associated with the scene
  33452. * @returns an Engine
  33453. */
  33454. getEngine(): Engine;
  33455. /**
  33456. * Gets the total number of vertices rendered per frame
  33457. * @returns the total number of vertices rendered per frame
  33458. */
  33459. getTotalVertices(): number;
  33460. /**
  33461. * Gets the performance counter for total vertices
  33462. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33463. */
  33464. readonly totalVerticesPerfCounter: PerfCounter;
  33465. /**
  33466. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33467. * @returns the total number of active indices rendered per frame
  33468. */
  33469. getActiveIndices(): number;
  33470. /**
  33471. * Gets the performance counter for active indices
  33472. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33473. */
  33474. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33475. /**
  33476. * Gets the total number of active particles rendered per frame
  33477. * @returns the total number of active particles rendered per frame
  33478. */
  33479. getActiveParticles(): number;
  33480. /**
  33481. * Gets the performance counter for active particles
  33482. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33483. */
  33484. readonly activeParticlesPerfCounter: PerfCounter;
  33485. /**
  33486. * Gets the total number of active bones rendered per frame
  33487. * @returns the total number of active bones rendered per frame
  33488. */
  33489. getActiveBones(): number;
  33490. /**
  33491. * Gets the performance counter for active bones
  33492. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33493. */
  33494. readonly activeBonesPerfCounter: PerfCounter;
  33495. /**
  33496. * Gets the array of active meshes
  33497. * @returns an array of AbstractMesh
  33498. */
  33499. getActiveMeshes(): SmartArray<AbstractMesh>;
  33500. /**
  33501. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33502. * @returns a number
  33503. */
  33504. getAnimationRatio(): number;
  33505. /**
  33506. * Gets an unique Id for the current render phase
  33507. * @returns a number
  33508. */
  33509. getRenderId(): number;
  33510. /**
  33511. * Gets an unique Id for the current frame
  33512. * @returns a number
  33513. */
  33514. getFrameId(): number;
  33515. /** Call this function if you want to manually increment the render Id*/
  33516. incrementRenderId(): void;
  33517. private _updatePointerPosition;
  33518. private _createUbo;
  33519. private _setRayOnPointerInfo;
  33520. /**
  33521. * Use this method to simulate a pointer move on a mesh
  33522. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33523. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33524. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33525. * @returns the current scene
  33526. */
  33527. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33528. private _processPointerMove;
  33529. private _checkPrePointerObservable;
  33530. /**
  33531. * Use this method to simulate a pointer down on a mesh
  33532. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33533. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33534. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33535. * @returns the current scene
  33536. */
  33537. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33538. private _processPointerDown;
  33539. /**
  33540. * Use this method to simulate a pointer up on a mesh
  33541. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33542. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33543. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33544. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33545. * @returns the current scene
  33546. */
  33547. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33548. private _processPointerUp;
  33549. /**
  33550. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33551. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33552. * @returns true if the pointer was captured
  33553. */
  33554. isPointerCaptured(pointerId?: number): boolean;
  33555. /** @hidden */
  33556. _isPointerSwiping(): boolean;
  33557. /**
  33558. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33559. * @param attachUp defines if you want to attach events to pointerup
  33560. * @param attachDown defines if you want to attach events to pointerdown
  33561. * @param attachMove defines if you want to attach events to pointermove
  33562. */
  33563. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33564. /** Detaches all event handlers*/
  33565. detachControl(): void;
  33566. /**
  33567. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33568. * Delay loaded resources are not taking in account
  33569. * @return true if all required resources are ready
  33570. */
  33571. isReady(): boolean;
  33572. /** Resets all cached information relative to material (including effect and visibility) */
  33573. resetCachedMaterial(): void;
  33574. /**
  33575. * Registers a function to be called before every frame render
  33576. * @param func defines the function to register
  33577. */
  33578. registerBeforeRender(func: () => void): void;
  33579. /**
  33580. * Unregisters a function called before every frame render
  33581. * @param func defines the function to unregister
  33582. */
  33583. unregisterBeforeRender(func: () => void): void;
  33584. /**
  33585. * Registers a function to be called after every frame render
  33586. * @param func defines the function to register
  33587. */
  33588. registerAfterRender(func: () => void): void;
  33589. /**
  33590. * Unregisters a function called after every frame render
  33591. * @param func defines the function to unregister
  33592. */
  33593. unregisterAfterRender(func: () => void): void;
  33594. private _executeOnceBeforeRender;
  33595. /**
  33596. * The provided function will run before render once and will be disposed afterwards.
  33597. * A timeout delay can be provided so that the function will be executed in N ms.
  33598. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33599. * @param func The function to be executed.
  33600. * @param timeout optional delay in ms
  33601. */
  33602. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33603. /** @hidden */
  33604. _addPendingData(data: any): void;
  33605. /** @hidden */
  33606. _removePendingData(data: any): void;
  33607. /**
  33608. * Returns the number of items waiting to be loaded
  33609. * @returns the number of items waiting to be loaded
  33610. */
  33611. getWaitingItemsCount(): number;
  33612. /**
  33613. * Returns a boolean indicating if the scene is still loading data
  33614. */
  33615. readonly isLoading: boolean;
  33616. /**
  33617. * Registers a function to be executed when the scene is ready
  33618. * @param {Function} func - the function to be executed
  33619. */
  33620. executeWhenReady(func: () => void): void;
  33621. /**
  33622. * Returns a promise that resolves when the scene is ready
  33623. * @returns A promise that resolves when the scene is ready
  33624. */
  33625. whenReadyAsync(): Promise<void>;
  33626. /** @hidden */
  33627. _checkIsReady(): void;
  33628. /**
  33629. * Gets all animatable attached to the scene
  33630. */
  33631. readonly animatables: Animatable[];
  33632. /**
  33633. * Resets the last animation time frame.
  33634. * Useful to override when animations start running when loading a scene for the first time.
  33635. */
  33636. resetLastAnimationTimeFrame(): void;
  33637. /**
  33638. * Gets the current view matrix
  33639. * @returns a Matrix
  33640. */
  33641. getViewMatrix(): Matrix;
  33642. /**
  33643. * Gets the current projection matrix
  33644. * @returns a Matrix
  33645. */
  33646. getProjectionMatrix(): Matrix;
  33647. /**
  33648. * Gets the current transform matrix
  33649. * @returns a Matrix made of View * Projection
  33650. */
  33651. getTransformMatrix(): Matrix;
  33652. /**
  33653. * Sets the current transform matrix
  33654. * @param viewL defines the View matrix to use
  33655. * @param projectionL defines the Projection matrix to use
  33656. * @param viewR defines the right View matrix to use (if provided)
  33657. * @param projectionR defines the right Projection matrix to use (if provided)
  33658. */
  33659. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33660. /**
  33661. * Gets the uniform buffer used to store scene data
  33662. * @returns a UniformBuffer
  33663. */
  33664. getSceneUniformBuffer(): UniformBuffer;
  33665. /**
  33666. * Gets an unique (relatively to the current scene) Id
  33667. * @returns an unique number for the scene
  33668. */
  33669. getUniqueId(): number;
  33670. /**
  33671. * Add a mesh to the list of scene's meshes
  33672. * @param newMesh defines the mesh to add
  33673. * @param recursive if all child meshes should also be added to the scene
  33674. */
  33675. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33676. /**
  33677. * Remove a mesh for the list of scene's meshes
  33678. * @param toRemove defines the mesh to remove
  33679. * @param recursive if all child meshes should also be removed from the scene
  33680. * @returns the index where the mesh was in the mesh list
  33681. */
  33682. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33683. /**
  33684. * Add a transform node to the list of scene's transform nodes
  33685. * @param newTransformNode defines the transform node to add
  33686. */
  33687. addTransformNode(newTransformNode: TransformNode): void;
  33688. /**
  33689. * Remove a transform node for the list of scene's transform nodes
  33690. * @param toRemove defines the transform node to remove
  33691. * @returns the index where the transform node was in the transform node list
  33692. */
  33693. removeTransformNode(toRemove: TransformNode): number;
  33694. /**
  33695. * Remove a skeleton for the list of scene's skeletons
  33696. * @param toRemove defines the skeleton to remove
  33697. * @returns the index where the skeleton was in the skeleton list
  33698. */
  33699. removeSkeleton(toRemove: Skeleton): number;
  33700. /**
  33701. * Remove a morph target for the list of scene's morph targets
  33702. * @param toRemove defines the morph target to remove
  33703. * @returns the index where the morph target was in the morph target list
  33704. */
  33705. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33706. /**
  33707. * Remove a light for the list of scene's lights
  33708. * @param toRemove defines the light to remove
  33709. * @returns the index where the light was in the light list
  33710. */
  33711. removeLight(toRemove: Light): number;
  33712. /**
  33713. * Remove a camera for the list of scene's cameras
  33714. * @param toRemove defines the camera to remove
  33715. * @returns the index where the camera was in the camera list
  33716. */
  33717. removeCamera(toRemove: Camera): number;
  33718. /**
  33719. * Remove a particle system for the list of scene's particle systems
  33720. * @param toRemove defines the particle system to remove
  33721. * @returns the index where the particle system was in the particle system list
  33722. */
  33723. removeParticleSystem(toRemove: IParticleSystem): number;
  33724. /**
  33725. * Remove a animation for the list of scene's animations
  33726. * @param toRemove defines the animation to remove
  33727. * @returns the index where the animation was in the animation list
  33728. */
  33729. removeAnimation(toRemove: Animation): number;
  33730. /**
  33731. * Removes the given animation group from this scene.
  33732. * @param toRemove The animation group to remove
  33733. * @returns The index of the removed animation group
  33734. */
  33735. removeAnimationGroup(toRemove: AnimationGroup): number;
  33736. /**
  33737. * Removes the given multi-material from this scene.
  33738. * @param toRemove The multi-material to remove
  33739. * @returns The index of the removed multi-material
  33740. */
  33741. removeMultiMaterial(toRemove: MultiMaterial): number;
  33742. /**
  33743. * Removes the given material from this scene.
  33744. * @param toRemove The material to remove
  33745. * @returns The index of the removed material
  33746. */
  33747. removeMaterial(toRemove: Material): number;
  33748. /**
  33749. * Removes the given action manager from this scene.
  33750. * @param toRemove The action manager to remove
  33751. * @returns The index of the removed action manager
  33752. */
  33753. removeActionManager(toRemove: AbstractActionManager): number;
  33754. /**
  33755. * Removes the given texture from this scene.
  33756. * @param toRemove The texture to remove
  33757. * @returns The index of the removed texture
  33758. */
  33759. removeTexture(toRemove: BaseTexture): number;
  33760. /**
  33761. * Adds the given light to this scene
  33762. * @param newLight The light to add
  33763. */
  33764. addLight(newLight: Light): void;
  33765. /**
  33766. * Sorts the list list based on light priorities
  33767. */
  33768. sortLightsByPriority(): void;
  33769. /**
  33770. * Adds the given camera to this scene
  33771. * @param newCamera The camera to add
  33772. */
  33773. addCamera(newCamera: Camera): void;
  33774. /**
  33775. * Adds the given skeleton to this scene
  33776. * @param newSkeleton The skeleton to add
  33777. */
  33778. addSkeleton(newSkeleton: Skeleton): void;
  33779. /**
  33780. * Adds the given particle system to this scene
  33781. * @param newParticleSystem The particle system to add
  33782. */
  33783. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33784. /**
  33785. * Adds the given animation to this scene
  33786. * @param newAnimation The animation to add
  33787. */
  33788. addAnimation(newAnimation: Animation): void;
  33789. /**
  33790. * Adds the given animation group to this scene.
  33791. * @param newAnimationGroup The animation group to add
  33792. */
  33793. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33794. /**
  33795. * Adds the given multi-material to this scene
  33796. * @param newMultiMaterial The multi-material to add
  33797. */
  33798. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33799. /**
  33800. * Adds the given material to this scene
  33801. * @param newMaterial The material to add
  33802. */
  33803. addMaterial(newMaterial: Material): void;
  33804. /**
  33805. * Adds the given morph target to this scene
  33806. * @param newMorphTargetManager The morph target to add
  33807. */
  33808. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33809. /**
  33810. * Adds the given geometry to this scene
  33811. * @param newGeometry The geometry to add
  33812. */
  33813. addGeometry(newGeometry: Geometry): void;
  33814. /**
  33815. * Adds the given action manager to this scene
  33816. * @param newActionManager The action manager to add
  33817. */
  33818. addActionManager(newActionManager: AbstractActionManager): void;
  33819. /**
  33820. * Adds the given texture to this scene.
  33821. * @param newTexture The texture to add
  33822. */
  33823. addTexture(newTexture: BaseTexture): void;
  33824. /**
  33825. * Switch active camera
  33826. * @param newCamera defines the new active camera
  33827. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33828. */
  33829. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33830. /**
  33831. * sets the active camera of the scene using its ID
  33832. * @param id defines the camera's ID
  33833. * @return the new active camera or null if none found.
  33834. */
  33835. setActiveCameraByID(id: string): Nullable<Camera>;
  33836. /**
  33837. * sets the active camera of the scene using its name
  33838. * @param name defines the camera's name
  33839. * @returns the new active camera or null if none found.
  33840. */
  33841. setActiveCameraByName(name: string): Nullable<Camera>;
  33842. /**
  33843. * get an animation group using its name
  33844. * @param name defines the material's name
  33845. * @return the animation group or null if none found.
  33846. */
  33847. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33848. /**
  33849. * Get a material using its unique id
  33850. * @param uniqueId defines the material's unique id
  33851. * @return the material or null if none found.
  33852. */
  33853. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33854. /**
  33855. * get a material using its id
  33856. * @param id defines the material's ID
  33857. * @return the material or null if none found.
  33858. */
  33859. getMaterialByID(id: string): Nullable<Material>;
  33860. /**
  33861. * Gets a material using its name
  33862. * @param name defines the material's name
  33863. * @return the material or null if none found.
  33864. */
  33865. getMaterialByName(name: string): Nullable<Material>;
  33866. /**
  33867. * Gets a camera using its id
  33868. * @param id defines the id to look for
  33869. * @returns the camera or null if not found
  33870. */
  33871. getCameraByID(id: string): Nullable<Camera>;
  33872. /**
  33873. * Gets a camera using its unique id
  33874. * @param uniqueId defines the unique id to look for
  33875. * @returns the camera or null if not found
  33876. */
  33877. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33878. /**
  33879. * Gets a camera using its name
  33880. * @param name defines the camera's name
  33881. * @return the camera or null if none found.
  33882. */
  33883. getCameraByName(name: string): Nullable<Camera>;
  33884. /**
  33885. * Gets a bone using its id
  33886. * @param id defines the bone's id
  33887. * @return the bone or null if not found
  33888. */
  33889. getBoneByID(id: string): Nullable<Bone>;
  33890. /**
  33891. * Gets a bone using its id
  33892. * @param name defines the bone's name
  33893. * @return the bone or null if not found
  33894. */
  33895. getBoneByName(name: string): Nullable<Bone>;
  33896. /**
  33897. * Gets a light node using its name
  33898. * @param name defines the the light's name
  33899. * @return the light or null if none found.
  33900. */
  33901. getLightByName(name: string): Nullable<Light>;
  33902. /**
  33903. * Gets a light node using its id
  33904. * @param id defines the light's id
  33905. * @return the light or null if none found.
  33906. */
  33907. getLightByID(id: string): Nullable<Light>;
  33908. /**
  33909. * Gets a light node using its scene-generated unique ID
  33910. * @param uniqueId defines the light's unique id
  33911. * @return the light or null if none found.
  33912. */
  33913. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33914. /**
  33915. * Gets a particle system by id
  33916. * @param id defines the particle system id
  33917. * @return the corresponding system or null if none found
  33918. */
  33919. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33920. /**
  33921. * Gets a geometry using its ID
  33922. * @param id defines the geometry's id
  33923. * @return the geometry or null if none found.
  33924. */
  33925. getGeometryByID(id: string): Nullable<Geometry>;
  33926. private _getGeometryByUniqueID;
  33927. /**
  33928. * Add a new geometry to this scene
  33929. * @param geometry defines the geometry to be added to the scene.
  33930. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33931. * @return a boolean defining if the geometry was added or not
  33932. */
  33933. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33934. /**
  33935. * Removes an existing geometry
  33936. * @param geometry defines the geometry to be removed from the scene
  33937. * @return a boolean defining if the geometry was removed or not
  33938. */
  33939. removeGeometry(geometry: Geometry): boolean;
  33940. /**
  33941. * Gets the list of geometries attached to the scene
  33942. * @returns an array of Geometry
  33943. */
  33944. getGeometries(): Geometry[];
  33945. /**
  33946. * Gets the first added mesh found of a given ID
  33947. * @param id defines the id to search for
  33948. * @return the mesh found or null if not found at all
  33949. */
  33950. getMeshByID(id: string): Nullable<AbstractMesh>;
  33951. /**
  33952. * Gets a list of meshes using their id
  33953. * @param id defines the id to search for
  33954. * @returns a list of meshes
  33955. */
  33956. getMeshesByID(id: string): Array<AbstractMesh>;
  33957. /**
  33958. * Gets the first added transform node found of a given ID
  33959. * @param id defines the id to search for
  33960. * @return the found transform node or null if not found at all.
  33961. */
  33962. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33963. /**
  33964. * Gets a transform node with its auto-generated unique id
  33965. * @param uniqueId efines the unique id to search for
  33966. * @return the found transform node or null if not found at all.
  33967. */
  33968. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33969. /**
  33970. * Gets a list of transform nodes using their id
  33971. * @param id defines the id to search for
  33972. * @returns a list of transform nodes
  33973. */
  33974. getTransformNodesByID(id: string): Array<TransformNode>;
  33975. /**
  33976. * Gets a mesh with its auto-generated unique id
  33977. * @param uniqueId defines the unique id to search for
  33978. * @return the found mesh or null if not found at all.
  33979. */
  33980. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33981. /**
  33982. * Gets a the last added mesh using a given id
  33983. * @param id defines the id to search for
  33984. * @return the found mesh or null if not found at all.
  33985. */
  33986. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33987. /**
  33988. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33989. * @param id defines the id to search for
  33990. * @return the found node or null if not found at all
  33991. */
  33992. getLastEntryByID(id: string): Nullable<Node>;
  33993. /**
  33994. * Gets a node (Mesh, Camera, Light) using a given id
  33995. * @param id defines the id to search for
  33996. * @return the found node or null if not found at all
  33997. */
  33998. getNodeByID(id: string): Nullable<Node>;
  33999. /**
  34000. * Gets a node (Mesh, Camera, Light) using a given name
  34001. * @param name defines the name to search for
  34002. * @return the found node or null if not found at all.
  34003. */
  34004. getNodeByName(name: string): Nullable<Node>;
  34005. /**
  34006. * Gets a mesh using a given name
  34007. * @param name defines the name to search for
  34008. * @return the found mesh or null if not found at all.
  34009. */
  34010. getMeshByName(name: string): Nullable<AbstractMesh>;
  34011. /**
  34012. * Gets a transform node using a given name
  34013. * @param name defines the name to search for
  34014. * @return the found transform node or null if not found at all.
  34015. */
  34016. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34017. /**
  34018. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34019. * @param id defines the id to search for
  34020. * @return the found skeleton or null if not found at all.
  34021. */
  34022. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34023. /**
  34024. * Gets a skeleton using a given auto generated unique id
  34025. * @param uniqueId defines the unique id to search for
  34026. * @return the found skeleton or null if not found at all.
  34027. */
  34028. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34029. /**
  34030. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34031. * @param id defines the id to search for
  34032. * @return the found skeleton or null if not found at all.
  34033. */
  34034. getSkeletonById(id: string): Nullable<Skeleton>;
  34035. /**
  34036. * Gets a skeleton using a given name
  34037. * @param name defines the name to search for
  34038. * @return the found skeleton or null if not found at all.
  34039. */
  34040. getSkeletonByName(name: string): Nullable<Skeleton>;
  34041. /**
  34042. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34043. * @param id defines the id to search for
  34044. * @return the found morph target manager or null if not found at all.
  34045. */
  34046. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34047. /**
  34048. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34049. * @param id defines the id to search for
  34050. * @return the found morph target or null if not found at all.
  34051. */
  34052. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34053. /**
  34054. * Gets a boolean indicating if the given mesh is active
  34055. * @param mesh defines the mesh to look for
  34056. * @returns true if the mesh is in the active list
  34057. */
  34058. isActiveMesh(mesh: AbstractMesh): boolean;
  34059. /**
  34060. * Return a unique id as a string which can serve as an identifier for the scene
  34061. */
  34062. readonly uid: string;
  34063. /**
  34064. * Add an externaly attached data from its key.
  34065. * This method call will fail and return false, if such key already exists.
  34066. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34067. * @param key the unique key that identifies the data
  34068. * @param data the data object to associate to the key for this Engine instance
  34069. * @return true if no such key were already present and the data was added successfully, false otherwise
  34070. */
  34071. addExternalData<T>(key: string, data: T): boolean;
  34072. /**
  34073. * Get an externaly attached data from its key
  34074. * @param key the unique key that identifies the data
  34075. * @return the associated data, if present (can be null), or undefined if not present
  34076. */
  34077. getExternalData<T>(key: string): Nullable<T>;
  34078. /**
  34079. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34080. * @param key the unique key that identifies the data
  34081. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34082. * @return the associated data, can be null if the factory returned null.
  34083. */
  34084. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34085. /**
  34086. * Remove an externaly attached data from the Engine instance
  34087. * @param key the unique key that identifies the data
  34088. * @return true if the data was successfully removed, false if it doesn't exist
  34089. */
  34090. removeExternalData(key: string): boolean;
  34091. private _evaluateSubMesh;
  34092. /**
  34093. * Clear the processed materials smart array preventing retention point in material dispose.
  34094. */
  34095. freeProcessedMaterials(): void;
  34096. private _preventFreeActiveMeshesAndRenderingGroups;
  34097. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34098. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34099. * when disposing several meshes in a row or a hierarchy of meshes.
  34100. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34101. */
  34102. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34103. /**
  34104. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34105. */
  34106. freeActiveMeshes(): void;
  34107. /**
  34108. * Clear the info related to rendering groups preventing retention points during dispose.
  34109. */
  34110. freeRenderingGroups(): void;
  34111. /** @hidden */
  34112. _isInIntermediateRendering(): boolean;
  34113. /**
  34114. * Lambda returning the list of potentially active meshes.
  34115. */
  34116. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34117. /**
  34118. * Lambda returning the list of potentially active sub meshes.
  34119. */
  34120. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34121. /**
  34122. * Lambda returning the list of potentially intersecting sub meshes.
  34123. */
  34124. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34125. /**
  34126. * Lambda returning the list of potentially colliding sub meshes.
  34127. */
  34128. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34129. private _activeMeshesFrozen;
  34130. /**
  34131. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34132. * @returns the current scene
  34133. */
  34134. freezeActiveMeshes(): Scene;
  34135. /**
  34136. * Use this function to restart evaluating active meshes on every frame
  34137. * @returns the current scene
  34138. */
  34139. unfreezeActiveMeshes(): Scene;
  34140. private _evaluateActiveMeshes;
  34141. private _activeMesh;
  34142. /**
  34143. * Update the transform matrix to update from the current active camera
  34144. * @param force defines a boolean used to force the update even if cache is up to date
  34145. */
  34146. updateTransformMatrix(force?: boolean): void;
  34147. private _bindFrameBuffer;
  34148. /** @hidden */
  34149. _allowPostProcessClearColor: boolean;
  34150. /** @hidden */
  34151. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34152. private _processSubCameras;
  34153. private _checkIntersections;
  34154. /** @hidden */
  34155. _advancePhysicsEngineStep(step: number): void;
  34156. /**
  34157. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34158. */
  34159. getDeterministicFrameTime: () => number;
  34160. /** @hidden */
  34161. _animate(): void;
  34162. /** Execute all animations (for a frame) */
  34163. animate(): void;
  34164. /**
  34165. * Render the scene
  34166. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34167. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34168. */
  34169. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34170. /**
  34171. * Freeze all materials
  34172. * A frozen material will not be updatable but should be faster to render
  34173. */
  34174. freezeMaterials(): void;
  34175. /**
  34176. * Unfreeze all materials
  34177. * A frozen material will not be updatable but should be faster to render
  34178. */
  34179. unfreezeMaterials(): void;
  34180. /**
  34181. * Releases all held ressources
  34182. */
  34183. dispose(): void;
  34184. /**
  34185. * Gets if the scene is already disposed
  34186. */
  34187. readonly isDisposed: boolean;
  34188. /**
  34189. * Call this function to reduce memory footprint of the scene.
  34190. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34191. */
  34192. clearCachedVertexData(): void;
  34193. /**
  34194. * This function will remove the local cached buffer data from texture.
  34195. * It will save memory but will prevent the texture from being rebuilt
  34196. */
  34197. cleanCachedTextureBuffer(): void;
  34198. /**
  34199. * Get the world extend vectors with an optional filter
  34200. *
  34201. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34202. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34203. */
  34204. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34205. min: Vector3;
  34206. max: Vector3;
  34207. };
  34208. /**
  34209. * Creates a ray that can be used to pick in the scene
  34210. * @param x defines the x coordinate of the origin (on-screen)
  34211. * @param y defines the y coordinate of the origin (on-screen)
  34212. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34213. * @param camera defines the camera to use for the picking
  34214. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34215. * @returns a Ray
  34216. */
  34217. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34218. /**
  34219. * Creates a ray that can be used to pick in the scene
  34220. * @param x defines the x coordinate of the origin (on-screen)
  34221. * @param y defines the y coordinate of the origin (on-screen)
  34222. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34223. * @param result defines the ray where to store the picking ray
  34224. * @param camera defines the camera to use for the picking
  34225. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34226. * @returns the current scene
  34227. */
  34228. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34229. /**
  34230. * Creates a ray that can be used to pick in the scene
  34231. * @param x defines the x coordinate of the origin (on-screen)
  34232. * @param y defines the y coordinate of the origin (on-screen)
  34233. * @param camera defines the camera to use for the picking
  34234. * @returns a Ray
  34235. */
  34236. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34237. /**
  34238. * Creates a ray that can be used to pick in the scene
  34239. * @param x defines the x coordinate of the origin (on-screen)
  34240. * @param y defines the y coordinate of the origin (on-screen)
  34241. * @param result defines the ray where to store the picking ray
  34242. * @param camera defines the camera to use for the picking
  34243. * @returns the current scene
  34244. */
  34245. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34246. /** Launch a ray to try to pick a mesh in the scene
  34247. * @param x position on screen
  34248. * @param y position on screen
  34249. * @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
  34250. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34251. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34252. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34253. * @returns a PickingInfo
  34254. */
  34255. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34256. /** Use the given ray to pick a mesh in the scene
  34257. * @param ray The ray to use to pick meshes
  34258. * @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
  34259. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34260. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34261. * @returns a PickingInfo
  34262. */
  34263. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34264. /**
  34265. * Launch a ray to try to pick a mesh in the scene
  34266. * @param x X position on screen
  34267. * @param y Y position on screen
  34268. * @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
  34269. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34270. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34271. * @returns an array of PickingInfo
  34272. */
  34273. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34274. /**
  34275. * Launch a ray to try to pick a mesh in the scene
  34276. * @param ray Ray to use
  34277. * @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
  34278. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34279. * @returns an array of PickingInfo
  34280. */
  34281. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34282. /**
  34283. * Force the value of meshUnderPointer
  34284. * @param mesh defines the mesh to use
  34285. */
  34286. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34287. /**
  34288. * Gets the mesh under the pointer
  34289. * @returns a Mesh or null if no mesh is under the pointer
  34290. */
  34291. getPointerOverMesh(): Nullable<AbstractMesh>;
  34292. /** @hidden */
  34293. _rebuildGeometries(): void;
  34294. /** @hidden */
  34295. _rebuildTextures(): void;
  34296. private _getByTags;
  34297. /**
  34298. * Get a list of meshes by tags
  34299. * @param tagsQuery defines the tags query to use
  34300. * @param forEach defines a predicate used to filter results
  34301. * @returns an array of Mesh
  34302. */
  34303. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34304. /**
  34305. * Get a list of cameras by tags
  34306. * @param tagsQuery defines the tags query to use
  34307. * @param forEach defines a predicate used to filter results
  34308. * @returns an array of Camera
  34309. */
  34310. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34311. /**
  34312. * Get a list of lights by tags
  34313. * @param tagsQuery defines the tags query to use
  34314. * @param forEach defines a predicate used to filter results
  34315. * @returns an array of Light
  34316. */
  34317. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34318. /**
  34319. * Get a list of materials by tags
  34320. * @param tagsQuery defines the tags query to use
  34321. * @param forEach defines a predicate used to filter results
  34322. * @returns an array of Material
  34323. */
  34324. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34325. /**
  34326. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34327. * This allowed control for front to back rendering or reversly depending of the special needs.
  34328. *
  34329. * @param renderingGroupId The rendering group id corresponding to its index
  34330. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34331. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34332. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34333. */
  34334. 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;
  34335. /**
  34336. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34337. *
  34338. * @param renderingGroupId The rendering group id corresponding to its index
  34339. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34340. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34341. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34342. */
  34343. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34344. /**
  34345. * Gets the current auto clear configuration for one rendering group of the rendering
  34346. * manager.
  34347. * @param index the rendering group index to get the information for
  34348. * @returns The auto clear setup for the requested rendering group
  34349. */
  34350. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34351. private _blockMaterialDirtyMechanism;
  34352. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34353. blockMaterialDirtyMechanism: boolean;
  34354. /**
  34355. * Will flag all materials as dirty to trigger new shader compilation
  34356. * @param flag defines the flag used to specify which material part must be marked as dirty
  34357. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34358. */
  34359. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34360. /** @hidden */
  34361. _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;
  34362. /** @hidden */
  34363. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34364. }
  34365. }
  34366. declare module "babylonjs/assetContainer" {
  34367. import { AbstractScene } from "babylonjs/abstractScene";
  34368. import { Scene } from "babylonjs/scene";
  34369. import { Mesh } from "babylonjs/Meshes/mesh";
  34370. /**
  34371. * Set of assets to keep when moving a scene into an asset container.
  34372. */
  34373. export class KeepAssets extends AbstractScene {
  34374. }
  34375. /**
  34376. * Container with a set of assets that can be added or removed from a scene.
  34377. */
  34378. export class AssetContainer extends AbstractScene {
  34379. /**
  34380. * The scene the AssetContainer belongs to.
  34381. */
  34382. scene: Scene;
  34383. /**
  34384. * Instantiates an AssetContainer.
  34385. * @param scene The scene the AssetContainer belongs to.
  34386. */
  34387. constructor(scene: Scene);
  34388. /**
  34389. * Adds all the assets from the container to the scene.
  34390. */
  34391. addAllToScene(): void;
  34392. /**
  34393. * Removes all the assets in the container from the scene
  34394. */
  34395. removeAllFromScene(): void;
  34396. /**
  34397. * Disposes all the assets in the container
  34398. */
  34399. dispose(): void;
  34400. private _moveAssets;
  34401. /**
  34402. * Removes all the assets contained in the scene and adds them to the container.
  34403. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34404. */
  34405. moveAllFromScene(keepAssets?: KeepAssets): void;
  34406. /**
  34407. * 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.
  34408. * @returns the root mesh
  34409. */
  34410. createRootMesh(): Mesh;
  34411. }
  34412. }
  34413. declare module "babylonjs/abstractScene" {
  34414. import { Scene } from "babylonjs/scene";
  34415. import { Nullable } from "babylonjs/types";
  34416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34417. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34418. import { Geometry } from "babylonjs/Meshes/geometry";
  34419. import { Skeleton } from "babylonjs/Bones/skeleton";
  34420. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34421. import { AssetContainer } from "babylonjs/assetContainer";
  34422. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34423. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34424. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34425. import { Material } from "babylonjs/Materials/material";
  34426. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34427. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34428. import { Camera } from "babylonjs/Cameras/camera";
  34429. import { Light } from "babylonjs/Lights/light";
  34430. import { Node } from "babylonjs/node";
  34431. import { Animation } from "babylonjs/Animations/animation";
  34432. /**
  34433. * Defines how the parser contract is defined.
  34434. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34435. */
  34436. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34437. /**
  34438. * Defines how the individual parser contract is defined.
  34439. * These parser can parse an individual asset
  34440. */
  34441. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34442. /**
  34443. * Base class of the scene acting as a container for the different elements composing a scene.
  34444. * This class is dynamically extended by the different components of the scene increasing
  34445. * flexibility and reducing coupling
  34446. */
  34447. export abstract class AbstractScene {
  34448. /**
  34449. * Stores the list of available parsers in the application.
  34450. */
  34451. private static _BabylonFileParsers;
  34452. /**
  34453. * Stores the list of available individual parsers in the application.
  34454. */
  34455. private static _IndividualBabylonFileParsers;
  34456. /**
  34457. * Adds a parser in the list of available ones
  34458. * @param name Defines the name of the parser
  34459. * @param parser Defines the parser to add
  34460. */
  34461. static AddParser(name: string, parser: BabylonFileParser): void;
  34462. /**
  34463. * Gets a general parser from the list of avaialble ones
  34464. * @param name Defines the name of the parser
  34465. * @returns the requested parser or null
  34466. */
  34467. static GetParser(name: string): Nullable<BabylonFileParser>;
  34468. /**
  34469. * Adds n individual parser in the list of available ones
  34470. * @param name Defines the name of the parser
  34471. * @param parser Defines the parser to add
  34472. */
  34473. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34474. /**
  34475. * Gets an individual parser from the list of avaialble ones
  34476. * @param name Defines the name of the parser
  34477. * @returns the requested parser or null
  34478. */
  34479. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34480. /**
  34481. * Parser json data and populate both a scene and its associated container object
  34482. * @param jsonData Defines the data to parse
  34483. * @param scene Defines the scene to parse the data for
  34484. * @param container Defines the container attached to the parsing sequence
  34485. * @param rootUrl Defines the root url of the data
  34486. */
  34487. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34488. /**
  34489. * Gets the list of root nodes (ie. nodes with no parent)
  34490. */
  34491. rootNodes: Node[];
  34492. /** All of the cameras added to this scene
  34493. * @see http://doc.babylonjs.com/babylon101/cameras
  34494. */
  34495. cameras: Camera[];
  34496. /**
  34497. * All of the lights added to this scene
  34498. * @see http://doc.babylonjs.com/babylon101/lights
  34499. */
  34500. lights: Light[];
  34501. /**
  34502. * All of the (abstract) meshes added to this scene
  34503. */
  34504. meshes: AbstractMesh[];
  34505. /**
  34506. * The list of skeletons added to the scene
  34507. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34508. */
  34509. skeletons: Skeleton[];
  34510. /**
  34511. * All of the particle systems added to this scene
  34512. * @see http://doc.babylonjs.com/babylon101/particles
  34513. */
  34514. particleSystems: IParticleSystem[];
  34515. /**
  34516. * Gets a list of Animations associated with the scene
  34517. */
  34518. animations: Animation[];
  34519. /**
  34520. * All of the animation groups added to this scene
  34521. * @see http://doc.babylonjs.com/how_to/group
  34522. */
  34523. animationGroups: AnimationGroup[];
  34524. /**
  34525. * All of the multi-materials added to this scene
  34526. * @see http://doc.babylonjs.com/how_to/multi_materials
  34527. */
  34528. multiMaterials: MultiMaterial[];
  34529. /**
  34530. * All of the materials added to this scene
  34531. * In the context of a Scene, it is not supposed to be modified manually.
  34532. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34533. * Note also that the order of the Material wihin the array is not significant and might change.
  34534. * @see http://doc.babylonjs.com/babylon101/materials
  34535. */
  34536. materials: Material[];
  34537. /**
  34538. * The list of morph target managers added to the scene
  34539. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34540. */
  34541. morphTargetManagers: MorphTargetManager[];
  34542. /**
  34543. * The list of geometries used in the scene.
  34544. */
  34545. geometries: Geometry[];
  34546. /**
  34547. * All of the tranform nodes added to this scene
  34548. * In the context of a Scene, it is not supposed to be modified manually.
  34549. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34550. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34551. * @see http://doc.babylonjs.com/how_to/transformnode
  34552. */
  34553. transformNodes: TransformNode[];
  34554. /**
  34555. * ActionManagers available on the scene.
  34556. */
  34557. actionManagers: AbstractActionManager[];
  34558. /**
  34559. * Textures to keep.
  34560. */
  34561. textures: BaseTexture[];
  34562. /**
  34563. * Environment texture for the scene
  34564. */
  34565. environmentTexture: Nullable<BaseTexture>;
  34566. }
  34567. }
  34568. declare module "babylonjs/Audio/sound" {
  34569. import { Observable } from "babylonjs/Misc/observable";
  34570. import { Vector3 } from "babylonjs/Maths/math";
  34571. import { Nullable } from "babylonjs/types";
  34572. import { Scene } from "babylonjs/scene";
  34573. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34574. /**
  34575. * Defines a sound that can be played in the application.
  34576. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34577. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34578. */
  34579. export class Sound {
  34580. /**
  34581. * The name of the sound in the scene.
  34582. */
  34583. name: string;
  34584. /**
  34585. * Does the sound autoplay once loaded.
  34586. */
  34587. autoplay: boolean;
  34588. /**
  34589. * Does the sound loop after it finishes playing once.
  34590. */
  34591. loop: boolean;
  34592. /**
  34593. * Does the sound use a custom attenuation curve to simulate the falloff
  34594. * happening when the source gets further away from the camera.
  34595. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34596. */
  34597. useCustomAttenuation: boolean;
  34598. /**
  34599. * The sound track id this sound belongs to.
  34600. */
  34601. soundTrackId: number;
  34602. /**
  34603. * Is this sound currently played.
  34604. */
  34605. isPlaying: boolean;
  34606. /**
  34607. * Is this sound currently paused.
  34608. */
  34609. isPaused: boolean;
  34610. /**
  34611. * Does this sound enables spatial sound.
  34612. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34613. */
  34614. spatialSound: boolean;
  34615. /**
  34616. * Define the reference distance the sound should be heard perfectly.
  34617. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34618. */
  34619. refDistance: number;
  34620. /**
  34621. * Define the roll off factor of spatial sounds.
  34622. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34623. */
  34624. rolloffFactor: number;
  34625. /**
  34626. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34627. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34628. */
  34629. maxDistance: number;
  34630. /**
  34631. * Define the distance attenuation model the sound will follow.
  34632. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34633. */
  34634. distanceModel: string;
  34635. /**
  34636. * @hidden
  34637. * Back Compat
  34638. **/
  34639. onended: () => any;
  34640. /**
  34641. * Observable event when the current playing sound finishes.
  34642. */
  34643. onEndedObservable: Observable<Sound>;
  34644. private _panningModel;
  34645. private _playbackRate;
  34646. private _streaming;
  34647. private _startTime;
  34648. private _startOffset;
  34649. private _position;
  34650. /** @hidden */
  34651. _positionInEmitterSpace: boolean;
  34652. private _localDirection;
  34653. private _volume;
  34654. private _isReadyToPlay;
  34655. private _isDirectional;
  34656. private _readyToPlayCallback;
  34657. private _audioBuffer;
  34658. private _soundSource;
  34659. private _streamingSource;
  34660. private _soundPanner;
  34661. private _soundGain;
  34662. private _inputAudioNode;
  34663. private _outputAudioNode;
  34664. private _coneInnerAngle;
  34665. private _coneOuterAngle;
  34666. private _coneOuterGain;
  34667. private _scene;
  34668. private _connectedTransformNode;
  34669. private _customAttenuationFunction;
  34670. private _registerFunc;
  34671. private _isOutputConnected;
  34672. private _htmlAudioElement;
  34673. private _urlType;
  34674. /** @hidden */
  34675. static _SceneComponentInitialization: (scene: Scene) => void;
  34676. /**
  34677. * Create a sound and attach it to a scene
  34678. * @param name Name of your sound
  34679. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34680. * @param scene defines the scene the sound belongs to
  34681. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34682. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34683. */
  34684. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34685. /**
  34686. * Release the sound and its associated resources
  34687. */
  34688. dispose(): void;
  34689. /**
  34690. * Gets if the sounds is ready to be played or not.
  34691. * @returns true if ready, otherwise false
  34692. */
  34693. isReady(): boolean;
  34694. private _soundLoaded;
  34695. /**
  34696. * Sets the data of the sound from an audiobuffer
  34697. * @param audioBuffer The audioBuffer containing the data
  34698. */
  34699. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34700. /**
  34701. * Updates the current sounds options such as maxdistance, loop...
  34702. * @param options A JSON object containing values named as the object properties
  34703. */
  34704. updateOptions(options: any): void;
  34705. private _createSpatialParameters;
  34706. private _updateSpatialParameters;
  34707. /**
  34708. * Switch the panning model to HRTF:
  34709. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34710. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34711. */
  34712. switchPanningModelToHRTF(): void;
  34713. /**
  34714. * Switch the panning model to Equal Power:
  34715. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34716. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34717. */
  34718. switchPanningModelToEqualPower(): void;
  34719. private _switchPanningModel;
  34720. /**
  34721. * Connect this sound to a sound track audio node like gain...
  34722. * @param soundTrackAudioNode the sound track audio node to connect to
  34723. */
  34724. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34725. /**
  34726. * Transform this sound into a directional source
  34727. * @param coneInnerAngle Size of the inner cone in degree
  34728. * @param coneOuterAngle Size of the outer cone in degree
  34729. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34730. */
  34731. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34732. /**
  34733. * Gets or sets the inner angle for the directional cone.
  34734. */
  34735. /**
  34736. * Gets or sets the inner angle for the directional cone.
  34737. */
  34738. directionalConeInnerAngle: number;
  34739. /**
  34740. * Gets or sets the outer angle for the directional cone.
  34741. */
  34742. /**
  34743. * Gets or sets the outer angle for the directional cone.
  34744. */
  34745. directionalConeOuterAngle: number;
  34746. /**
  34747. * Sets the position of the emitter if spatial sound is enabled
  34748. * @param newPosition Defines the new posisiton
  34749. */
  34750. setPosition(newPosition: Vector3): void;
  34751. /**
  34752. * Sets the local direction of the emitter if spatial sound is enabled
  34753. * @param newLocalDirection Defines the new local direction
  34754. */
  34755. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34756. private _updateDirection;
  34757. /** @hidden */
  34758. updateDistanceFromListener(): void;
  34759. /**
  34760. * Sets a new custom attenuation function for the sound.
  34761. * @param callback Defines the function used for the attenuation
  34762. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34763. */
  34764. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34765. /**
  34766. * Play the sound
  34767. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34768. * @param offset (optional) Start the sound setting it at a specific time
  34769. */
  34770. play(time?: number, offset?: number): void;
  34771. private _onended;
  34772. /**
  34773. * Stop the sound
  34774. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34775. */
  34776. stop(time?: number): void;
  34777. /**
  34778. * Put the sound in pause
  34779. */
  34780. pause(): void;
  34781. /**
  34782. * Sets a dedicated volume for this sounds
  34783. * @param newVolume Define the new volume of the sound
  34784. * @param time Define in how long the sound should be at this value
  34785. */
  34786. setVolume(newVolume: number, time?: number): void;
  34787. /**
  34788. * Set the sound play back rate
  34789. * @param newPlaybackRate Define the playback rate the sound should be played at
  34790. */
  34791. setPlaybackRate(newPlaybackRate: number): void;
  34792. /**
  34793. * Gets the volume of the sound.
  34794. * @returns the volume of the sound
  34795. */
  34796. getVolume(): number;
  34797. /**
  34798. * Attach the sound to a dedicated mesh
  34799. * @param transformNode The transform node to connect the sound with
  34800. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34801. */
  34802. attachToMesh(transformNode: TransformNode): void;
  34803. /**
  34804. * Detach the sound from the previously attached mesh
  34805. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34806. */
  34807. detachFromMesh(): void;
  34808. private _onRegisterAfterWorldMatrixUpdate;
  34809. /**
  34810. * Clone the current sound in the scene.
  34811. * @returns the new sound clone
  34812. */
  34813. clone(): Nullable<Sound>;
  34814. /**
  34815. * Gets the current underlying audio buffer containing the data
  34816. * @returns the audio buffer
  34817. */
  34818. getAudioBuffer(): Nullable<AudioBuffer>;
  34819. /**
  34820. * Serializes the Sound in a JSON representation
  34821. * @returns the JSON representation of the sound
  34822. */
  34823. serialize(): any;
  34824. /**
  34825. * Parse a JSON representation of a sound to innstantiate in a given scene
  34826. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34827. * @param scene Define the scene the new parsed sound should be created in
  34828. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34829. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34830. * @returns the newly parsed sound
  34831. */
  34832. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34833. }
  34834. }
  34835. declare module "babylonjs/Actions/directAudioActions" {
  34836. import { Action } from "babylonjs/Actions/action";
  34837. import { Condition } from "babylonjs/Actions/condition";
  34838. import { Sound } from "babylonjs/Audio/sound";
  34839. /**
  34840. * This defines an action helpful to play a defined sound on a triggered action.
  34841. */
  34842. export class PlaySoundAction extends Action {
  34843. private _sound;
  34844. /**
  34845. * Instantiate the action
  34846. * @param triggerOptions defines the trigger options
  34847. * @param sound defines the sound to play
  34848. * @param condition defines the trigger related conditions
  34849. */
  34850. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34851. /** @hidden */
  34852. _prepare(): void;
  34853. /**
  34854. * Execute the action and play the sound.
  34855. */
  34856. execute(): void;
  34857. /**
  34858. * Serializes the actions and its related information.
  34859. * @param parent defines the object to serialize in
  34860. * @returns the serialized object
  34861. */
  34862. serialize(parent: any): any;
  34863. }
  34864. /**
  34865. * This defines an action helpful to stop a defined sound on a triggered action.
  34866. */
  34867. export class StopSoundAction extends Action {
  34868. private _sound;
  34869. /**
  34870. * Instantiate the action
  34871. * @param triggerOptions defines the trigger options
  34872. * @param sound defines the sound to stop
  34873. * @param condition defines the trigger related conditions
  34874. */
  34875. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34876. /** @hidden */
  34877. _prepare(): void;
  34878. /**
  34879. * Execute the action and stop the sound.
  34880. */
  34881. execute(): void;
  34882. /**
  34883. * Serializes the actions and its related information.
  34884. * @param parent defines the object to serialize in
  34885. * @returns the serialized object
  34886. */
  34887. serialize(parent: any): any;
  34888. }
  34889. }
  34890. declare module "babylonjs/Actions/interpolateValueAction" {
  34891. import { Action } from "babylonjs/Actions/action";
  34892. import { Condition } from "babylonjs/Actions/condition";
  34893. import { Observable } from "babylonjs/Misc/observable";
  34894. /**
  34895. * This defines an action responsible to change the value of a property
  34896. * by interpolating between its current value and the newly set one once triggered.
  34897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34898. */
  34899. export class InterpolateValueAction extends Action {
  34900. /**
  34901. * Defines the path of the property where the value should be interpolated
  34902. */
  34903. propertyPath: string;
  34904. /**
  34905. * Defines the target value at the end of the interpolation.
  34906. */
  34907. value: any;
  34908. /**
  34909. * Defines the time it will take for the property to interpolate to the value.
  34910. */
  34911. duration: number;
  34912. /**
  34913. * Defines if the other scene animations should be stopped when the action has been triggered
  34914. */
  34915. stopOtherAnimations?: boolean;
  34916. /**
  34917. * Defines a callback raised once the interpolation animation has been done.
  34918. */
  34919. onInterpolationDone?: () => void;
  34920. /**
  34921. * Observable triggered once the interpolation animation has been done.
  34922. */
  34923. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34924. private _target;
  34925. private _effectiveTarget;
  34926. private _property;
  34927. /**
  34928. * Instantiate the action
  34929. * @param triggerOptions defines the trigger options
  34930. * @param target defines the object containing the value to interpolate
  34931. * @param propertyPath defines the path to the property in the target object
  34932. * @param value defines the target value at the end of the interpolation
  34933. * @param duration deines the time it will take for the property to interpolate to the value.
  34934. * @param condition defines the trigger related conditions
  34935. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34936. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34937. */
  34938. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34939. /** @hidden */
  34940. _prepare(): void;
  34941. /**
  34942. * Execute the action starts the value interpolation.
  34943. */
  34944. execute(): void;
  34945. /**
  34946. * Serializes the actions and its related information.
  34947. * @param parent defines the object to serialize in
  34948. * @returns the serialized object
  34949. */
  34950. serialize(parent: any): any;
  34951. }
  34952. }
  34953. declare module "babylonjs/Actions/index" {
  34954. export * from "babylonjs/Actions/action";
  34955. export * from "babylonjs/Actions/actionEvent";
  34956. export * from "babylonjs/Actions/actionManager";
  34957. export * from "babylonjs/Actions/condition";
  34958. export * from "babylonjs/Actions/directActions";
  34959. export * from "babylonjs/Actions/directAudioActions";
  34960. export * from "babylonjs/Actions/interpolateValueAction";
  34961. }
  34962. declare module "babylonjs/Animations/index" {
  34963. export * from "babylonjs/Animations/animatable";
  34964. export * from "babylonjs/Animations/animation";
  34965. export * from "babylonjs/Animations/animationGroup";
  34966. export * from "babylonjs/Animations/animationPropertiesOverride";
  34967. export * from "babylonjs/Animations/easing";
  34968. export * from "babylonjs/Animations/runtimeAnimation";
  34969. export * from "babylonjs/Animations/animationEvent";
  34970. export * from "babylonjs/Animations/animationGroup";
  34971. export * from "babylonjs/Animations/animationKey";
  34972. export * from "babylonjs/Animations/animationRange";
  34973. }
  34974. declare module "babylonjs/Audio/soundTrack" {
  34975. import { Sound } from "babylonjs/Audio/sound";
  34976. import { Analyser } from "babylonjs/Audio/analyser";
  34977. import { Scene } from "babylonjs/scene";
  34978. /**
  34979. * Options allowed during the creation of a sound track.
  34980. */
  34981. export interface ISoundTrackOptions {
  34982. /**
  34983. * The volume the sound track should take during creation
  34984. */
  34985. volume?: number;
  34986. /**
  34987. * Define if the sound track is the main sound track of the scene
  34988. */
  34989. mainTrack?: boolean;
  34990. }
  34991. /**
  34992. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34993. * It will be also used in a future release to apply effects on a specific track.
  34994. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34995. */
  34996. export class SoundTrack {
  34997. /**
  34998. * The unique identifier of the sound track in the scene.
  34999. */
  35000. id: number;
  35001. /**
  35002. * The list of sounds included in the sound track.
  35003. */
  35004. soundCollection: Array<Sound>;
  35005. private _outputAudioNode;
  35006. private _scene;
  35007. private _isMainTrack;
  35008. private _connectedAnalyser;
  35009. private _options;
  35010. private _isInitialized;
  35011. /**
  35012. * Creates a new sound track.
  35013. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35014. * @param scene Define the scene the sound track belongs to
  35015. * @param options
  35016. */
  35017. constructor(scene: Scene, options?: ISoundTrackOptions);
  35018. private _initializeSoundTrackAudioGraph;
  35019. /**
  35020. * Release the sound track and its associated resources
  35021. */
  35022. dispose(): void;
  35023. /**
  35024. * Adds a sound to this sound track
  35025. * @param sound define the cound to add
  35026. * @ignoreNaming
  35027. */
  35028. AddSound(sound: Sound): void;
  35029. /**
  35030. * Removes a sound to this sound track
  35031. * @param sound define the cound to remove
  35032. * @ignoreNaming
  35033. */
  35034. RemoveSound(sound: Sound): void;
  35035. /**
  35036. * Set a global volume for the full sound track.
  35037. * @param newVolume Define the new volume of the sound track
  35038. */
  35039. setVolume(newVolume: number): void;
  35040. /**
  35041. * Switch the panning model to HRTF:
  35042. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35043. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35044. */
  35045. switchPanningModelToHRTF(): void;
  35046. /**
  35047. * Switch the panning model to Equal Power:
  35048. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35049. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35050. */
  35051. switchPanningModelToEqualPower(): void;
  35052. /**
  35053. * Connect the sound track to an audio analyser allowing some amazing
  35054. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35055. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35056. * @param analyser The analyser to connect to the engine
  35057. */
  35058. connectToAnalyser(analyser: Analyser): void;
  35059. }
  35060. }
  35061. declare module "babylonjs/Audio/audioSceneComponent" {
  35062. import { Sound } from "babylonjs/Audio/sound";
  35063. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35064. import { Nullable } from "babylonjs/types";
  35065. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35066. import { Scene } from "babylonjs/scene";
  35067. import { AbstractScene } from "babylonjs/abstractScene";
  35068. module "babylonjs/abstractScene" {
  35069. interface AbstractScene {
  35070. /**
  35071. * The list of sounds used in the scene.
  35072. */
  35073. sounds: Nullable<Array<Sound>>;
  35074. }
  35075. }
  35076. module "babylonjs/scene" {
  35077. interface Scene {
  35078. /**
  35079. * @hidden
  35080. * Backing field
  35081. */
  35082. _mainSoundTrack: SoundTrack;
  35083. /**
  35084. * The main sound track played by the scene.
  35085. * It cotains your primary collection of sounds.
  35086. */
  35087. mainSoundTrack: SoundTrack;
  35088. /**
  35089. * The list of sound tracks added to the scene
  35090. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35091. */
  35092. soundTracks: Nullable<Array<SoundTrack>>;
  35093. /**
  35094. * Gets a sound using a given name
  35095. * @param name defines the name to search for
  35096. * @return the found sound or null if not found at all.
  35097. */
  35098. getSoundByName(name: string): Nullable<Sound>;
  35099. /**
  35100. * Gets or sets if audio support is enabled
  35101. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35102. */
  35103. audioEnabled: boolean;
  35104. /**
  35105. * Gets or sets if audio will be output to headphones
  35106. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35107. */
  35108. headphone: boolean;
  35109. }
  35110. }
  35111. /**
  35112. * Defines the sound scene component responsible to manage any sounds
  35113. * in a given scene.
  35114. */
  35115. export class AudioSceneComponent implements ISceneSerializableComponent {
  35116. /**
  35117. * The component name helpfull to identify the component in the list of scene components.
  35118. */
  35119. readonly name: string;
  35120. /**
  35121. * The scene the component belongs to.
  35122. */
  35123. scene: Scene;
  35124. private _audioEnabled;
  35125. /**
  35126. * Gets whether audio is enabled or not.
  35127. * Please use related enable/disable method to switch state.
  35128. */
  35129. readonly audioEnabled: boolean;
  35130. private _headphone;
  35131. /**
  35132. * Gets whether audio is outputing to headphone or not.
  35133. * Please use the according Switch methods to change output.
  35134. */
  35135. readonly headphone: boolean;
  35136. /**
  35137. * Creates a new instance of the component for the given scene
  35138. * @param scene Defines the scene to register the component in
  35139. */
  35140. constructor(scene: Scene);
  35141. /**
  35142. * Registers the component in a given scene
  35143. */
  35144. register(): void;
  35145. /**
  35146. * Rebuilds the elements related to this component in case of
  35147. * context lost for instance.
  35148. */
  35149. rebuild(): void;
  35150. /**
  35151. * Serializes the component data to the specified json object
  35152. * @param serializationObject The object to serialize to
  35153. */
  35154. serialize(serializationObject: any): void;
  35155. /**
  35156. * Adds all the element from the container to the scene
  35157. * @param container the container holding the elements
  35158. */
  35159. addFromContainer(container: AbstractScene): void;
  35160. /**
  35161. * Removes all the elements in the container from the scene
  35162. * @param container contains the elements to remove
  35163. * @param dispose if the removed element should be disposed (default: false)
  35164. */
  35165. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35166. /**
  35167. * Disposes the component and the associated ressources.
  35168. */
  35169. dispose(): void;
  35170. /**
  35171. * Disables audio in the associated scene.
  35172. */
  35173. disableAudio(): void;
  35174. /**
  35175. * Enables audio in the associated scene.
  35176. */
  35177. enableAudio(): void;
  35178. /**
  35179. * Switch audio to headphone output.
  35180. */
  35181. switchAudioModeForHeadphones(): void;
  35182. /**
  35183. * Switch audio to normal speakers.
  35184. */
  35185. switchAudioModeForNormalSpeakers(): void;
  35186. private _afterRender;
  35187. }
  35188. }
  35189. declare module "babylonjs/Audio/weightedsound" {
  35190. import { Sound } from "babylonjs/Audio/sound";
  35191. /**
  35192. * Wraps one or more Sound objects and selects one with random weight for playback.
  35193. */
  35194. export class WeightedSound {
  35195. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35196. loop: boolean;
  35197. private _coneInnerAngle;
  35198. private _coneOuterAngle;
  35199. private _volume;
  35200. /** A Sound is currently playing. */
  35201. isPlaying: boolean;
  35202. /** A Sound is currently paused. */
  35203. isPaused: boolean;
  35204. private _sounds;
  35205. private _weights;
  35206. private _currentIndex?;
  35207. /**
  35208. * Creates a new WeightedSound from the list of sounds given.
  35209. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35210. * @param sounds Array of Sounds that will be selected from.
  35211. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35212. */
  35213. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35214. /**
  35215. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35216. */
  35217. /**
  35218. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35219. */
  35220. directionalConeInnerAngle: number;
  35221. /**
  35222. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35223. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35224. */
  35225. /**
  35226. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35227. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35228. */
  35229. directionalConeOuterAngle: number;
  35230. /**
  35231. * Playback volume.
  35232. */
  35233. /**
  35234. * Playback volume.
  35235. */
  35236. volume: number;
  35237. private _onended;
  35238. /**
  35239. * Suspend playback
  35240. */
  35241. pause(): void;
  35242. /**
  35243. * Stop playback
  35244. */
  35245. stop(): void;
  35246. /**
  35247. * Start playback.
  35248. * @param startOffset Position the clip head at a specific time in seconds.
  35249. */
  35250. play(startOffset?: number): void;
  35251. }
  35252. }
  35253. declare module "babylonjs/Audio/index" {
  35254. export * from "babylonjs/Audio/analyser";
  35255. export * from "babylonjs/Audio/audioEngine";
  35256. export * from "babylonjs/Audio/audioSceneComponent";
  35257. export * from "babylonjs/Audio/sound";
  35258. export * from "babylonjs/Audio/soundTrack";
  35259. export * from "babylonjs/Audio/weightedsound";
  35260. }
  35261. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35262. import { Behavior } from "babylonjs/Behaviors/behavior";
  35263. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35264. import { BackEase } from "babylonjs/Animations/easing";
  35265. /**
  35266. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35267. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35268. */
  35269. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35270. /**
  35271. * Gets the name of the behavior.
  35272. */
  35273. readonly name: string;
  35274. /**
  35275. * The easing function used by animations
  35276. */
  35277. static EasingFunction: BackEase;
  35278. /**
  35279. * The easing mode used by animations
  35280. */
  35281. static EasingMode: number;
  35282. /**
  35283. * The duration of the animation, in milliseconds
  35284. */
  35285. transitionDuration: number;
  35286. /**
  35287. * Length of the distance animated by the transition when lower radius is reached
  35288. */
  35289. lowerRadiusTransitionRange: number;
  35290. /**
  35291. * Length of the distance animated by the transition when upper radius is reached
  35292. */
  35293. upperRadiusTransitionRange: number;
  35294. private _autoTransitionRange;
  35295. /**
  35296. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35297. */
  35298. /**
  35299. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35300. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35301. */
  35302. autoTransitionRange: boolean;
  35303. private _attachedCamera;
  35304. private _onAfterCheckInputsObserver;
  35305. private _onMeshTargetChangedObserver;
  35306. /**
  35307. * Initializes the behavior.
  35308. */
  35309. init(): void;
  35310. /**
  35311. * Attaches the behavior to its arc rotate camera.
  35312. * @param camera Defines the camera to attach the behavior to
  35313. */
  35314. attach(camera: ArcRotateCamera): void;
  35315. /**
  35316. * Detaches the behavior from its current arc rotate camera.
  35317. */
  35318. detach(): void;
  35319. private _radiusIsAnimating;
  35320. private _radiusBounceTransition;
  35321. private _animatables;
  35322. private _cachedWheelPrecision;
  35323. /**
  35324. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35325. * @param radiusLimit The limit to check against.
  35326. * @return Bool to indicate if at limit.
  35327. */
  35328. private _isRadiusAtLimit;
  35329. /**
  35330. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35331. * @param radiusDelta The delta by which to animate to. Can be negative.
  35332. */
  35333. private _applyBoundRadiusAnimation;
  35334. /**
  35335. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35336. */
  35337. protected _clearAnimationLocks(): void;
  35338. /**
  35339. * Stops and removes all animations that have been applied to the camera
  35340. */
  35341. stopAllAnimations(): void;
  35342. }
  35343. }
  35344. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35345. import { Behavior } from "babylonjs/Behaviors/behavior";
  35346. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35347. import { ExponentialEase } from "babylonjs/Animations/easing";
  35348. import { Nullable } from "babylonjs/types";
  35349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35350. import { Vector3 } from "babylonjs/Maths/math";
  35351. /**
  35352. * 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.
  35353. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35354. */
  35355. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35356. /**
  35357. * Gets the name of the behavior.
  35358. */
  35359. readonly name: string;
  35360. private _mode;
  35361. private _radiusScale;
  35362. private _positionScale;
  35363. private _defaultElevation;
  35364. private _elevationReturnTime;
  35365. private _elevationReturnWaitTime;
  35366. private _zoomStopsAnimation;
  35367. private _framingTime;
  35368. /**
  35369. * The easing function used by animations
  35370. */
  35371. static EasingFunction: ExponentialEase;
  35372. /**
  35373. * The easing mode used by animations
  35374. */
  35375. static EasingMode: number;
  35376. /**
  35377. * Sets the current mode used by the behavior
  35378. */
  35379. /**
  35380. * Gets current mode used by the behavior.
  35381. */
  35382. mode: number;
  35383. /**
  35384. * Sets the scale applied to the radius (1 by default)
  35385. */
  35386. /**
  35387. * Gets the scale applied to the radius
  35388. */
  35389. radiusScale: number;
  35390. /**
  35391. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35392. */
  35393. /**
  35394. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35395. */
  35396. positionScale: number;
  35397. /**
  35398. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35399. * behaviour is triggered, in radians.
  35400. */
  35401. /**
  35402. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35403. * behaviour is triggered, in radians.
  35404. */
  35405. defaultElevation: number;
  35406. /**
  35407. * Sets the time (in milliseconds) taken to return to the default beta position.
  35408. * Negative value indicates camera should not return to default.
  35409. */
  35410. /**
  35411. * Gets the time (in milliseconds) taken to return to the default beta position.
  35412. * Negative value indicates camera should not return to default.
  35413. */
  35414. elevationReturnTime: number;
  35415. /**
  35416. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35417. */
  35418. /**
  35419. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35420. */
  35421. elevationReturnWaitTime: number;
  35422. /**
  35423. * Sets the flag that indicates if user zooming should stop animation.
  35424. */
  35425. /**
  35426. * Gets the flag that indicates if user zooming should stop animation.
  35427. */
  35428. zoomStopsAnimation: boolean;
  35429. /**
  35430. * Sets the transition time when framing the mesh, in milliseconds
  35431. */
  35432. /**
  35433. * Gets the transition time when framing the mesh, in milliseconds
  35434. */
  35435. framingTime: number;
  35436. /**
  35437. * Define if the behavior should automatically change the configured
  35438. * camera limits and sensibilities.
  35439. */
  35440. autoCorrectCameraLimitsAndSensibility: boolean;
  35441. private _onPrePointerObservableObserver;
  35442. private _onAfterCheckInputsObserver;
  35443. private _onMeshTargetChangedObserver;
  35444. private _attachedCamera;
  35445. private _isPointerDown;
  35446. private _lastInteractionTime;
  35447. /**
  35448. * Initializes the behavior.
  35449. */
  35450. init(): void;
  35451. /**
  35452. * Attaches the behavior to its arc rotate camera.
  35453. * @param camera Defines the camera to attach the behavior to
  35454. */
  35455. attach(camera: ArcRotateCamera): void;
  35456. /**
  35457. * Detaches the behavior from its current arc rotate camera.
  35458. */
  35459. detach(): void;
  35460. private _animatables;
  35461. private _betaIsAnimating;
  35462. private _betaTransition;
  35463. private _radiusTransition;
  35464. private _vectorTransition;
  35465. /**
  35466. * Targets the given mesh and updates zoom level accordingly.
  35467. * @param mesh The mesh to target.
  35468. * @param radius Optional. If a cached radius position already exists, overrides default.
  35469. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35470. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35471. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35472. */
  35473. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35474. /**
  35475. * Targets the given mesh with its children and updates zoom level accordingly.
  35476. * @param mesh The mesh to target.
  35477. * @param radius Optional. If a cached radius position already exists, overrides default.
  35478. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35479. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35480. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35481. */
  35482. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35483. /**
  35484. * Targets the given meshes with their children and updates zoom level accordingly.
  35485. * @param meshes The mesh to target.
  35486. * @param radius Optional. If a cached radius position already exists, overrides default.
  35487. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35488. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35489. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35490. */
  35491. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35492. /**
  35493. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35494. * @param minimumWorld Determines the smaller position of the bounding box extend
  35495. * @param maximumWorld Determines the bigger position of the bounding box extend
  35496. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35497. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35498. */
  35499. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35500. /**
  35501. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35502. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35503. * frustum width.
  35504. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35505. * to fully enclose the mesh in the viewing frustum.
  35506. */
  35507. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35508. /**
  35509. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35510. * is automatically returned to its default position (expected to be above ground plane).
  35511. */
  35512. private _maintainCameraAboveGround;
  35513. /**
  35514. * Returns the frustum slope based on the canvas ratio and camera FOV
  35515. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35516. */
  35517. private _getFrustumSlope;
  35518. /**
  35519. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35520. */
  35521. private _clearAnimationLocks;
  35522. /**
  35523. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35524. */
  35525. private _applyUserInteraction;
  35526. /**
  35527. * Stops and removes all animations that have been applied to the camera
  35528. */
  35529. stopAllAnimations(): void;
  35530. /**
  35531. * Gets a value indicating if the user is moving the camera
  35532. */
  35533. readonly isUserIsMoving: boolean;
  35534. /**
  35535. * The camera can move all the way towards the mesh.
  35536. */
  35537. static IgnoreBoundsSizeMode: number;
  35538. /**
  35539. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35540. */
  35541. static FitFrustumSidesMode: number;
  35542. }
  35543. }
  35544. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35545. import { Nullable } from "babylonjs/types";
  35546. import { Camera } from "babylonjs/Cameras/camera";
  35547. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35548. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35549. /**
  35550. * Base class for Camera Pointer Inputs.
  35551. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35552. * for example usage.
  35553. */
  35554. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35555. /**
  35556. * Defines the camera the input is attached to.
  35557. */
  35558. abstract camera: Camera;
  35559. /**
  35560. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35561. */
  35562. protected _altKey: boolean;
  35563. protected _ctrlKey: boolean;
  35564. protected _metaKey: boolean;
  35565. protected _shiftKey: boolean;
  35566. /**
  35567. * Which mouse buttons were pressed at time of last mouse event.
  35568. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35569. */
  35570. protected _buttonsPressed: number;
  35571. /**
  35572. * Defines the buttons associated with the input to handle camera move.
  35573. */
  35574. buttons: number[];
  35575. /**
  35576. * Attach the input controls to a specific dom element to get the input from.
  35577. * @param element Defines the element the controls should be listened from
  35578. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35579. */
  35580. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35581. /**
  35582. * Detach the current controls from the specified dom element.
  35583. * @param element Defines the element to stop listening the inputs from
  35584. */
  35585. detachControl(element: Nullable<HTMLElement>): void;
  35586. /**
  35587. * Gets the class name of the current input.
  35588. * @returns the class name
  35589. */
  35590. getClassName(): string;
  35591. /**
  35592. * Get the friendly name associated with the input class.
  35593. * @returns the input friendly name
  35594. */
  35595. getSimpleName(): string;
  35596. /**
  35597. * Called on pointer POINTERDOUBLETAP event.
  35598. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35599. */
  35600. protected onDoubleTap(type: string): void;
  35601. /**
  35602. * Called on pointer POINTERMOVE event if only a single touch is active.
  35603. * Override this method to provide functionality.
  35604. */
  35605. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35606. /**
  35607. * Called on pointer POINTERMOVE event if multiple touches are active.
  35608. * Override this method to provide functionality.
  35609. */
  35610. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35611. /**
  35612. * Called on JS contextmenu event.
  35613. * Override this method to provide functionality.
  35614. */
  35615. protected onContextMenu(evt: PointerEvent): void;
  35616. /**
  35617. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35618. * press.
  35619. * Override this method to provide functionality.
  35620. */
  35621. protected onButtonDown(evt: PointerEvent): void;
  35622. /**
  35623. * Called each time a new POINTERUP event occurs. Ie, for each button
  35624. * release.
  35625. * Override this method to provide functionality.
  35626. */
  35627. protected onButtonUp(evt: PointerEvent): void;
  35628. /**
  35629. * Called when window becomes inactive.
  35630. * Override this method to provide functionality.
  35631. */
  35632. protected onLostFocus(): void;
  35633. private _pointerInput;
  35634. private _observer;
  35635. private _onLostFocus;
  35636. private pointA;
  35637. private pointB;
  35638. }
  35639. }
  35640. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35641. import { Nullable } from "babylonjs/types";
  35642. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35643. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35644. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35645. /**
  35646. * Manage the pointers inputs to control an arc rotate camera.
  35647. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35648. */
  35649. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35650. /**
  35651. * Defines the camera the input is attached to.
  35652. */
  35653. camera: ArcRotateCamera;
  35654. /**
  35655. * Gets the class name of the current input.
  35656. * @returns the class name
  35657. */
  35658. getClassName(): string;
  35659. /**
  35660. * Defines the buttons associated with the input to handle camera move.
  35661. */
  35662. buttons: number[];
  35663. /**
  35664. * Defines the pointer angular sensibility along the X axis or how fast is
  35665. * the camera rotating.
  35666. */
  35667. angularSensibilityX: number;
  35668. /**
  35669. * Defines the pointer angular sensibility along the Y axis or how fast is
  35670. * the camera rotating.
  35671. */
  35672. angularSensibilityY: number;
  35673. /**
  35674. * Defines the pointer pinch precision or how fast is the camera zooming.
  35675. */
  35676. pinchPrecision: number;
  35677. /**
  35678. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35679. * from 0.
  35680. * It defines the percentage of current camera.radius to use as delta when
  35681. * pinch zoom is used.
  35682. */
  35683. pinchDeltaPercentage: number;
  35684. /**
  35685. * Defines the pointer panning sensibility or how fast is the camera moving.
  35686. */
  35687. panningSensibility: number;
  35688. /**
  35689. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35690. */
  35691. multiTouchPanning: boolean;
  35692. /**
  35693. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35694. * zoom (pinch) through multitouch.
  35695. */
  35696. multiTouchPanAndZoom: boolean;
  35697. /**
  35698. * Revers pinch action direction.
  35699. */
  35700. pinchInwards: boolean;
  35701. private _isPanClick;
  35702. private _twoFingerActivityCount;
  35703. private _isPinching;
  35704. /**
  35705. * Called on pointer POINTERMOVE event if only a single touch is active.
  35706. */
  35707. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35708. /**
  35709. * Called on pointer POINTERDOUBLETAP event.
  35710. */
  35711. protected onDoubleTap(type: string): void;
  35712. /**
  35713. * Called on pointer POINTERMOVE event if multiple touches are active.
  35714. */
  35715. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35716. /**
  35717. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35718. * press.
  35719. */
  35720. protected onButtonDown(evt: PointerEvent): void;
  35721. /**
  35722. * Called each time a new POINTERUP event occurs. Ie, for each button
  35723. * release.
  35724. */
  35725. protected onButtonUp(evt: PointerEvent): void;
  35726. /**
  35727. * Called when window becomes inactive.
  35728. */
  35729. protected onLostFocus(): void;
  35730. }
  35731. }
  35732. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35733. import { Nullable } from "babylonjs/types";
  35734. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35735. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35736. /**
  35737. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35738. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35739. */
  35740. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35741. /**
  35742. * Defines the camera the input is attached to.
  35743. */
  35744. camera: ArcRotateCamera;
  35745. /**
  35746. * Defines the list of key codes associated with the up action (increase alpha)
  35747. */
  35748. keysUp: number[];
  35749. /**
  35750. * Defines the list of key codes associated with the down action (decrease alpha)
  35751. */
  35752. keysDown: number[];
  35753. /**
  35754. * Defines the list of key codes associated with the left action (increase beta)
  35755. */
  35756. keysLeft: number[];
  35757. /**
  35758. * Defines the list of key codes associated with the right action (decrease beta)
  35759. */
  35760. keysRight: number[];
  35761. /**
  35762. * Defines the list of key codes associated with the reset action.
  35763. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35764. */
  35765. keysReset: number[];
  35766. /**
  35767. * Defines the panning sensibility of the inputs.
  35768. * (How fast is the camera paning)
  35769. */
  35770. panningSensibility: number;
  35771. /**
  35772. * Defines the zooming sensibility of the inputs.
  35773. * (How fast is the camera zooming)
  35774. */
  35775. zoomingSensibility: number;
  35776. /**
  35777. * Defines wether maintaining the alt key down switch the movement mode from
  35778. * orientation to zoom.
  35779. */
  35780. useAltToZoom: boolean;
  35781. /**
  35782. * Rotation speed of the camera
  35783. */
  35784. angularSpeed: number;
  35785. private _keys;
  35786. private _ctrlPressed;
  35787. private _altPressed;
  35788. private _onCanvasBlurObserver;
  35789. private _onKeyboardObserver;
  35790. private _engine;
  35791. private _scene;
  35792. /**
  35793. * Attach the input controls to a specific dom element to get the input from.
  35794. * @param element Defines the element the controls should be listened from
  35795. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35796. */
  35797. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35798. /**
  35799. * Detach the current controls from the specified dom element.
  35800. * @param element Defines the element to stop listening the inputs from
  35801. */
  35802. detachControl(element: Nullable<HTMLElement>): void;
  35803. /**
  35804. * Update the current camera state depending on the inputs that have been used this frame.
  35805. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35806. */
  35807. checkInputs(): void;
  35808. /**
  35809. * Gets the class name of the current intput.
  35810. * @returns the class name
  35811. */
  35812. getClassName(): string;
  35813. /**
  35814. * Get the friendly name associated with the input class.
  35815. * @returns the input friendly name
  35816. */
  35817. getSimpleName(): string;
  35818. }
  35819. }
  35820. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35821. import { Nullable } from "babylonjs/types";
  35822. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35823. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35824. /**
  35825. * Manage the mouse wheel inputs to control an arc rotate camera.
  35826. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35827. */
  35828. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35829. /**
  35830. * Defines the camera the input is attached to.
  35831. */
  35832. camera: ArcRotateCamera;
  35833. /**
  35834. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35835. */
  35836. wheelPrecision: number;
  35837. /**
  35838. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35839. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35840. */
  35841. wheelDeltaPercentage: number;
  35842. private _wheel;
  35843. private _observer;
  35844. /**
  35845. * Attach the input controls to a specific dom element to get the input from.
  35846. * @param element Defines the element the controls should be listened from
  35847. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35848. */
  35849. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35850. /**
  35851. * Detach the current controls from the specified dom element.
  35852. * @param element Defines the element to stop listening the inputs from
  35853. */
  35854. detachControl(element: Nullable<HTMLElement>): void;
  35855. /**
  35856. * Gets the class name of the current intput.
  35857. * @returns the class name
  35858. */
  35859. getClassName(): string;
  35860. /**
  35861. * Get the friendly name associated with the input class.
  35862. * @returns the input friendly name
  35863. */
  35864. getSimpleName(): string;
  35865. }
  35866. }
  35867. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35868. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35869. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35870. /**
  35871. * Default Inputs manager for the ArcRotateCamera.
  35872. * It groups all the default supported inputs for ease of use.
  35873. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35874. */
  35875. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35876. /**
  35877. * Instantiates a new ArcRotateCameraInputsManager.
  35878. * @param camera Defines the camera the inputs belong to
  35879. */
  35880. constructor(camera: ArcRotateCamera);
  35881. /**
  35882. * Add mouse wheel input support to the input manager.
  35883. * @returns the current input manager
  35884. */
  35885. addMouseWheel(): ArcRotateCameraInputsManager;
  35886. /**
  35887. * Add pointers input support to the input manager.
  35888. * @returns the current input manager
  35889. */
  35890. addPointers(): ArcRotateCameraInputsManager;
  35891. /**
  35892. * Add keyboard input support to the input manager.
  35893. * @returns the current input manager
  35894. */
  35895. addKeyboard(): ArcRotateCameraInputsManager;
  35896. }
  35897. }
  35898. declare module "babylonjs/Cameras/arcRotateCamera" {
  35899. import { Observable } from "babylonjs/Misc/observable";
  35900. import { Nullable } from "babylonjs/types";
  35901. import { Scene } from "babylonjs/scene";
  35902. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35904. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35905. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35906. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35907. import { Camera } from "babylonjs/Cameras/camera";
  35908. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35909. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35910. import { Collider } from "babylonjs/Collisions/collider";
  35911. /**
  35912. * This represents an orbital type of camera.
  35913. *
  35914. * 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.
  35915. * 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.
  35916. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35917. */
  35918. export class ArcRotateCamera extends TargetCamera {
  35919. /**
  35920. * Defines the rotation angle of the camera along the longitudinal axis.
  35921. */
  35922. alpha: number;
  35923. /**
  35924. * Defines the rotation angle of the camera along the latitudinal axis.
  35925. */
  35926. beta: number;
  35927. /**
  35928. * Defines the radius of the camera from it s target point.
  35929. */
  35930. radius: number;
  35931. protected _target: Vector3;
  35932. protected _targetHost: Nullable<AbstractMesh>;
  35933. /**
  35934. * Defines the target point of the camera.
  35935. * The camera looks towards it form the radius distance.
  35936. */
  35937. target: Vector3;
  35938. /**
  35939. * Define the current local position of the camera in the scene
  35940. */
  35941. position: Vector3;
  35942. protected _upVector: Vector3;
  35943. protected _upToYMatrix: Matrix;
  35944. protected _YToUpMatrix: Matrix;
  35945. /**
  35946. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35947. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35948. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35949. */
  35950. upVector: Vector3;
  35951. /**
  35952. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35953. */
  35954. setMatUp(): void;
  35955. /**
  35956. * Current inertia value on the longitudinal axis.
  35957. * The bigger this number the longer it will take for the camera to stop.
  35958. */
  35959. inertialAlphaOffset: number;
  35960. /**
  35961. * Current inertia value on the latitudinal axis.
  35962. * The bigger this number the longer it will take for the camera to stop.
  35963. */
  35964. inertialBetaOffset: number;
  35965. /**
  35966. * Current inertia value on the radius axis.
  35967. * The bigger this number the longer it will take for the camera to stop.
  35968. */
  35969. inertialRadiusOffset: number;
  35970. /**
  35971. * Minimum allowed angle on the longitudinal axis.
  35972. * This can help limiting how the Camera is able to move in the scene.
  35973. */
  35974. lowerAlphaLimit: Nullable<number>;
  35975. /**
  35976. * Maximum allowed angle on the longitudinal axis.
  35977. * This can help limiting how the Camera is able to move in the scene.
  35978. */
  35979. upperAlphaLimit: Nullable<number>;
  35980. /**
  35981. * Minimum allowed angle on the latitudinal axis.
  35982. * This can help limiting how the Camera is able to move in the scene.
  35983. */
  35984. lowerBetaLimit: number;
  35985. /**
  35986. * Maximum allowed angle on the latitudinal axis.
  35987. * This can help limiting how the Camera is able to move in the scene.
  35988. */
  35989. upperBetaLimit: number;
  35990. /**
  35991. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35992. * This can help limiting how the Camera is able to move in the scene.
  35993. */
  35994. lowerRadiusLimit: Nullable<number>;
  35995. /**
  35996. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35997. * This can help limiting how the Camera is able to move in the scene.
  35998. */
  35999. upperRadiusLimit: Nullable<number>;
  36000. /**
  36001. * Defines the current inertia value used during panning of the camera along the X axis.
  36002. */
  36003. inertialPanningX: number;
  36004. /**
  36005. * Defines the current inertia value used during panning of the camera along the Y axis.
  36006. */
  36007. inertialPanningY: number;
  36008. /**
  36009. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36010. * Basically if your fingers moves away from more than this distance you will be considered
  36011. * in pinch mode.
  36012. */
  36013. pinchToPanMaxDistance: number;
  36014. /**
  36015. * Defines the maximum distance the camera can pan.
  36016. * This could help keeping the cammera always in your scene.
  36017. */
  36018. panningDistanceLimit: Nullable<number>;
  36019. /**
  36020. * Defines the target of the camera before paning.
  36021. */
  36022. panningOriginTarget: Vector3;
  36023. /**
  36024. * Defines the value of the inertia used during panning.
  36025. * 0 would mean stop inertia and one would mean no decelleration at all.
  36026. */
  36027. panningInertia: number;
  36028. /**
  36029. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36030. */
  36031. angularSensibilityX: number;
  36032. /**
  36033. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36034. */
  36035. angularSensibilityY: number;
  36036. /**
  36037. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36038. */
  36039. pinchPrecision: number;
  36040. /**
  36041. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36042. * It will be used instead of pinchDeltaPrecision if different from 0.
  36043. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36044. */
  36045. pinchDeltaPercentage: number;
  36046. /**
  36047. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36048. */
  36049. panningSensibility: number;
  36050. /**
  36051. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36052. */
  36053. keysUp: number[];
  36054. /**
  36055. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36056. */
  36057. keysDown: number[];
  36058. /**
  36059. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36060. */
  36061. keysLeft: number[];
  36062. /**
  36063. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36064. */
  36065. keysRight: number[];
  36066. /**
  36067. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36068. */
  36069. wheelPrecision: number;
  36070. /**
  36071. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36072. * It will be used instead of pinchDeltaPrecision if different from 0.
  36073. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36074. */
  36075. wheelDeltaPercentage: number;
  36076. /**
  36077. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36078. */
  36079. zoomOnFactor: number;
  36080. /**
  36081. * Defines a screen offset for the camera position.
  36082. */
  36083. targetScreenOffset: Vector2;
  36084. /**
  36085. * Allows the camera to be completely reversed.
  36086. * If false the camera can not arrive upside down.
  36087. */
  36088. allowUpsideDown: boolean;
  36089. /**
  36090. * Define if double tap/click is used to restore the previously saved state of the camera.
  36091. */
  36092. useInputToRestoreState: boolean;
  36093. /** @hidden */
  36094. _viewMatrix: Matrix;
  36095. /** @hidden */
  36096. _useCtrlForPanning: boolean;
  36097. /** @hidden */
  36098. _panningMouseButton: number;
  36099. /**
  36100. * Defines the input associated to the camera.
  36101. */
  36102. inputs: ArcRotateCameraInputsManager;
  36103. /** @hidden */
  36104. _reset: () => void;
  36105. /**
  36106. * Defines the allowed panning axis.
  36107. */
  36108. panningAxis: Vector3;
  36109. protected _localDirection: Vector3;
  36110. protected _transformedDirection: Vector3;
  36111. private _bouncingBehavior;
  36112. /**
  36113. * Gets the bouncing behavior of the camera if it has been enabled.
  36114. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36115. */
  36116. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36117. /**
  36118. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36119. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36120. */
  36121. useBouncingBehavior: boolean;
  36122. private _framingBehavior;
  36123. /**
  36124. * Gets the framing behavior of the camera if it has been enabled.
  36125. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36126. */
  36127. readonly framingBehavior: Nullable<FramingBehavior>;
  36128. /**
  36129. * Defines if the framing behavior of the camera is enabled on the camera.
  36130. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36131. */
  36132. useFramingBehavior: boolean;
  36133. private _autoRotationBehavior;
  36134. /**
  36135. * Gets the auto rotation behavior of the camera if it has been enabled.
  36136. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36137. */
  36138. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36139. /**
  36140. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36141. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36142. */
  36143. useAutoRotationBehavior: boolean;
  36144. /**
  36145. * Observable triggered when the mesh target has been changed on the camera.
  36146. */
  36147. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36148. /**
  36149. * Event raised when the camera is colliding with a mesh.
  36150. */
  36151. onCollide: (collidedMesh: AbstractMesh) => void;
  36152. /**
  36153. * Defines whether the camera should check collision with the objects oh the scene.
  36154. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36155. */
  36156. checkCollisions: boolean;
  36157. /**
  36158. * Defines the collision radius of the camera.
  36159. * This simulates a sphere around the camera.
  36160. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36161. */
  36162. collisionRadius: Vector3;
  36163. protected _collider: Collider;
  36164. protected _previousPosition: Vector3;
  36165. protected _collisionVelocity: Vector3;
  36166. protected _newPosition: Vector3;
  36167. protected _previousAlpha: number;
  36168. protected _previousBeta: number;
  36169. protected _previousRadius: number;
  36170. protected _collisionTriggered: boolean;
  36171. protected _targetBoundingCenter: Nullable<Vector3>;
  36172. private _computationVector;
  36173. /**
  36174. * Instantiates a new ArcRotateCamera in a given scene
  36175. * @param name Defines the name of the camera
  36176. * @param alpha Defines the camera rotation along the logitudinal axis
  36177. * @param beta Defines the camera rotation along the latitudinal axis
  36178. * @param radius Defines the camera distance from its target
  36179. * @param target Defines the camera target
  36180. * @param scene Defines the scene the camera belongs to
  36181. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36182. */
  36183. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36184. /** @hidden */
  36185. _initCache(): void;
  36186. /** @hidden */
  36187. _updateCache(ignoreParentClass?: boolean): void;
  36188. protected _getTargetPosition(): Vector3;
  36189. private _storedAlpha;
  36190. private _storedBeta;
  36191. private _storedRadius;
  36192. private _storedTarget;
  36193. /**
  36194. * Stores the current state of the camera (alpha, beta, radius and target)
  36195. * @returns the camera itself
  36196. */
  36197. storeState(): Camera;
  36198. /**
  36199. * @hidden
  36200. * Restored camera state. You must call storeState() first
  36201. */
  36202. _restoreStateValues(): boolean;
  36203. /** @hidden */
  36204. _isSynchronizedViewMatrix(): boolean;
  36205. /**
  36206. * Attached controls to the current camera.
  36207. * @param element Defines the element the controls should be listened from
  36208. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36209. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36210. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36211. */
  36212. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36213. /**
  36214. * Detach the current controls from the camera.
  36215. * The camera will stop reacting to inputs.
  36216. * @param element Defines the element to stop listening the inputs from
  36217. */
  36218. detachControl(element: HTMLElement): void;
  36219. /** @hidden */
  36220. _checkInputs(): void;
  36221. protected _checkLimits(): void;
  36222. /**
  36223. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36224. */
  36225. rebuildAnglesAndRadius(): void;
  36226. /**
  36227. * Use a position to define the current camera related information like aplha, beta and radius
  36228. * @param position Defines the position to set the camera at
  36229. */
  36230. setPosition(position: Vector3): void;
  36231. /**
  36232. * Defines the target the camera should look at.
  36233. * This will automatically adapt alpha beta and radius to fit within the new target.
  36234. * @param target Defines the new target as a Vector or a mesh
  36235. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36236. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36237. */
  36238. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36239. /** @hidden */
  36240. _getViewMatrix(): Matrix;
  36241. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36242. /**
  36243. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36244. * @param meshes Defines the mesh to zoom on
  36245. * @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)
  36246. */
  36247. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36248. /**
  36249. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36250. * The target will be changed but the radius
  36251. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36252. * @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)
  36253. */
  36254. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36255. min: Vector3;
  36256. max: Vector3;
  36257. distance: number;
  36258. }, doNotUpdateMaxZ?: boolean): void;
  36259. /**
  36260. * @override
  36261. * Override Camera.createRigCamera
  36262. */
  36263. createRigCamera(name: string, cameraIndex: number): Camera;
  36264. /**
  36265. * @hidden
  36266. * @override
  36267. * Override Camera._updateRigCameras
  36268. */
  36269. _updateRigCameras(): void;
  36270. /**
  36271. * Destroy the camera and release the current resources hold by it.
  36272. */
  36273. dispose(): void;
  36274. /**
  36275. * Gets the current object class name.
  36276. * @return the class name
  36277. */
  36278. getClassName(): string;
  36279. }
  36280. }
  36281. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36282. import { Behavior } from "babylonjs/Behaviors/behavior";
  36283. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36284. /**
  36285. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36286. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36287. */
  36288. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36289. /**
  36290. * Gets the name of the behavior.
  36291. */
  36292. readonly name: string;
  36293. private _zoomStopsAnimation;
  36294. private _idleRotationSpeed;
  36295. private _idleRotationWaitTime;
  36296. private _idleRotationSpinupTime;
  36297. /**
  36298. * Sets the flag that indicates if user zooming should stop animation.
  36299. */
  36300. /**
  36301. * Gets the flag that indicates if user zooming should stop animation.
  36302. */
  36303. zoomStopsAnimation: boolean;
  36304. /**
  36305. * Sets the default speed at which the camera rotates around the model.
  36306. */
  36307. /**
  36308. * Gets the default speed at which the camera rotates around the model.
  36309. */
  36310. idleRotationSpeed: number;
  36311. /**
  36312. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36313. */
  36314. /**
  36315. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36316. */
  36317. idleRotationWaitTime: number;
  36318. /**
  36319. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36320. */
  36321. /**
  36322. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36323. */
  36324. idleRotationSpinupTime: number;
  36325. /**
  36326. * Gets a value indicating if the camera is currently rotating because of this behavior
  36327. */
  36328. readonly rotationInProgress: boolean;
  36329. private _onPrePointerObservableObserver;
  36330. private _onAfterCheckInputsObserver;
  36331. private _attachedCamera;
  36332. private _isPointerDown;
  36333. private _lastFrameTime;
  36334. private _lastInteractionTime;
  36335. private _cameraRotationSpeed;
  36336. /**
  36337. * Initializes the behavior.
  36338. */
  36339. init(): void;
  36340. /**
  36341. * Attaches the behavior to its arc rotate camera.
  36342. * @param camera Defines the camera to attach the behavior to
  36343. */
  36344. attach(camera: ArcRotateCamera): void;
  36345. /**
  36346. * Detaches the behavior from its current arc rotate camera.
  36347. */
  36348. detach(): void;
  36349. /**
  36350. * Returns true if user is scrolling.
  36351. * @return true if user is scrolling.
  36352. */
  36353. private _userIsZooming;
  36354. private _lastFrameRadius;
  36355. private _shouldAnimationStopForInteraction;
  36356. /**
  36357. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36358. */
  36359. private _applyUserInteraction;
  36360. private _userIsMoving;
  36361. }
  36362. }
  36363. declare module "babylonjs/Behaviors/Cameras/index" {
  36364. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36365. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36366. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36367. }
  36368. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36369. import { Mesh } from "babylonjs/Meshes/mesh";
  36370. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36371. import { Behavior } from "babylonjs/Behaviors/behavior";
  36372. /**
  36373. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36374. */
  36375. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36376. private ui;
  36377. /**
  36378. * The name of the behavior
  36379. */
  36380. name: string;
  36381. /**
  36382. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36383. */
  36384. distanceAwayFromFace: number;
  36385. /**
  36386. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36387. */
  36388. distanceAwayFromBottomOfFace: number;
  36389. private _faceVectors;
  36390. private _target;
  36391. private _scene;
  36392. private _onRenderObserver;
  36393. private _tmpMatrix;
  36394. private _tmpVector;
  36395. /**
  36396. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36397. * @param ui The transform node that should be attched to the mesh
  36398. */
  36399. constructor(ui: TransformNode);
  36400. /**
  36401. * Initializes the behavior
  36402. */
  36403. init(): void;
  36404. private _closestFace;
  36405. private _zeroVector;
  36406. private _lookAtTmpMatrix;
  36407. private _lookAtToRef;
  36408. /**
  36409. * Attaches the AttachToBoxBehavior to the passed in mesh
  36410. * @param target The mesh that the specified node will be attached to
  36411. */
  36412. attach(target: Mesh): void;
  36413. /**
  36414. * Detaches the behavior from the mesh
  36415. */
  36416. detach(): void;
  36417. }
  36418. }
  36419. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36420. import { Behavior } from "babylonjs/Behaviors/behavior";
  36421. import { Mesh } from "babylonjs/Meshes/mesh";
  36422. /**
  36423. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36424. */
  36425. export class FadeInOutBehavior implements Behavior<Mesh> {
  36426. /**
  36427. * Time in milliseconds to delay before fading in (Default: 0)
  36428. */
  36429. delay: number;
  36430. /**
  36431. * Time in milliseconds for the mesh to fade in (Default: 300)
  36432. */
  36433. fadeInTime: number;
  36434. private _millisecondsPerFrame;
  36435. private _hovered;
  36436. private _hoverValue;
  36437. private _ownerNode;
  36438. /**
  36439. * Instatiates the FadeInOutBehavior
  36440. */
  36441. constructor();
  36442. /**
  36443. * The name of the behavior
  36444. */
  36445. readonly name: string;
  36446. /**
  36447. * Initializes the behavior
  36448. */
  36449. init(): void;
  36450. /**
  36451. * Attaches the fade behavior on the passed in mesh
  36452. * @param ownerNode The mesh that will be faded in/out once attached
  36453. */
  36454. attach(ownerNode: Mesh): void;
  36455. /**
  36456. * Detaches the behavior from the mesh
  36457. */
  36458. detach(): void;
  36459. /**
  36460. * Triggers the mesh to begin fading in or out
  36461. * @param value if the object should fade in or out (true to fade in)
  36462. */
  36463. fadeIn(value: boolean): void;
  36464. private _update;
  36465. private _setAllVisibility;
  36466. }
  36467. }
  36468. declare module "babylonjs/Misc/pivotTools" {
  36469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36470. /**
  36471. * Class containing a set of static utilities functions for managing Pivots
  36472. * @hidden
  36473. */
  36474. export class PivotTools {
  36475. private static _PivotCached;
  36476. private static _OldPivotPoint;
  36477. private static _PivotTranslation;
  36478. private static _PivotTmpVector;
  36479. /** @hidden */
  36480. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36481. /** @hidden */
  36482. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36483. }
  36484. }
  36485. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36486. import { Scene } from "babylonjs/scene";
  36487. import { Vector4, Plane } from "babylonjs/Maths/math";
  36488. import { Mesh } from "babylonjs/Meshes/mesh";
  36489. import { Nullable } from "babylonjs/types";
  36490. /**
  36491. * Class containing static functions to help procedurally build meshes
  36492. */
  36493. export class PlaneBuilder {
  36494. /**
  36495. * Creates a plane mesh
  36496. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36497. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36498. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36499. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36500. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36502. * @param name defines the name of the mesh
  36503. * @param options defines the options used to create the mesh
  36504. * @param scene defines the hosting scene
  36505. * @returns the plane mesh
  36506. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36507. */
  36508. static CreatePlane(name: string, options: {
  36509. size?: number;
  36510. width?: number;
  36511. height?: number;
  36512. sideOrientation?: number;
  36513. frontUVs?: Vector4;
  36514. backUVs?: Vector4;
  36515. updatable?: boolean;
  36516. sourcePlane?: Plane;
  36517. }, scene?: Nullable<Scene>): Mesh;
  36518. }
  36519. }
  36520. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36521. import { Behavior } from "babylonjs/Behaviors/behavior";
  36522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36523. import { Observable } from "babylonjs/Misc/observable";
  36524. import { Vector3 } from "babylonjs/Maths/math";
  36525. import { Ray } from "babylonjs/Culling/ray";
  36526. import "babylonjs/Meshes/Builders/planeBuilder";
  36527. /**
  36528. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36529. */
  36530. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36531. private static _AnyMouseID;
  36532. private _attachedNode;
  36533. private _dragPlane;
  36534. private _scene;
  36535. private _pointerObserver;
  36536. private _beforeRenderObserver;
  36537. private static _planeScene;
  36538. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36539. /**
  36540. * 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)
  36541. */
  36542. maxDragAngle: number;
  36543. /**
  36544. * @hidden
  36545. */
  36546. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36547. /**
  36548. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36549. */
  36550. currentDraggingPointerID: number;
  36551. /**
  36552. * The last position where the pointer hit the drag plane in world space
  36553. */
  36554. lastDragPosition: Vector3;
  36555. /**
  36556. * If the behavior is currently in a dragging state
  36557. */
  36558. dragging: boolean;
  36559. /**
  36560. * 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)
  36561. */
  36562. dragDeltaRatio: number;
  36563. /**
  36564. * If the drag plane orientation should be updated during the dragging (Default: true)
  36565. */
  36566. updateDragPlane: boolean;
  36567. private _debugMode;
  36568. private _moving;
  36569. /**
  36570. * Fires each time the attached mesh is dragged with the pointer
  36571. * * delta between last drag position and current drag position in world space
  36572. * * dragDistance along the drag axis
  36573. * * dragPlaneNormal normal of the current drag plane used during the drag
  36574. * * dragPlanePoint in world space where the drag intersects the drag plane
  36575. */
  36576. onDragObservable: Observable<{
  36577. delta: Vector3;
  36578. dragPlanePoint: Vector3;
  36579. dragPlaneNormal: Vector3;
  36580. dragDistance: number;
  36581. pointerId: number;
  36582. }>;
  36583. /**
  36584. * Fires each time a drag begins (eg. mouse down on mesh)
  36585. */
  36586. onDragStartObservable: Observable<{
  36587. dragPlanePoint: Vector3;
  36588. pointerId: number;
  36589. }>;
  36590. /**
  36591. * Fires each time a drag ends (eg. mouse release after drag)
  36592. */
  36593. onDragEndObservable: Observable<{
  36594. dragPlanePoint: Vector3;
  36595. pointerId: number;
  36596. }>;
  36597. /**
  36598. * If the attached mesh should be moved when dragged
  36599. */
  36600. moveAttached: boolean;
  36601. /**
  36602. * If the drag behavior will react to drag events (Default: true)
  36603. */
  36604. enabled: boolean;
  36605. /**
  36606. * If camera controls should be detached during the drag
  36607. */
  36608. detachCameraControls: boolean;
  36609. /**
  36610. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36611. */
  36612. useObjectOrienationForDragging: boolean;
  36613. private _options;
  36614. /**
  36615. * Creates a pointer drag behavior that can be attached to a mesh
  36616. * @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)
  36617. */
  36618. constructor(options?: {
  36619. dragAxis?: Vector3;
  36620. dragPlaneNormal?: Vector3;
  36621. });
  36622. /**
  36623. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36624. */
  36625. validateDrag: (targetPosition: Vector3) => boolean;
  36626. /**
  36627. * The name of the behavior
  36628. */
  36629. readonly name: string;
  36630. /**
  36631. * Initializes the behavior
  36632. */
  36633. init(): void;
  36634. private _tmpVector;
  36635. private _alternatePickedPoint;
  36636. private _worldDragAxis;
  36637. private _targetPosition;
  36638. private _attachedElement;
  36639. /**
  36640. * Attaches the drag behavior the passed in mesh
  36641. * @param ownerNode The mesh that will be dragged around once attached
  36642. */
  36643. attach(ownerNode: AbstractMesh): void;
  36644. /**
  36645. * Force relase the drag action by code.
  36646. */
  36647. releaseDrag(): void;
  36648. private _startDragRay;
  36649. private _lastPointerRay;
  36650. /**
  36651. * Simulates the start of a pointer drag event on the behavior
  36652. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36653. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36654. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36655. */
  36656. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36657. private _startDrag;
  36658. private _dragDelta;
  36659. private _moveDrag;
  36660. private _pickWithRayOnDragPlane;
  36661. private _pointA;
  36662. private _pointB;
  36663. private _pointC;
  36664. private _lineA;
  36665. private _lineB;
  36666. private _localAxis;
  36667. private _lookAt;
  36668. private _updateDragPlanePosition;
  36669. /**
  36670. * Detaches the behavior from the mesh
  36671. */
  36672. detach(): void;
  36673. }
  36674. }
  36675. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36676. import { Mesh } from "babylonjs/Meshes/mesh";
  36677. import { Behavior } from "babylonjs/Behaviors/behavior";
  36678. /**
  36679. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36680. */
  36681. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36682. private _dragBehaviorA;
  36683. private _dragBehaviorB;
  36684. private _startDistance;
  36685. private _initialScale;
  36686. private _targetScale;
  36687. private _ownerNode;
  36688. private _sceneRenderObserver;
  36689. /**
  36690. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36691. */
  36692. constructor();
  36693. /**
  36694. * The name of the behavior
  36695. */
  36696. readonly name: string;
  36697. /**
  36698. * Initializes the behavior
  36699. */
  36700. init(): void;
  36701. private _getCurrentDistance;
  36702. /**
  36703. * Attaches the scale behavior the passed in mesh
  36704. * @param ownerNode The mesh that will be scaled around once attached
  36705. */
  36706. attach(ownerNode: Mesh): void;
  36707. /**
  36708. * Detaches the behavior from the mesh
  36709. */
  36710. detach(): void;
  36711. }
  36712. }
  36713. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36714. import { Behavior } from "babylonjs/Behaviors/behavior";
  36715. import { Mesh } from "babylonjs/Meshes/mesh";
  36716. import { Observable } from "babylonjs/Misc/observable";
  36717. /**
  36718. * 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
  36719. */
  36720. export class SixDofDragBehavior implements Behavior<Mesh> {
  36721. private static _virtualScene;
  36722. private _ownerNode;
  36723. private _sceneRenderObserver;
  36724. private _scene;
  36725. private _targetPosition;
  36726. private _virtualOriginMesh;
  36727. private _virtualDragMesh;
  36728. private _pointerObserver;
  36729. private _moving;
  36730. private _startingOrientation;
  36731. /**
  36732. * 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)
  36733. */
  36734. private zDragFactor;
  36735. /**
  36736. * If the object should rotate to face the drag origin
  36737. */
  36738. rotateDraggedObject: boolean;
  36739. /**
  36740. * If the behavior is currently in a dragging state
  36741. */
  36742. dragging: boolean;
  36743. /**
  36744. * 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)
  36745. */
  36746. dragDeltaRatio: number;
  36747. /**
  36748. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36749. */
  36750. currentDraggingPointerID: number;
  36751. /**
  36752. * If camera controls should be detached during the drag
  36753. */
  36754. detachCameraControls: boolean;
  36755. /**
  36756. * Fires each time a drag starts
  36757. */
  36758. onDragStartObservable: Observable<{}>;
  36759. /**
  36760. * Fires each time a drag ends (eg. mouse release after drag)
  36761. */
  36762. onDragEndObservable: Observable<{}>;
  36763. /**
  36764. * 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
  36765. */
  36766. constructor();
  36767. /**
  36768. * The name of the behavior
  36769. */
  36770. readonly name: string;
  36771. /**
  36772. * Initializes the behavior
  36773. */
  36774. init(): void;
  36775. /**
  36776. * Attaches the scale behavior the passed in mesh
  36777. * @param ownerNode The mesh that will be scaled around once attached
  36778. */
  36779. attach(ownerNode: Mesh): void;
  36780. /**
  36781. * Detaches the behavior from the mesh
  36782. */
  36783. detach(): void;
  36784. }
  36785. }
  36786. declare module "babylonjs/Behaviors/Meshes/index" {
  36787. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36788. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36789. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36790. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36791. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36792. }
  36793. declare module "babylonjs/Behaviors/index" {
  36794. export * from "babylonjs/Behaviors/behavior";
  36795. export * from "babylonjs/Behaviors/Cameras/index";
  36796. export * from "babylonjs/Behaviors/Meshes/index";
  36797. }
  36798. declare module "babylonjs/Bones/boneIKController" {
  36799. import { Bone } from "babylonjs/Bones/bone";
  36800. import { Vector3 } from "babylonjs/Maths/math";
  36801. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36802. import { Nullable } from "babylonjs/types";
  36803. /**
  36804. * Class used to apply inverse kinematics to bones
  36805. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36806. */
  36807. export class BoneIKController {
  36808. private static _tmpVecs;
  36809. private static _tmpQuat;
  36810. private static _tmpMats;
  36811. /**
  36812. * Gets or sets the target mesh
  36813. */
  36814. targetMesh: AbstractMesh;
  36815. /** Gets or sets the mesh used as pole */
  36816. poleTargetMesh: AbstractMesh;
  36817. /**
  36818. * Gets or sets the bone used as pole
  36819. */
  36820. poleTargetBone: Nullable<Bone>;
  36821. /**
  36822. * Gets or sets the target position
  36823. */
  36824. targetPosition: Vector3;
  36825. /**
  36826. * Gets or sets the pole target position
  36827. */
  36828. poleTargetPosition: Vector3;
  36829. /**
  36830. * Gets or sets the pole target local offset
  36831. */
  36832. poleTargetLocalOffset: Vector3;
  36833. /**
  36834. * Gets or sets the pole angle
  36835. */
  36836. poleAngle: number;
  36837. /**
  36838. * Gets or sets the mesh associated with the controller
  36839. */
  36840. mesh: AbstractMesh;
  36841. /**
  36842. * 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)
  36843. */
  36844. slerpAmount: number;
  36845. private _bone1Quat;
  36846. private _bone1Mat;
  36847. private _bone2Ang;
  36848. private _bone1;
  36849. private _bone2;
  36850. private _bone1Length;
  36851. private _bone2Length;
  36852. private _maxAngle;
  36853. private _maxReach;
  36854. private _rightHandedSystem;
  36855. private _bendAxis;
  36856. private _slerping;
  36857. private _adjustRoll;
  36858. /**
  36859. * Gets or sets maximum allowed angle
  36860. */
  36861. maxAngle: number;
  36862. /**
  36863. * Creates a new BoneIKController
  36864. * @param mesh defines the mesh to control
  36865. * @param bone defines the bone to control
  36866. * @param options defines options to set up the controller
  36867. */
  36868. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36869. targetMesh?: AbstractMesh;
  36870. poleTargetMesh?: AbstractMesh;
  36871. poleTargetBone?: Bone;
  36872. poleTargetLocalOffset?: Vector3;
  36873. poleAngle?: number;
  36874. bendAxis?: Vector3;
  36875. maxAngle?: number;
  36876. slerpAmount?: number;
  36877. });
  36878. private _setMaxAngle;
  36879. /**
  36880. * Force the controller to update the bones
  36881. */
  36882. update(): void;
  36883. }
  36884. }
  36885. declare module "babylonjs/Bones/boneLookController" {
  36886. import { Vector3, Space } from "babylonjs/Maths/math";
  36887. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36888. import { Bone } from "babylonjs/Bones/bone";
  36889. /**
  36890. * Class used to make a bone look toward a point in space
  36891. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36892. */
  36893. export class BoneLookController {
  36894. private static _tmpVecs;
  36895. private static _tmpQuat;
  36896. private static _tmpMats;
  36897. /**
  36898. * The target Vector3 that the bone will look at
  36899. */
  36900. target: Vector3;
  36901. /**
  36902. * The mesh that the bone is attached to
  36903. */
  36904. mesh: AbstractMesh;
  36905. /**
  36906. * The bone that will be looking to the target
  36907. */
  36908. bone: Bone;
  36909. /**
  36910. * The up axis of the coordinate system that is used when the bone is rotated
  36911. */
  36912. upAxis: Vector3;
  36913. /**
  36914. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36915. */
  36916. upAxisSpace: Space;
  36917. /**
  36918. * Used to make an adjustment to the yaw of the bone
  36919. */
  36920. adjustYaw: number;
  36921. /**
  36922. * Used to make an adjustment to the pitch of the bone
  36923. */
  36924. adjustPitch: number;
  36925. /**
  36926. * Used to make an adjustment to the roll of the bone
  36927. */
  36928. adjustRoll: number;
  36929. /**
  36930. * 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)
  36931. */
  36932. slerpAmount: number;
  36933. private _minYaw;
  36934. private _maxYaw;
  36935. private _minPitch;
  36936. private _maxPitch;
  36937. private _minYawSin;
  36938. private _minYawCos;
  36939. private _maxYawSin;
  36940. private _maxYawCos;
  36941. private _midYawConstraint;
  36942. private _minPitchTan;
  36943. private _maxPitchTan;
  36944. private _boneQuat;
  36945. private _slerping;
  36946. private _transformYawPitch;
  36947. private _transformYawPitchInv;
  36948. private _firstFrameSkipped;
  36949. private _yawRange;
  36950. private _fowardAxis;
  36951. /**
  36952. * Gets or sets the minimum yaw angle that the bone can look to
  36953. */
  36954. minYaw: number;
  36955. /**
  36956. * Gets or sets the maximum yaw angle that the bone can look to
  36957. */
  36958. maxYaw: number;
  36959. /**
  36960. * Gets or sets the minimum pitch angle that the bone can look to
  36961. */
  36962. minPitch: number;
  36963. /**
  36964. * Gets or sets the maximum pitch angle that the bone can look to
  36965. */
  36966. maxPitch: number;
  36967. /**
  36968. * Create a BoneLookController
  36969. * @param mesh the mesh that the bone belongs to
  36970. * @param bone the bone that will be looking to the target
  36971. * @param target the target Vector3 to look at
  36972. * @param options optional settings:
  36973. * * maxYaw: the maximum angle the bone will yaw to
  36974. * * minYaw: the minimum angle the bone will yaw to
  36975. * * maxPitch: the maximum angle the bone will pitch to
  36976. * * minPitch: the minimum angle the bone will yaw to
  36977. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36978. * * upAxis: the up axis of the coordinate system
  36979. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36980. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36981. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36982. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36983. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36984. * * adjustRoll: used to make an adjustment to the roll of the bone
  36985. **/
  36986. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36987. maxYaw?: number;
  36988. minYaw?: number;
  36989. maxPitch?: number;
  36990. minPitch?: number;
  36991. slerpAmount?: number;
  36992. upAxis?: Vector3;
  36993. upAxisSpace?: Space;
  36994. yawAxis?: Vector3;
  36995. pitchAxis?: Vector3;
  36996. adjustYaw?: number;
  36997. adjustPitch?: number;
  36998. adjustRoll?: number;
  36999. });
  37000. /**
  37001. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37002. */
  37003. update(): void;
  37004. private _getAngleDiff;
  37005. private _getAngleBetween;
  37006. private _isAngleBetween;
  37007. }
  37008. }
  37009. declare module "babylonjs/Bones/index" {
  37010. export * from "babylonjs/Bones/bone";
  37011. export * from "babylonjs/Bones/boneIKController";
  37012. export * from "babylonjs/Bones/boneLookController";
  37013. export * from "babylonjs/Bones/skeleton";
  37014. }
  37015. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37016. import { Nullable } from "babylonjs/types";
  37017. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37018. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37019. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37020. /**
  37021. * Manage the gamepad inputs to control an arc rotate camera.
  37022. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37023. */
  37024. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37025. /**
  37026. * Defines the camera the input is attached to.
  37027. */
  37028. camera: ArcRotateCamera;
  37029. /**
  37030. * Defines the gamepad the input is gathering event from.
  37031. */
  37032. gamepad: Nullable<Gamepad>;
  37033. /**
  37034. * Defines the gamepad rotation sensiblity.
  37035. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37036. */
  37037. gamepadRotationSensibility: number;
  37038. /**
  37039. * Defines the gamepad move sensiblity.
  37040. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37041. */
  37042. gamepadMoveSensibility: number;
  37043. private _onGamepadConnectedObserver;
  37044. private _onGamepadDisconnectedObserver;
  37045. /**
  37046. * Attach the input controls to a specific dom element to get the input from.
  37047. * @param element Defines the element the controls should be listened from
  37048. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37049. */
  37050. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37051. /**
  37052. * Detach the current controls from the specified dom element.
  37053. * @param element Defines the element to stop listening the inputs from
  37054. */
  37055. detachControl(element: Nullable<HTMLElement>): void;
  37056. /**
  37057. * Update the current camera state depending on the inputs that have been used this frame.
  37058. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37059. */
  37060. checkInputs(): void;
  37061. /**
  37062. * Gets the class name of the current intput.
  37063. * @returns the class name
  37064. */
  37065. getClassName(): string;
  37066. /**
  37067. * Get the friendly name associated with the input class.
  37068. * @returns the input friendly name
  37069. */
  37070. getSimpleName(): string;
  37071. }
  37072. }
  37073. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37074. import { Nullable } from "babylonjs/types";
  37075. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37076. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37077. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37078. interface ArcRotateCameraInputsManager {
  37079. /**
  37080. * Add orientation input support to the input manager.
  37081. * @returns the current input manager
  37082. */
  37083. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37084. }
  37085. }
  37086. /**
  37087. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37088. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37089. */
  37090. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37091. /**
  37092. * Defines the camera the input is attached to.
  37093. */
  37094. camera: ArcRotateCamera;
  37095. /**
  37096. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37097. */
  37098. alphaCorrection: number;
  37099. /**
  37100. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37101. */
  37102. gammaCorrection: number;
  37103. private _alpha;
  37104. private _gamma;
  37105. private _dirty;
  37106. private _deviceOrientationHandler;
  37107. /**
  37108. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37109. */
  37110. constructor();
  37111. /**
  37112. * Attach the input controls to a specific dom element to get the input from.
  37113. * @param element Defines the element the controls should be listened from
  37114. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37115. */
  37116. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37117. /** @hidden */
  37118. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37119. /**
  37120. * Update the current camera state depending on the inputs that have been used this frame.
  37121. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37122. */
  37123. checkInputs(): void;
  37124. /**
  37125. * Detach the current controls from the specified dom element.
  37126. * @param element Defines the element to stop listening the inputs from
  37127. */
  37128. detachControl(element: Nullable<HTMLElement>): void;
  37129. /**
  37130. * Gets the class name of the current intput.
  37131. * @returns the class name
  37132. */
  37133. getClassName(): string;
  37134. /**
  37135. * Get the friendly name associated with the input class.
  37136. * @returns the input friendly name
  37137. */
  37138. getSimpleName(): string;
  37139. }
  37140. }
  37141. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37142. import { Nullable } from "babylonjs/types";
  37143. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37144. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37145. /**
  37146. * Listen to mouse events to control the camera.
  37147. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37148. */
  37149. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37150. /**
  37151. * Defines the camera the input is attached to.
  37152. */
  37153. camera: FlyCamera;
  37154. /**
  37155. * Defines if touch is enabled. (Default is true.)
  37156. */
  37157. touchEnabled: boolean;
  37158. /**
  37159. * Defines the buttons associated with the input to handle camera rotation.
  37160. */
  37161. buttons: number[];
  37162. /**
  37163. * Assign buttons for Yaw control.
  37164. */
  37165. buttonsYaw: number[];
  37166. /**
  37167. * Assign buttons for Pitch control.
  37168. */
  37169. buttonsPitch: number[];
  37170. /**
  37171. * Assign buttons for Roll control.
  37172. */
  37173. buttonsRoll: number[];
  37174. /**
  37175. * Detect if any button is being pressed while mouse is moved.
  37176. * -1 = Mouse locked.
  37177. * 0 = Left button.
  37178. * 1 = Middle Button.
  37179. * 2 = Right Button.
  37180. */
  37181. activeButton: number;
  37182. /**
  37183. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37184. * Higher values reduce its sensitivity.
  37185. */
  37186. angularSensibility: number;
  37187. private _mousemoveCallback;
  37188. private _observer;
  37189. private _rollObserver;
  37190. private previousPosition;
  37191. private noPreventDefault;
  37192. private element;
  37193. /**
  37194. * Listen to mouse events to control the camera.
  37195. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37196. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37197. */
  37198. constructor(touchEnabled?: boolean);
  37199. /**
  37200. * Attach the mouse control to the HTML DOM element.
  37201. * @param element Defines the element that listens to the input events.
  37202. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37203. */
  37204. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37205. /**
  37206. * Detach the current controls from the specified dom element.
  37207. * @param element Defines the element to stop listening the inputs from
  37208. */
  37209. detachControl(element: Nullable<HTMLElement>): void;
  37210. /**
  37211. * Gets the class name of the current input.
  37212. * @returns the class name.
  37213. */
  37214. getClassName(): string;
  37215. /**
  37216. * Get the friendly name associated with the input class.
  37217. * @returns the input's friendly name.
  37218. */
  37219. getSimpleName(): string;
  37220. private _pointerInput;
  37221. private _onMouseMove;
  37222. /**
  37223. * Rotate camera by mouse offset.
  37224. */
  37225. private rotateCamera;
  37226. }
  37227. }
  37228. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37229. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37230. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37231. /**
  37232. * Default Inputs manager for the FlyCamera.
  37233. * It groups all the default supported inputs for ease of use.
  37234. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37235. */
  37236. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37237. /**
  37238. * Instantiates a new FlyCameraInputsManager.
  37239. * @param camera Defines the camera the inputs belong to.
  37240. */
  37241. constructor(camera: FlyCamera);
  37242. /**
  37243. * Add keyboard input support to the input manager.
  37244. * @returns the new FlyCameraKeyboardMoveInput().
  37245. */
  37246. addKeyboard(): FlyCameraInputsManager;
  37247. /**
  37248. * Add mouse input support to the input manager.
  37249. * @param touchEnabled Enable touch screen support.
  37250. * @returns the new FlyCameraMouseInput().
  37251. */
  37252. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37253. }
  37254. }
  37255. declare module "babylonjs/Cameras/flyCamera" {
  37256. import { Scene } from "babylonjs/scene";
  37257. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37258. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37259. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37260. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37261. /**
  37262. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37263. * such as in a 3D Space Shooter or a Flight Simulator.
  37264. */
  37265. export class FlyCamera extends TargetCamera {
  37266. /**
  37267. * Define the collision ellipsoid of the camera.
  37268. * This is helpful for simulating a camera body, like a player's body.
  37269. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37270. */
  37271. ellipsoid: Vector3;
  37272. /**
  37273. * Define an offset for the position of the ellipsoid around the camera.
  37274. * This can be helpful if the camera is attached away from the player's body center,
  37275. * such as at its head.
  37276. */
  37277. ellipsoidOffset: Vector3;
  37278. /**
  37279. * Enable or disable collisions of the camera with the rest of the scene objects.
  37280. */
  37281. checkCollisions: boolean;
  37282. /**
  37283. * Enable or disable gravity on the camera.
  37284. */
  37285. applyGravity: boolean;
  37286. /**
  37287. * Define the current direction the camera is moving to.
  37288. */
  37289. cameraDirection: Vector3;
  37290. /**
  37291. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37292. * This overrides and empties cameraRotation.
  37293. */
  37294. rotationQuaternion: Quaternion;
  37295. /**
  37296. * Track Roll to maintain the wanted Rolling when looking around.
  37297. */
  37298. _trackRoll: number;
  37299. /**
  37300. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37301. */
  37302. rollCorrect: number;
  37303. /**
  37304. * Mimic a banked turn, Rolling the camera when Yawing.
  37305. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37306. */
  37307. bankedTurn: boolean;
  37308. /**
  37309. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37310. */
  37311. bankedTurnLimit: number;
  37312. /**
  37313. * Value of 0 disables the banked Roll.
  37314. * Value of 1 is equal to the Yaw angle in radians.
  37315. */
  37316. bankedTurnMultiplier: number;
  37317. /**
  37318. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37319. */
  37320. inputs: FlyCameraInputsManager;
  37321. /**
  37322. * Gets the input sensibility for mouse input.
  37323. * Higher values reduce sensitivity.
  37324. */
  37325. /**
  37326. * Sets the input sensibility for a mouse input.
  37327. * Higher values reduce sensitivity.
  37328. */
  37329. angularSensibility: number;
  37330. /**
  37331. * Get the keys for camera movement forward.
  37332. */
  37333. /**
  37334. * Set the keys for camera movement forward.
  37335. */
  37336. keysForward: number[];
  37337. /**
  37338. * Get the keys for camera movement backward.
  37339. */
  37340. keysBackward: number[];
  37341. /**
  37342. * Get the keys for camera movement up.
  37343. */
  37344. /**
  37345. * Set the keys for camera movement up.
  37346. */
  37347. keysUp: number[];
  37348. /**
  37349. * Get the keys for camera movement down.
  37350. */
  37351. /**
  37352. * Set the keys for camera movement down.
  37353. */
  37354. keysDown: number[];
  37355. /**
  37356. * Get the keys for camera movement left.
  37357. */
  37358. /**
  37359. * Set the keys for camera movement left.
  37360. */
  37361. keysLeft: number[];
  37362. /**
  37363. * Set the keys for camera movement right.
  37364. */
  37365. /**
  37366. * Set the keys for camera movement right.
  37367. */
  37368. keysRight: number[];
  37369. /**
  37370. * Event raised when the camera collides with a mesh in the scene.
  37371. */
  37372. onCollide: (collidedMesh: AbstractMesh) => void;
  37373. private _collider;
  37374. private _needMoveForGravity;
  37375. private _oldPosition;
  37376. private _diffPosition;
  37377. private _newPosition;
  37378. /** @hidden */
  37379. _localDirection: Vector3;
  37380. /** @hidden */
  37381. _transformedDirection: Vector3;
  37382. /**
  37383. * Instantiates a FlyCamera.
  37384. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37385. * such as in a 3D Space Shooter or a Flight Simulator.
  37386. * @param name Define the name of the camera in the scene.
  37387. * @param position Define the starting position of the camera in the scene.
  37388. * @param scene Define the scene the camera belongs to.
  37389. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37390. */
  37391. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37392. /**
  37393. * Attach a control to the HTML DOM element.
  37394. * @param element Defines the element that listens to the input events.
  37395. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37396. */
  37397. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37398. /**
  37399. * Detach a control from the HTML DOM element.
  37400. * The camera will stop reacting to that input.
  37401. * @param element Defines the element that listens to the input events.
  37402. */
  37403. detachControl(element: HTMLElement): void;
  37404. private _collisionMask;
  37405. /**
  37406. * Get the mask that the camera ignores in collision events.
  37407. */
  37408. /**
  37409. * Set the mask that the camera ignores in collision events.
  37410. */
  37411. collisionMask: number;
  37412. /** @hidden */
  37413. _collideWithWorld(displacement: Vector3): void;
  37414. /** @hidden */
  37415. private _onCollisionPositionChange;
  37416. /** @hidden */
  37417. _checkInputs(): void;
  37418. /** @hidden */
  37419. _decideIfNeedsToMove(): boolean;
  37420. /** @hidden */
  37421. _updatePosition(): void;
  37422. /**
  37423. * Restore the Roll to its target value at the rate specified.
  37424. * @param rate - Higher means slower restoring.
  37425. * @hidden
  37426. */
  37427. restoreRoll(rate: number): void;
  37428. /**
  37429. * Destroy the camera and release the current resources held by it.
  37430. */
  37431. dispose(): void;
  37432. /**
  37433. * Get the current object class name.
  37434. * @returns the class name.
  37435. */
  37436. getClassName(): string;
  37437. }
  37438. }
  37439. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37440. import { Nullable } from "babylonjs/types";
  37441. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37442. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37443. /**
  37444. * Listen to keyboard events to control the camera.
  37445. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37446. */
  37447. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37448. /**
  37449. * Defines the camera the input is attached to.
  37450. */
  37451. camera: FlyCamera;
  37452. /**
  37453. * The list of keyboard keys used to control the forward move of the camera.
  37454. */
  37455. keysForward: number[];
  37456. /**
  37457. * The list of keyboard keys used to control the backward move of the camera.
  37458. */
  37459. keysBackward: number[];
  37460. /**
  37461. * The list of keyboard keys used to control the forward move of the camera.
  37462. */
  37463. keysUp: number[];
  37464. /**
  37465. * The list of keyboard keys used to control the backward move of the camera.
  37466. */
  37467. keysDown: number[];
  37468. /**
  37469. * The list of keyboard keys used to control the right strafe move of the camera.
  37470. */
  37471. keysRight: number[];
  37472. /**
  37473. * The list of keyboard keys used to control the left strafe move of the camera.
  37474. */
  37475. keysLeft: number[];
  37476. private _keys;
  37477. private _onCanvasBlurObserver;
  37478. private _onKeyboardObserver;
  37479. private _engine;
  37480. private _scene;
  37481. /**
  37482. * Attach the input controls to a specific dom element to get the input from.
  37483. * @param element Defines the element the controls should be listened from
  37484. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37485. */
  37486. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37487. /**
  37488. * Detach the current controls from the specified dom element.
  37489. * @param element Defines the element to stop listening the inputs from
  37490. */
  37491. detachControl(element: Nullable<HTMLElement>): void;
  37492. /**
  37493. * Gets the class name of the current intput.
  37494. * @returns the class name
  37495. */
  37496. getClassName(): string;
  37497. /** @hidden */
  37498. _onLostFocus(e: FocusEvent): void;
  37499. /**
  37500. * Get the friendly name associated with the input class.
  37501. * @returns the input friendly name
  37502. */
  37503. getSimpleName(): string;
  37504. /**
  37505. * Update the current camera state depending on the inputs that have been used this frame.
  37506. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37507. */
  37508. checkInputs(): void;
  37509. }
  37510. }
  37511. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37512. import { Nullable } from "babylonjs/types";
  37513. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37514. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37515. /**
  37516. * Manage the mouse wheel inputs to control a follow camera.
  37517. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37518. */
  37519. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37520. /**
  37521. * Defines the camera the input is attached to.
  37522. */
  37523. camera: FollowCamera;
  37524. /**
  37525. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37526. */
  37527. axisControlRadius: boolean;
  37528. /**
  37529. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37530. */
  37531. axisControlHeight: boolean;
  37532. /**
  37533. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37534. */
  37535. axisControlRotation: boolean;
  37536. /**
  37537. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37538. * relation to mouseWheel events.
  37539. */
  37540. wheelPrecision: number;
  37541. /**
  37542. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37543. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37544. */
  37545. wheelDeltaPercentage: number;
  37546. private _wheel;
  37547. private _observer;
  37548. /**
  37549. * Attach the input controls to a specific dom element to get the input from.
  37550. * @param element Defines the element the controls should be listened from
  37551. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37552. */
  37553. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37554. /**
  37555. * Detach the current controls from the specified dom element.
  37556. * @param element Defines the element to stop listening the inputs from
  37557. */
  37558. detachControl(element: Nullable<HTMLElement>): void;
  37559. /**
  37560. * Gets the class name of the current intput.
  37561. * @returns the class name
  37562. */
  37563. getClassName(): string;
  37564. /**
  37565. * Get the friendly name associated with the input class.
  37566. * @returns the input friendly name
  37567. */
  37568. getSimpleName(): string;
  37569. }
  37570. }
  37571. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37572. import { Nullable } from "babylonjs/types";
  37573. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37574. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37575. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37576. /**
  37577. * Manage the pointers inputs to control an follow camera.
  37578. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37579. */
  37580. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37581. /**
  37582. * Defines the camera the input is attached to.
  37583. */
  37584. camera: FollowCamera;
  37585. /**
  37586. * Gets the class name of the current input.
  37587. * @returns the class name
  37588. */
  37589. getClassName(): string;
  37590. /**
  37591. * Defines the pointer angular sensibility along the X axis or how fast is
  37592. * the camera rotating.
  37593. * A negative number will reverse the axis direction.
  37594. */
  37595. angularSensibilityX: number;
  37596. /**
  37597. * Defines the pointer angular sensibility along the Y axis or how fast is
  37598. * the camera rotating.
  37599. * A negative number will reverse the axis direction.
  37600. */
  37601. angularSensibilityY: number;
  37602. /**
  37603. * Defines the pointer pinch precision or how fast is the camera zooming.
  37604. * A negative number will reverse the axis direction.
  37605. */
  37606. pinchPrecision: number;
  37607. /**
  37608. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37609. * from 0.
  37610. * It defines the percentage of current camera.radius to use as delta when
  37611. * pinch zoom is used.
  37612. */
  37613. pinchDeltaPercentage: number;
  37614. /**
  37615. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37616. */
  37617. axisXControlRadius: boolean;
  37618. /**
  37619. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37620. */
  37621. axisXControlHeight: boolean;
  37622. /**
  37623. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37624. */
  37625. axisXControlRotation: boolean;
  37626. /**
  37627. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37628. */
  37629. axisYControlRadius: boolean;
  37630. /**
  37631. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37632. */
  37633. axisYControlHeight: boolean;
  37634. /**
  37635. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37636. */
  37637. axisYControlRotation: boolean;
  37638. /**
  37639. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37640. */
  37641. axisPinchControlRadius: boolean;
  37642. /**
  37643. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37644. */
  37645. axisPinchControlHeight: boolean;
  37646. /**
  37647. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37648. */
  37649. axisPinchControlRotation: boolean;
  37650. /**
  37651. * Log error messages if basic misconfiguration has occurred.
  37652. */
  37653. warningEnable: boolean;
  37654. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37655. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37656. private _warningCounter;
  37657. private _warning;
  37658. }
  37659. }
  37660. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37661. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37662. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37663. /**
  37664. * Default Inputs manager for the FollowCamera.
  37665. * It groups all the default supported inputs for ease of use.
  37666. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37667. */
  37668. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37669. /**
  37670. * Instantiates a new FollowCameraInputsManager.
  37671. * @param camera Defines the camera the inputs belong to
  37672. */
  37673. constructor(camera: FollowCamera);
  37674. /**
  37675. * Add keyboard input support to the input manager.
  37676. * @returns the current input manager
  37677. */
  37678. addKeyboard(): FollowCameraInputsManager;
  37679. /**
  37680. * Add mouse wheel input support to the input manager.
  37681. * @returns the current input manager
  37682. */
  37683. addMouseWheel(): FollowCameraInputsManager;
  37684. /**
  37685. * Add pointers input support to the input manager.
  37686. * @returns the current input manager
  37687. */
  37688. addPointers(): FollowCameraInputsManager;
  37689. /**
  37690. * Add orientation input support to the input manager.
  37691. * @returns the current input manager
  37692. */
  37693. addVRDeviceOrientation(): FollowCameraInputsManager;
  37694. }
  37695. }
  37696. declare module "babylonjs/Cameras/followCamera" {
  37697. import { Nullable } from "babylonjs/types";
  37698. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37699. import { Scene } from "babylonjs/scene";
  37700. import { Vector3 } from "babylonjs/Maths/math";
  37701. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37702. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37703. /**
  37704. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37705. * an arc rotate version arcFollowCamera are available.
  37706. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37707. */
  37708. export class FollowCamera extends TargetCamera {
  37709. /**
  37710. * Distance the follow camera should follow an object at
  37711. */
  37712. radius: number;
  37713. /**
  37714. * Minimum allowed distance of the camera to the axis of rotation
  37715. * (The camera can not get closer).
  37716. * This can help limiting how the Camera is able to move in the scene.
  37717. */
  37718. lowerRadiusLimit: Nullable<number>;
  37719. /**
  37720. * Maximum allowed distance of the camera to the axis of rotation
  37721. * (The camera can not get further).
  37722. * This can help limiting how the Camera is able to move in the scene.
  37723. */
  37724. upperRadiusLimit: Nullable<number>;
  37725. /**
  37726. * Define a rotation offset between the camera and the object it follows
  37727. */
  37728. rotationOffset: number;
  37729. /**
  37730. * Minimum allowed angle to camera position relative to target object.
  37731. * This can help limiting how the Camera is able to move in the scene.
  37732. */
  37733. lowerRotationOffsetLimit: Nullable<number>;
  37734. /**
  37735. * Maximum allowed angle to camera position relative to target object.
  37736. * This can help limiting how the Camera is able to move in the scene.
  37737. */
  37738. upperRotationOffsetLimit: Nullable<number>;
  37739. /**
  37740. * Define a height offset between the camera and the object it follows.
  37741. * It can help following an object from the top (like a car chaing a plane)
  37742. */
  37743. heightOffset: number;
  37744. /**
  37745. * Minimum allowed height of camera position relative to target object.
  37746. * This can help limiting how the Camera is able to move in the scene.
  37747. */
  37748. lowerHeightOffsetLimit: Nullable<number>;
  37749. /**
  37750. * Maximum allowed height of camera position relative to target object.
  37751. * This can help limiting how the Camera is able to move in the scene.
  37752. */
  37753. upperHeightOffsetLimit: Nullable<number>;
  37754. /**
  37755. * Define how fast the camera can accelerate to follow it s target.
  37756. */
  37757. cameraAcceleration: number;
  37758. /**
  37759. * Define the speed limit of the camera following an object.
  37760. */
  37761. maxCameraSpeed: number;
  37762. /**
  37763. * Define the target of the camera.
  37764. */
  37765. lockedTarget: Nullable<AbstractMesh>;
  37766. /**
  37767. * Defines the input associated with the camera.
  37768. */
  37769. inputs: FollowCameraInputsManager;
  37770. /**
  37771. * Instantiates the follow camera.
  37772. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37773. * @param name Define the name of the camera in the scene
  37774. * @param position Define the position of the camera
  37775. * @param scene Define the scene the camera belong to
  37776. * @param lockedTarget Define the target of the camera
  37777. */
  37778. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37779. private _follow;
  37780. /**
  37781. * Attached controls to the current camera.
  37782. * @param element Defines the element the controls should be listened from
  37783. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37784. */
  37785. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37786. /**
  37787. * Detach the current controls from the camera.
  37788. * The camera will stop reacting to inputs.
  37789. * @param element Defines the element to stop listening the inputs from
  37790. */
  37791. detachControl(element: HTMLElement): void;
  37792. /** @hidden */
  37793. _checkInputs(): void;
  37794. private _checkLimits;
  37795. /**
  37796. * Gets the camera class name.
  37797. * @returns the class name
  37798. */
  37799. getClassName(): string;
  37800. }
  37801. /**
  37802. * Arc Rotate version of the follow camera.
  37803. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37804. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37805. */
  37806. export class ArcFollowCamera extends TargetCamera {
  37807. /** The longitudinal angle of the camera */
  37808. alpha: number;
  37809. /** The latitudinal angle of the camera */
  37810. beta: number;
  37811. /** The radius of the camera from its target */
  37812. radius: number;
  37813. /** Define the camera target (the messh it should follow) */
  37814. target: Nullable<AbstractMesh>;
  37815. private _cartesianCoordinates;
  37816. /**
  37817. * Instantiates a new ArcFollowCamera
  37818. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37819. * @param name Define the name of the camera
  37820. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37821. * @param beta Define the rotation angle of the camera around the elevation axis
  37822. * @param radius Define the radius of the camera from its target point
  37823. * @param target Define the target of the camera
  37824. * @param scene Define the scene the camera belongs to
  37825. */
  37826. constructor(name: string,
  37827. /** The longitudinal angle of the camera */
  37828. alpha: number,
  37829. /** The latitudinal angle of the camera */
  37830. beta: number,
  37831. /** The radius of the camera from its target */
  37832. radius: number,
  37833. /** Define the camera target (the messh it should follow) */
  37834. target: Nullable<AbstractMesh>, scene: Scene);
  37835. private _follow;
  37836. /** @hidden */
  37837. _checkInputs(): void;
  37838. /**
  37839. * Returns the class name of the object.
  37840. * It is mostly used internally for serialization purposes.
  37841. */
  37842. getClassName(): string;
  37843. }
  37844. }
  37845. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37846. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37847. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37848. import { Nullable } from "babylonjs/types";
  37849. /**
  37850. * Manage the keyboard inputs to control the movement of a follow camera.
  37851. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37852. */
  37853. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37854. /**
  37855. * Defines the camera the input is attached to.
  37856. */
  37857. camera: FollowCamera;
  37858. /**
  37859. * Defines the list of key codes associated with the up action (increase heightOffset)
  37860. */
  37861. keysHeightOffsetIncr: number[];
  37862. /**
  37863. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37864. */
  37865. keysHeightOffsetDecr: number[];
  37866. /**
  37867. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37868. */
  37869. keysHeightOffsetModifierAlt: boolean;
  37870. /**
  37871. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37872. */
  37873. keysHeightOffsetModifierCtrl: boolean;
  37874. /**
  37875. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37876. */
  37877. keysHeightOffsetModifierShift: boolean;
  37878. /**
  37879. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37880. */
  37881. keysRotationOffsetIncr: number[];
  37882. /**
  37883. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37884. */
  37885. keysRotationOffsetDecr: number[];
  37886. /**
  37887. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37888. */
  37889. keysRotationOffsetModifierAlt: boolean;
  37890. /**
  37891. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37892. */
  37893. keysRotationOffsetModifierCtrl: boolean;
  37894. /**
  37895. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37896. */
  37897. keysRotationOffsetModifierShift: boolean;
  37898. /**
  37899. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37900. */
  37901. keysRadiusIncr: number[];
  37902. /**
  37903. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37904. */
  37905. keysRadiusDecr: number[];
  37906. /**
  37907. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37908. */
  37909. keysRadiusModifierAlt: boolean;
  37910. /**
  37911. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37912. */
  37913. keysRadiusModifierCtrl: boolean;
  37914. /**
  37915. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37916. */
  37917. keysRadiusModifierShift: boolean;
  37918. /**
  37919. * Defines the rate of change of heightOffset.
  37920. */
  37921. heightSensibility: number;
  37922. /**
  37923. * Defines the rate of change of rotationOffset.
  37924. */
  37925. rotationSensibility: number;
  37926. /**
  37927. * Defines the rate of change of radius.
  37928. */
  37929. radiusSensibility: number;
  37930. private _keys;
  37931. private _ctrlPressed;
  37932. private _altPressed;
  37933. private _shiftPressed;
  37934. private _onCanvasBlurObserver;
  37935. private _onKeyboardObserver;
  37936. private _engine;
  37937. private _scene;
  37938. /**
  37939. * Attach the input controls to a specific dom element to get the input from.
  37940. * @param element Defines the element the controls should be listened from
  37941. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37942. */
  37943. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37944. /**
  37945. * Detach the current controls from the specified dom element.
  37946. * @param element Defines the element to stop listening the inputs from
  37947. */
  37948. detachControl(element: Nullable<HTMLElement>): void;
  37949. /**
  37950. * Update the current camera state depending on the inputs that have been used this frame.
  37951. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37952. */
  37953. checkInputs(): void;
  37954. /**
  37955. * Gets the class name of the current input.
  37956. * @returns the class name
  37957. */
  37958. getClassName(): string;
  37959. /**
  37960. * Get the friendly name associated with the input class.
  37961. * @returns the input friendly name
  37962. */
  37963. getSimpleName(): string;
  37964. /**
  37965. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37966. * allow modification of the heightOffset value.
  37967. */
  37968. private _modifierHeightOffset;
  37969. /**
  37970. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37971. * allow modification of the rotationOffset value.
  37972. */
  37973. private _modifierRotationOffset;
  37974. /**
  37975. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37976. * allow modification of the radius value.
  37977. */
  37978. private _modifierRadius;
  37979. }
  37980. }
  37981. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37982. import { Nullable } from "babylonjs/types";
  37983. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37984. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37985. import { Observable } from "babylonjs/Misc/observable";
  37986. module "babylonjs/Cameras/freeCameraInputsManager" {
  37987. interface FreeCameraInputsManager {
  37988. /**
  37989. * @hidden
  37990. */
  37991. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37992. /**
  37993. * Add orientation input support to the input manager.
  37994. * @returns the current input manager
  37995. */
  37996. addDeviceOrientation(): FreeCameraInputsManager;
  37997. }
  37998. }
  37999. /**
  38000. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38001. * Screen rotation is taken into account.
  38002. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38003. */
  38004. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38005. private _camera;
  38006. private _screenOrientationAngle;
  38007. private _constantTranform;
  38008. private _screenQuaternion;
  38009. private _alpha;
  38010. private _beta;
  38011. private _gamma;
  38012. /**
  38013. * @hidden
  38014. */
  38015. _onDeviceOrientationChangedObservable: Observable<void>;
  38016. /**
  38017. * Instantiates a new input
  38018. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38019. */
  38020. constructor();
  38021. /**
  38022. * Define the camera controlled by the input.
  38023. */
  38024. camera: FreeCamera;
  38025. /**
  38026. * Attach the input controls to a specific dom element to get the input from.
  38027. * @param element Defines the element the controls should be listened from
  38028. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38029. */
  38030. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38031. private _orientationChanged;
  38032. private _deviceOrientation;
  38033. /**
  38034. * Detach the current controls from the specified dom element.
  38035. * @param element Defines the element to stop listening the inputs from
  38036. */
  38037. detachControl(element: Nullable<HTMLElement>): void;
  38038. /**
  38039. * Update the current camera state depending on the inputs that have been used this frame.
  38040. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38041. */
  38042. checkInputs(): void;
  38043. /**
  38044. * Gets the class name of the current intput.
  38045. * @returns the class name
  38046. */
  38047. getClassName(): string;
  38048. /**
  38049. * Get the friendly name associated with the input class.
  38050. * @returns the input friendly name
  38051. */
  38052. getSimpleName(): string;
  38053. }
  38054. }
  38055. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38056. import { Nullable } from "babylonjs/types";
  38057. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38058. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38059. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38060. /**
  38061. * Manage the gamepad inputs to control a free camera.
  38062. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38063. */
  38064. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38065. /**
  38066. * Define the camera the input is attached to.
  38067. */
  38068. camera: FreeCamera;
  38069. /**
  38070. * Define the Gamepad controlling the input
  38071. */
  38072. gamepad: Nullable<Gamepad>;
  38073. /**
  38074. * Defines the gamepad rotation sensiblity.
  38075. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38076. */
  38077. gamepadAngularSensibility: number;
  38078. /**
  38079. * Defines the gamepad move sensiblity.
  38080. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38081. */
  38082. gamepadMoveSensibility: number;
  38083. private _onGamepadConnectedObserver;
  38084. private _onGamepadDisconnectedObserver;
  38085. private _cameraTransform;
  38086. private _deltaTransform;
  38087. private _vector3;
  38088. private _vector2;
  38089. /**
  38090. * Attach the input controls to a specific dom element to get the input from.
  38091. * @param element Defines the element the controls should be listened from
  38092. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38093. */
  38094. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38095. /**
  38096. * Detach the current controls from the specified dom element.
  38097. * @param element Defines the element to stop listening the inputs from
  38098. */
  38099. detachControl(element: Nullable<HTMLElement>): void;
  38100. /**
  38101. * Update the current camera state depending on the inputs that have been used this frame.
  38102. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38103. */
  38104. checkInputs(): void;
  38105. /**
  38106. * Gets the class name of the current intput.
  38107. * @returns the class name
  38108. */
  38109. getClassName(): string;
  38110. /**
  38111. * Get the friendly name associated with the input class.
  38112. * @returns the input friendly name
  38113. */
  38114. getSimpleName(): string;
  38115. }
  38116. }
  38117. declare module "babylonjs/Misc/virtualJoystick" {
  38118. import { Nullable } from "babylonjs/types";
  38119. import { Vector3 } from "babylonjs/Maths/math";
  38120. /**
  38121. * Defines the potential axis of a Joystick
  38122. */
  38123. export enum JoystickAxis {
  38124. /** X axis */
  38125. X = 0,
  38126. /** Y axis */
  38127. Y = 1,
  38128. /** Z axis */
  38129. Z = 2
  38130. }
  38131. /**
  38132. * Class used to define virtual joystick (used in touch mode)
  38133. */
  38134. export class VirtualJoystick {
  38135. /**
  38136. * Gets or sets a boolean indicating that left and right values must be inverted
  38137. */
  38138. reverseLeftRight: boolean;
  38139. /**
  38140. * Gets or sets a boolean indicating that up and down values must be inverted
  38141. */
  38142. reverseUpDown: boolean;
  38143. /**
  38144. * Gets the offset value for the position (ie. the change of the position value)
  38145. */
  38146. deltaPosition: Vector3;
  38147. /**
  38148. * Gets a boolean indicating if the virtual joystick was pressed
  38149. */
  38150. pressed: boolean;
  38151. /**
  38152. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38153. */
  38154. static Canvas: Nullable<HTMLCanvasElement>;
  38155. private static _globalJoystickIndex;
  38156. private static vjCanvasContext;
  38157. private static vjCanvasWidth;
  38158. private static vjCanvasHeight;
  38159. private static halfWidth;
  38160. private _action;
  38161. private _axisTargetedByLeftAndRight;
  38162. private _axisTargetedByUpAndDown;
  38163. private _joystickSensibility;
  38164. private _inversedSensibility;
  38165. private _joystickPointerID;
  38166. private _joystickColor;
  38167. private _joystickPointerPos;
  38168. private _joystickPreviousPointerPos;
  38169. private _joystickPointerStartPos;
  38170. private _deltaJoystickVector;
  38171. private _leftJoystick;
  38172. private _touches;
  38173. private _onPointerDownHandlerRef;
  38174. private _onPointerMoveHandlerRef;
  38175. private _onPointerUpHandlerRef;
  38176. private _onResize;
  38177. /**
  38178. * Creates a new virtual joystick
  38179. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38180. */
  38181. constructor(leftJoystick?: boolean);
  38182. /**
  38183. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38184. * @param newJoystickSensibility defines the new sensibility
  38185. */
  38186. setJoystickSensibility(newJoystickSensibility: number): void;
  38187. private _onPointerDown;
  38188. private _onPointerMove;
  38189. private _onPointerUp;
  38190. /**
  38191. * Change the color of the virtual joystick
  38192. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38193. */
  38194. setJoystickColor(newColor: string): void;
  38195. /**
  38196. * Defines a callback to call when the joystick is touched
  38197. * @param action defines the callback
  38198. */
  38199. setActionOnTouch(action: () => any): void;
  38200. /**
  38201. * Defines which axis you'd like to control for left & right
  38202. * @param axis defines the axis to use
  38203. */
  38204. setAxisForLeftRight(axis: JoystickAxis): void;
  38205. /**
  38206. * Defines which axis you'd like to control for up & down
  38207. * @param axis defines the axis to use
  38208. */
  38209. setAxisForUpDown(axis: JoystickAxis): void;
  38210. private _drawVirtualJoystick;
  38211. /**
  38212. * Release internal HTML canvas
  38213. */
  38214. releaseCanvas(): void;
  38215. }
  38216. }
  38217. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38218. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38219. import { Nullable } from "babylonjs/types";
  38220. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38221. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38222. module "babylonjs/Cameras/freeCameraInputsManager" {
  38223. interface FreeCameraInputsManager {
  38224. /**
  38225. * Add virtual joystick input support to the input manager.
  38226. * @returns the current input manager
  38227. */
  38228. addVirtualJoystick(): FreeCameraInputsManager;
  38229. }
  38230. }
  38231. /**
  38232. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38233. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38234. */
  38235. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38236. /**
  38237. * Defines the camera the input is attached to.
  38238. */
  38239. camera: FreeCamera;
  38240. private _leftjoystick;
  38241. private _rightjoystick;
  38242. /**
  38243. * Gets the left stick of the virtual joystick.
  38244. * @returns The virtual Joystick
  38245. */
  38246. getLeftJoystick(): VirtualJoystick;
  38247. /**
  38248. * Gets the right stick of the virtual joystick.
  38249. * @returns The virtual Joystick
  38250. */
  38251. getRightJoystick(): VirtualJoystick;
  38252. /**
  38253. * Update the current camera state depending on the inputs that have been used this frame.
  38254. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38255. */
  38256. checkInputs(): void;
  38257. /**
  38258. * Attach the input controls to a specific dom element to get the input from.
  38259. * @param element Defines the element the controls should be listened from
  38260. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38261. */
  38262. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38263. /**
  38264. * Detach the current controls from the specified dom element.
  38265. * @param element Defines the element to stop listening the inputs from
  38266. */
  38267. detachControl(element: Nullable<HTMLElement>): void;
  38268. /**
  38269. * Gets the class name of the current intput.
  38270. * @returns the class name
  38271. */
  38272. getClassName(): string;
  38273. /**
  38274. * Get the friendly name associated with the input class.
  38275. * @returns the input friendly name
  38276. */
  38277. getSimpleName(): string;
  38278. }
  38279. }
  38280. declare module "babylonjs/Cameras/Inputs/index" {
  38281. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38282. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38283. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38284. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38285. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38286. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38287. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38288. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38289. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38290. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38291. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38292. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38293. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38294. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38295. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38296. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38297. }
  38298. declare module "babylonjs/Cameras/touchCamera" {
  38299. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38300. import { Scene } from "babylonjs/scene";
  38301. import { Vector3 } from "babylonjs/Maths/math";
  38302. /**
  38303. * This represents a FPS type of camera controlled by touch.
  38304. * This is like a universal camera minus the Gamepad controls.
  38305. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38306. */
  38307. export class TouchCamera extends FreeCamera {
  38308. /**
  38309. * Defines the touch sensibility for rotation.
  38310. * The higher the faster.
  38311. */
  38312. touchAngularSensibility: number;
  38313. /**
  38314. * Defines the touch sensibility for move.
  38315. * The higher the faster.
  38316. */
  38317. touchMoveSensibility: number;
  38318. /**
  38319. * Instantiates a new touch camera.
  38320. * This represents a FPS type of camera controlled by touch.
  38321. * This is like a universal camera minus the Gamepad controls.
  38322. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38323. * @param name Define the name of the camera in the scene
  38324. * @param position Define the start position of the camera in the scene
  38325. * @param scene Define the scene the camera belongs to
  38326. */
  38327. constructor(name: string, position: Vector3, scene: Scene);
  38328. /**
  38329. * Gets the current object class name.
  38330. * @return the class name
  38331. */
  38332. getClassName(): string;
  38333. /** @hidden */
  38334. _setupInputs(): void;
  38335. }
  38336. }
  38337. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38338. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38339. import { Scene } from "babylonjs/scene";
  38340. import { Vector3, Axis } from "babylonjs/Maths/math";
  38341. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38342. /**
  38343. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38344. * being tilted forward or back and left or right.
  38345. */
  38346. export class DeviceOrientationCamera extends FreeCamera {
  38347. private _initialQuaternion;
  38348. private _quaternionCache;
  38349. private _tmpDragQuaternion;
  38350. /**
  38351. * Creates a new device orientation camera
  38352. * @param name The name of the camera
  38353. * @param position The start position camera
  38354. * @param scene The scene the camera belongs to
  38355. */
  38356. constructor(name: string, position: Vector3, scene: Scene);
  38357. /**
  38358. * @hidden
  38359. * Disabled pointer input on first orientation sensor update (Default: true)
  38360. */
  38361. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  38362. private _dragFactor;
  38363. /**
  38364. * Enabled turning on the y axis when the orientation sensor is active
  38365. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38366. */
  38367. enableHorizontalDragging(dragFactor?: number): void;
  38368. /**
  38369. * Gets the current instance class name ("DeviceOrientationCamera").
  38370. * This helps avoiding instanceof at run time.
  38371. * @returns the class name
  38372. */
  38373. getClassName(): string;
  38374. /**
  38375. * @hidden
  38376. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38377. */
  38378. _checkInputs(): void;
  38379. /**
  38380. * Reset the camera to its default orientation on the specified axis only.
  38381. * @param axis The axis to reset
  38382. */
  38383. resetToCurrentRotation(axis?: Axis): void;
  38384. }
  38385. }
  38386. declare module "babylonjs/Cameras/universalCamera" {
  38387. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38388. import { Scene } from "babylonjs/scene";
  38389. import { Vector3 } from "babylonjs/Maths/math";
  38390. /**
  38391. * 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,
  38392. * which still works and will still be found in many Playgrounds.
  38393. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38394. */
  38395. export class UniversalCamera extends TouchCamera {
  38396. /**
  38397. * Defines the gamepad rotation sensiblity.
  38398. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38399. */
  38400. gamepadAngularSensibility: number;
  38401. /**
  38402. * Defines the gamepad move sensiblity.
  38403. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38404. */
  38405. gamepadMoveSensibility: number;
  38406. /**
  38407. * 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,
  38408. * which still works and will still be found in many Playgrounds.
  38409. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38410. * @param name Define the name of the camera in the scene
  38411. * @param position Define the start position of the camera in the scene
  38412. * @param scene Define the scene the camera belongs to
  38413. */
  38414. constructor(name: string, position: Vector3, scene: Scene);
  38415. /**
  38416. * Gets the current object class name.
  38417. * @return the class name
  38418. */
  38419. getClassName(): string;
  38420. }
  38421. }
  38422. declare module "babylonjs/Cameras/gamepadCamera" {
  38423. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38424. import { Scene } from "babylonjs/scene";
  38425. import { Vector3 } from "babylonjs/Maths/math";
  38426. /**
  38427. * This represents a FPS type of camera. This is only here for back compat purpose.
  38428. * Please use the UniversalCamera instead as both are identical.
  38429. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38430. */
  38431. export class GamepadCamera extends UniversalCamera {
  38432. /**
  38433. * Instantiates a new Gamepad Camera
  38434. * This represents a FPS type of camera. This is only here for back compat purpose.
  38435. * Please use the UniversalCamera instead as both are identical.
  38436. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38437. * @param name Define the name of the camera in the scene
  38438. * @param position Define the start position of the camera in the scene
  38439. * @param scene Define the scene the camera belongs to
  38440. */
  38441. constructor(name: string, position: Vector3, scene: Scene);
  38442. /**
  38443. * Gets the current object class name.
  38444. * @return the class name
  38445. */
  38446. getClassName(): string;
  38447. }
  38448. }
  38449. declare module "babylonjs/Shaders/pass.fragment" {
  38450. /** @hidden */
  38451. export var passPixelShader: {
  38452. name: string;
  38453. shader: string;
  38454. };
  38455. }
  38456. declare module "babylonjs/Shaders/passCube.fragment" {
  38457. /** @hidden */
  38458. export var passCubePixelShader: {
  38459. name: string;
  38460. shader: string;
  38461. };
  38462. }
  38463. declare module "babylonjs/PostProcesses/passPostProcess" {
  38464. import { Nullable } from "babylonjs/types";
  38465. import { Camera } from "babylonjs/Cameras/camera";
  38466. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38467. import { Engine } from "babylonjs/Engines/engine";
  38468. import "babylonjs/Shaders/pass.fragment";
  38469. import "babylonjs/Shaders/passCube.fragment";
  38470. /**
  38471. * PassPostProcess which produces an output the same as it's input
  38472. */
  38473. export class PassPostProcess extends PostProcess {
  38474. /**
  38475. * Creates the PassPostProcess
  38476. * @param name The name of the effect.
  38477. * @param options The required width/height ratio to downsize to before computing the render pass.
  38478. * @param camera The camera to apply the render pass to.
  38479. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38480. * @param engine The engine which the post process will be applied. (default: current engine)
  38481. * @param reusable If the post process can be reused on the same frame. (default: false)
  38482. * @param textureType The type of texture to be used when performing the post processing.
  38483. * @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)
  38484. */
  38485. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38486. }
  38487. /**
  38488. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38489. */
  38490. export class PassCubePostProcess extends PostProcess {
  38491. private _face;
  38492. /**
  38493. * Gets or sets the cube face to display.
  38494. * * 0 is +X
  38495. * * 1 is -X
  38496. * * 2 is +Y
  38497. * * 3 is -Y
  38498. * * 4 is +Z
  38499. * * 5 is -Z
  38500. */
  38501. face: number;
  38502. /**
  38503. * Creates the PassCubePostProcess
  38504. * @param name The name of the effect.
  38505. * @param options The required width/height ratio to downsize to before computing the render pass.
  38506. * @param camera The camera to apply the render pass to.
  38507. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38508. * @param engine The engine which the post process will be applied. (default: current engine)
  38509. * @param reusable If the post process can be reused on the same frame. (default: false)
  38510. * @param textureType The type of texture to be used when performing the post processing.
  38511. * @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)
  38512. */
  38513. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38514. }
  38515. }
  38516. declare module "babylonjs/Shaders/anaglyph.fragment" {
  38517. /** @hidden */
  38518. export var anaglyphPixelShader: {
  38519. name: string;
  38520. shader: string;
  38521. };
  38522. }
  38523. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  38524. import { Engine } from "babylonjs/Engines/engine";
  38525. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38526. import { Camera } from "babylonjs/Cameras/camera";
  38527. import "babylonjs/Shaders/anaglyph.fragment";
  38528. /**
  38529. * Postprocess used to generate anaglyphic rendering
  38530. */
  38531. export class AnaglyphPostProcess extends PostProcess {
  38532. private _passedProcess;
  38533. /**
  38534. * Creates a new AnaglyphPostProcess
  38535. * @param name defines postprocess name
  38536. * @param options defines creation options or target ratio scale
  38537. * @param rigCameras defines cameras using this postprocess
  38538. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38539. * @param engine defines hosting engine
  38540. * @param reusable defines if the postprocess will be reused multiple times per frame
  38541. */
  38542. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38543. }
  38544. }
  38545. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  38546. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38547. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38548. import { Scene } from "babylonjs/scene";
  38549. import { Vector3 } from "babylonjs/Maths/math";
  38550. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38551. /**
  38552. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38553. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38554. */
  38555. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38556. /**
  38557. * Creates a new AnaglyphArcRotateCamera
  38558. * @param name defines camera name
  38559. * @param alpha defines alpha angle (in radians)
  38560. * @param beta defines beta angle (in radians)
  38561. * @param radius defines radius
  38562. * @param target defines camera target
  38563. * @param interaxialDistance defines distance between each color axis
  38564. * @param scene defines the hosting scene
  38565. */
  38566. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38567. /**
  38568. * Gets camera class name
  38569. * @returns AnaglyphArcRotateCamera
  38570. */
  38571. getClassName(): string;
  38572. }
  38573. }
  38574. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38575. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38576. import { Scene } from "babylonjs/scene";
  38577. import { Vector3 } from "babylonjs/Maths/math";
  38578. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38579. /**
  38580. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38581. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38582. */
  38583. export class AnaglyphFreeCamera extends FreeCamera {
  38584. /**
  38585. * Creates a new AnaglyphFreeCamera
  38586. * @param name defines camera name
  38587. * @param position defines initial position
  38588. * @param interaxialDistance defines distance between each color axis
  38589. * @param scene defines the hosting scene
  38590. */
  38591. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38592. /**
  38593. * Gets camera class name
  38594. * @returns AnaglyphFreeCamera
  38595. */
  38596. getClassName(): string;
  38597. }
  38598. }
  38599. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38600. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38601. import { Scene } from "babylonjs/scene";
  38602. import { Vector3 } from "babylonjs/Maths/math";
  38603. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38604. /**
  38605. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38606. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38607. */
  38608. export class AnaglyphGamepadCamera extends GamepadCamera {
  38609. /**
  38610. * Creates a new AnaglyphGamepadCamera
  38611. * @param name defines camera name
  38612. * @param position defines initial position
  38613. * @param interaxialDistance defines distance between each color axis
  38614. * @param scene defines the hosting scene
  38615. */
  38616. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38617. /**
  38618. * Gets camera class name
  38619. * @returns AnaglyphGamepadCamera
  38620. */
  38621. getClassName(): string;
  38622. }
  38623. }
  38624. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38625. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38626. import { Scene } from "babylonjs/scene";
  38627. import { Vector3 } from "babylonjs/Maths/math";
  38628. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38629. /**
  38630. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38631. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38632. */
  38633. export class AnaglyphUniversalCamera extends UniversalCamera {
  38634. /**
  38635. * Creates a new AnaglyphUniversalCamera
  38636. * @param name defines camera name
  38637. * @param position defines initial position
  38638. * @param interaxialDistance defines distance between each color axis
  38639. * @param scene defines the hosting scene
  38640. */
  38641. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38642. /**
  38643. * Gets camera class name
  38644. * @returns AnaglyphUniversalCamera
  38645. */
  38646. getClassName(): string;
  38647. }
  38648. }
  38649. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  38650. /** @hidden */
  38651. export var stereoscopicInterlacePixelShader: {
  38652. name: string;
  38653. shader: string;
  38654. };
  38655. }
  38656. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  38657. import { Camera } from "babylonjs/Cameras/camera";
  38658. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38659. import { Engine } from "babylonjs/Engines/engine";
  38660. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  38661. /**
  38662. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38663. */
  38664. export class StereoscopicInterlacePostProcess extends PostProcess {
  38665. private _stepSize;
  38666. private _passedProcess;
  38667. /**
  38668. * Initializes a StereoscopicInterlacePostProcess
  38669. * @param name The name of the effect.
  38670. * @param rigCameras The rig cameras to be appled to the post process
  38671. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38672. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38673. * @param engine The engine which the post process will be applied. (default: current engine)
  38674. * @param reusable If the post process can be reused on the same frame. (default: false)
  38675. */
  38676. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38677. }
  38678. }
  38679. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  38680. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38681. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38682. import { Scene } from "babylonjs/scene";
  38683. import { Vector3 } from "babylonjs/Maths/math";
  38684. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38685. /**
  38686. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38687. * @see http://doc.babylonjs.com/features/cameras
  38688. */
  38689. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38690. /**
  38691. * Creates a new StereoscopicArcRotateCamera
  38692. * @param name defines camera name
  38693. * @param alpha defines alpha angle (in radians)
  38694. * @param beta defines beta angle (in radians)
  38695. * @param radius defines radius
  38696. * @param target defines camera target
  38697. * @param interaxialDistance defines distance between each color axis
  38698. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38699. * @param scene defines the hosting scene
  38700. */
  38701. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38702. /**
  38703. * Gets camera class name
  38704. * @returns StereoscopicArcRotateCamera
  38705. */
  38706. getClassName(): string;
  38707. }
  38708. }
  38709. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38710. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38711. import { Scene } from "babylonjs/scene";
  38712. import { Vector3 } from "babylonjs/Maths/math";
  38713. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38714. /**
  38715. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38716. * @see http://doc.babylonjs.com/features/cameras
  38717. */
  38718. export class StereoscopicFreeCamera extends FreeCamera {
  38719. /**
  38720. * Creates a new StereoscopicFreeCamera
  38721. * @param name defines camera name
  38722. * @param position defines initial position
  38723. * @param interaxialDistance defines distance between each color axis
  38724. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38725. * @param scene defines the hosting scene
  38726. */
  38727. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38728. /**
  38729. * Gets camera class name
  38730. * @returns StereoscopicFreeCamera
  38731. */
  38732. getClassName(): string;
  38733. }
  38734. }
  38735. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38736. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38737. import { Scene } from "babylonjs/scene";
  38738. import { Vector3 } from "babylonjs/Maths/math";
  38739. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38740. /**
  38741. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38742. * @see http://doc.babylonjs.com/features/cameras
  38743. */
  38744. export class StereoscopicGamepadCamera extends GamepadCamera {
  38745. /**
  38746. * Creates a new StereoscopicGamepadCamera
  38747. * @param name defines camera name
  38748. * @param position defines initial position
  38749. * @param interaxialDistance defines distance between each color axis
  38750. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38751. * @param scene defines the hosting scene
  38752. */
  38753. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38754. /**
  38755. * Gets camera class name
  38756. * @returns StereoscopicGamepadCamera
  38757. */
  38758. getClassName(): string;
  38759. }
  38760. }
  38761. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38762. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38763. import { Scene } from "babylonjs/scene";
  38764. import { Vector3 } from "babylonjs/Maths/math";
  38765. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38766. /**
  38767. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38768. * @see http://doc.babylonjs.com/features/cameras
  38769. */
  38770. export class StereoscopicUniversalCamera extends UniversalCamera {
  38771. /**
  38772. * Creates a new StereoscopicUniversalCamera
  38773. * @param name defines camera name
  38774. * @param position defines initial position
  38775. * @param interaxialDistance defines distance between each color axis
  38776. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38777. * @param scene defines the hosting scene
  38778. */
  38779. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38780. /**
  38781. * Gets camera class name
  38782. * @returns StereoscopicUniversalCamera
  38783. */
  38784. getClassName(): string;
  38785. }
  38786. }
  38787. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38788. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38789. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38790. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38791. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38792. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38793. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38794. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38795. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38796. }
  38797. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38798. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38799. import { Scene } from "babylonjs/scene";
  38800. import { Vector3 } from "babylonjs/Maths/math";
  38801. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38802. /**
  38803. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38804. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38805. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38806. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38807. */
  38808. export class VirtualJoysticksCamera extends FreeCamera {
  38809. /**
  38810. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38811. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38812. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38813. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38814. * @param name Define the name of the camera in the scene
  38815. * @param position Define the start position of the camera in the scene
  38816. * @param scene Define the scene the camera belongs to
  38817. */
  38818. constructor(name: string, position: Vector3, scene: Scene);
  38819. /**
  38820. * Gets the current object class name.
  38821. * @return the class name
  38822. */
  38823. getClassName(): string;
  38824. }
  38825. }
  38826. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38827. import { Matrix } from "babylonjs/Maths/math";
  38828. /**
  38829. * This represents all the required metrics to create a VR camera.
  38830. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38831. */
  38832. export class VRCameraMetrics {
  38833. /**
  38834. * Define the horizontal resolution off the screen.
  38835. */
  38836. hResolution: number;
  38837. /**
  38838. * Define the vertical resolution off the screen.
  38839. */
  38840. vResolution: number;
  38841. /**
  38842. * Define the horizontal screen size.
  38843. */
  38844. hScreenSize: number;
  38845. /**
  38846. * Define the vertical screen size.
  38847. */
  38848. vScreenSize: number;
  38849. /**
  38850. * Define the vertical screen center position.
  38851. */
  38852. vScreenCenter: number;
  38853. /**
  38854. * Define the distance of the eyes to the screen.
  38855. */
  38856. eyeToScreenDistance: number;
  38857. /**
  38858. * Define the distance between both lenses
  38859. */
  38860. lensSeparationDistance: number;
  38861. /**
  38862. * Define the distance between both viewer's eyes.
  38863. */
  38864. interpupillaryDistance: number;
  38865. /**
  38866. * Define the distortion factor of the VR postprocess.
  38867. * Please, touch with care.
  38868. */
  38869. distortionK: number[];
  38870. /**
  38871. * Define the chromatic aberration correction factors for the VR post process.
  38872. */
  38873. chromaAbCorrection: number[];
  38874. /**
  38875. * Define the scale factor of the post process.
  38876. * The smaller the better but the slower.
  38877. */
  38878. postProcessScaleFactor: number;
  38879. /**
  38880. * Define an offset for the lens center.
  38881. */
  38882. lensCenterOffset: number;
  38883. /**
  38884. * Define if the current vr camera should compensate the distortion of the lense or not.
  38885. */
  38886. compensateDistortion: boolean;
  38887. /**
  38888. * Defines if multiview should be enabled when rendering (Default: false)
  38889. */
  38890. multiviewEnabled: boolean;
  38891. /**
  38892. * Gets the rendering aspect ratio based on the provided resolutions.
  38893. */
  38894. readonly aspectRatio: number;
  38895. /**
  38896. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38897. */
  38898. readonly aspectRatioFov: number;
  38899. /**
  38900. * @hidden
  38901. */
  38902. readonly leftHMatrix: Matrix;
  38903. /**
  38904. * @hidden
  38905. */
  38906. readonly rightHMatrix: Matrix;
  38907. /**
  38908. * @hidden
  38909. */
  38910. readonly leftPreViewMatrix: Matrix;
  38911. /**
  38912. * @hidden
  38913. */
  38914. readonly rightPreViewMatrix: Matrix;
  38915. /**
  38916. * Get the default VRMetrics based on the most generic setup.
  38917. * @returns the default vr metrics
  38918. */
  38919. static GetDefault(): VRCameraMetrics;
  38920. }
  38921. }
  38922. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38923. /** @hidden */
  38924. export var vrDistortionCorrectionPixelShader: {
  38925. name: string;
  38926. shader: string;
  38927. };
  38928. }
  38929. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38930. import { Camera } from "babylonjs/Cameras/camera";
  38931. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38932. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38933. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38934. /**
  38935. * VRDistortionCorrectionPostProcess used for mobile VR
  38936. */
  38937. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38938. private _isRightEye;
  38939. private _distortionFactors;
  38940. private _postProcessScaleFactor;
  38941. private _lensCenterOffset;
  38942. private _scaleIn;
  38943. private _scaleFactor;
  38944. private _lensCenter;
  38945. /**
  38946. * Initializes the VRDistortionCorrectionPostProcess
  38947. * @param name The name of the effect.
  38948. * @param camera The camera to apply the render pass to.
  38949. * @param isRightEye If this is for the right eye distortion
  38950. * @param vrMetrics All the required metrics for the VR camera
  38951. */
  38952. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38953. }
  38954. }
  38955. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38956. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38957. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38958. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38959. import { Scene } from "babylonjs/scene";
  38960. import { Vector3 } from "babylonjs/Maths/math";
  38961. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38962. import "babylonjs/Cameras/RigModes/vrRigMode";
  38963. /**
  38964. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38965. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38966. */
  38967. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38968. /**
  38969. * Creates a new VRDeviceOrientationArcRotateCamera
  38970. * @param name defines camera name
  38971. * @param alpha defines the camera rotation along the logitudinal axis
  38972. * @param beta defines the camera rotation along the latitudinal axis
  38973. * @param radius defines the camera distance from its target
  38974. * @param target defines the camera target
  38975. * @param scene defines the scene the camera belongs to
  38976. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38977. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38978. */
  38979. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38980. /**
  38981. * Gets camera class name
  38982. * @returns VRDeviceOrientationArcRotateCamera
  38983. */
  38984. getClassName(): string;
  38985. }
  38986. }
  38987. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38988. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38989. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38990. import { Scene } from "babylonjs/scene";
  38991. import { Vector3 } from "babylonjs/Maths/math";
  38992. import "babylonjs/Cameras/RigModes/vrRigMode";
  38993. /**
  38994. * Camera used to simulate VR rendering (based on FreeCamera)
  38995. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38996. */
  38997. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38998. /**
  38999. * Creates a new VRDeviceOrientationFreeCamera
  39000. * @param name defines camera name
  39001. * @param position defines the start position of the camera
  39002. * @param scene defines the scene the camera belongs to
  39003. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39004. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39005. */
  39006. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39007. /**
  39008. * Gets camera class name
  39009. * @returns VRDeviceOrientationFreeCamera
  39010. */
  39011. getClassName(): string;
  39012. }
  39013. }
  39014. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  39015. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39016. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39017. import { Scene } from "babylonjs/scene";
  39018. import { Vector3 } from "babylonjs/Maths/math";
  39019. /**
  39020. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39021. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39022. */
  39023. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39024. /**
  39025. * Creates a new VRDeviceOrientationGamepadCamera
  39026. * @param name defines camera name
  39027. * @param position defines the start position of the camera
  39028. * @param scene defines the scene the camera belongs to
  39029. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39030. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39031. */
  39032. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39033. /**
  39034. * Gets camera class name
  39035. * @returns VRDeviceOrientationGamepadCamera
  39036. */
  39037. getClassName(): string;
  39038. }
  39039. }
  39040. declare module "babylonjs/Gamepads/xboxGamepad" {
  39041. import { Observable } from "babylonjs/Misc/observable";
  39042. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39043. /**
  39044. * Defines supported buttons for XBox360 compatible gamepads
  39045. */
  39046. export enum Xbox360Button {
  39047. /** A */
  39048. A = 0,
  39049. /** B */
  39050. B = 1,
  39051. /** X */
  39052. X = 2,
  39053. /** Y */
  39054. Y = 3,
  39055. /** Start */
  39056. Start = 4,
  39057. /** Back */
  39058. Back = 5,
  39059. /** Left button */
  39060. LB = 6,
  39061. /** Right button */
  39062. RB = 7,
  39063. /** Left stick */
  39064. LeftStick = 8,
  39065. /** Right stick */
  39066. RightStick = 9
  39067. }
  39068. /** Defines values for XBox360 DPad */
  39069. export enum Xbox360Dpad {
  39070. /** Up */
  39071. Up = 0,
  39072. /** Down */
  39073. Down = 1,
  39074. /** Left */
  39075. Left = 2,
  39076. /** Right */
  39077. Right = 3
  39078. }
  39079. /**
  39080. * Defines a XBox360 gamepad
  39081. */
  39082. export class Xbox360Pad extends Gamepad {
  39083. private _leftTrigger;
  39084. private _rightTrigger;
  39085. private _onlefttriggerchanged;
  39086. private _onrighttriggerchanged;
  39087. private _onbuttondown;
  39088. private _onbuttonup;
  39089. private _ondpaddown;
  39090. private _ondpadup;
  39091. /** Observable raised when a button is pressed */
  39092. onButtonDownObservable: Observable<Xbox360Button>;
  39093. /** Observable raised when a button is released */
  39094. onButtonUpObservable: Observable<Xbox360Button>;
  39095. /** Observable raised when a pad is pressed */
  39096. onPadDownObservable: Observable<Xbox360Dpad>;
  39097. /** Observable raised when a pad is released */
  39098. onPadUpObservable: Observable<Xbox360Dpad>;
  39099. private _buttonA;
  39100. private _buttonB;
  39101. private _buttonX;
  39102. private _buttonY;
  39103. private _buttonBack;
  39104. private _buttonStart;
  39105. private _buttonLB;
  39106. private _buttonRB;
  39107. private _buttonLeftStick;
  39108. private _buttonRightStick;
  39109. private _dPadUp;
  39110. private _dPadDown;
  39111. private _dPadLeft;
  39112. private _dPadRight;
  39113. private _isXboxOnePad;
  39114. /**
  39115. * Creates a new XBox360 gamepad object
  39116. * @param id defines the id of this gamepad
  39117. * @param index defines its index
  39118. * @param gamepad defines the internal HTML gamepad object
  39119. * @param xboxOne defines if it is a XBox One gamepad
  39120. */
  39121. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39122. /**
  39123. * Defines the callback to call when left trigger is pressed
  39124. * @param callback defines the callback to use
  39125. */
  39126. onlefttriggerchanged(callback: (value: number) => void): void;
  39127. /**
  39128. * Defines the callback to call when right trigger is pressed
  39129. * @param callback defines the callback to use
  39130. */
  39131. onrighttriggerchanged(callback: (value: number) => void): void;
  39132. /**
  39133. * Gets the left trigger value
  39134. */
  39135. /**
  39136. * Sets the left trigger value
  39137. */
  39138. leftTrigger: number;
  39139. /**
  39140. * Gets the right trigger value
  39141. */
  39142. /**
  39143. * Sets the right trigger value
  39144. */
  39145. rightTrigger: number;
  39146. /**
  39147. * Defines the callback to call when a button is pressed
  39148. * @param callback defines the callback to use
  39149. */
  39150. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39151. /**
  39152. * Defines the callback to call when a button is released
  39153. * @param callback defines the callback to use
  39154. */
  39155. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39156. /**
  39157. * Defines the callback to call when a pad is pressed
  39158. * @param callback defines the callback to use
  39159. */
  39160. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39161. /**
  39162. * Defines the callback to call when a pad is released
  39163. * @param callback defines the callback to use
  39164. */
  39165. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39166. private _setButtonValue;
  39167. private _setDPadValue;
  39168. /**
  39169. * Gets the value of the `A` button
  39170. */
  39171. /**
  39172. * Sets the value of the `A` button
  39173. */
  39174. buttonA: number;
  39175. /**
  39176. * Gets the value of the `B` button
  39177. */
  39178. /**
  39179. * Sets the value of the `B` button
  39180. */
  39181. buttonB: number;
  39182. /**
  39183. * Gets the value of the `X` button
  39184. */
  39185. /**
  39186. * Sets the value of the `X` button
  39187. */
  39188. buttonX: number;
  39189. /**
  39190. * Gets the value of the `Y` button
  39191. */
  39192. /**
  39193. * Sets the value of the `Y` button
  39194. */
  39195. buttonY: number;
  39196. /**
  39197. * Gets the value of the `Start` button
  39198. */
  39199. /**
  39200. * Sets the value of the `Start` button
  39201. */
  39202. buttonStart: number;
  39203. /**
  39204. * Gets the value of the `Back` button
  39205. */
  39206. /**
  39207. * Sets the value of the `Back` button
  39208. */
  39209. buttonBack: number;
  39210. /**
  39211. * Gets the value of the `Left` button
  39212. */
  39213. /**
  39214. * Sets the value of the `Left` button
  39215. */
  39216. buttonLB: number;
  39217. /**
  39218. * Gets the value of the `Right` button
  39219. */
  39220. /**
  39221. * Sets the value of the `Right` button
  39222. */
  39223. buttonRB: number;
  39224. /**
  39225. * Gets the value of the Left joystick
  39226. */
  39227. /**
  39228. * Sets the value of the Left joystick
  39229. */
  39230. buttonLeftStick: number;
  39231. /**
  39232. * Gets the value of the Right joystick
  39233. */
  39234. /**
  39235. * Sets the value of the Right joystick
  39236. */
  39237. buttonRightStick: number;
  39238. /**
  39239. * Gets the value of D-pad up
  39240. */
  39241. /**
  39242. * Sets the value of D-pad up
  39243. */
  39244. dPadUp: number;
  39245. /**
  39246. * Gets the value of D-pad down
  39247. */
  39248. /**
  39249. * Sets the value of D-pad down
  39250. */
  39251. dPadDown: number;
  39252. /**
  39253. * Gets the value of D-pad left
  39254. */
  39255. /**
  39256. * Sets the value of D-pad left
  39257. */
  39258. dPadLeft: number;
  39259. /**
  39260. * Gets the value of D-pad right
  39261. */
  39262. /**
  39263. * Sets the value of D-pad right
  39264. */
  39265. dPadRight: number;
  39266. /**
  39267. * Force the gamepad to synchronize with device values
  39268. */
  39269. update(): void;
  39270. /**
  39271. * Disposes the gamepad
  39272. */
  39273. dispose(): void;
  39274. }
  39275. }
  39276. declare module "babylonjs/Materials/pushMaterial" {
  39277. import { Nullable } from "babylonjs/types";
  39278. import { Scene } from "babylonjs/scene";
  39279. import { Matrix } from "babylonjs/Maths/math";
  39280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39281. import { Mesh } from "babylonjs/Meshes/mesh";
  39282. import { Material } from "babylonjs/Materials/material";
  39283. import { Effect } from "babylonjs/Materials/effect";
  39284. /**
  39285. * Base class of materials working in push mode in babylon JS
  39286. * @hidden
  39287. */
  39288. export class PushMaterial extends Material {
  39289. protected _activeEffect: Effect;
  39290. protected _normalMatrix: Matrix;
  39291. /**
  39292. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39293. * This means that the material can keep using a previous shader while a new one is being compiled.
  39294. * This is mostly used when shader parallel compilation is supported (true by default)
  39295. */
  39296. allowShaderHotSwapping: boolean;
  39297. constructor(name: string, scene: Scene);
  39298. getEffect(): Effect;
  39299. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39300. /**
  39301. * Binds the given world matrix to the active effect
  39302. *
  39303. * @param world the matrix to bind
  39304. */
  39305. bindOnlyWorldMatrix(world: Matrix): void;
  39306. /**
  39307. * Binds the given normal matrix to the active effect
  39308. *
  39309. * @param normalMatrix the matrix to bind
  39310. */
  39311. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39312. bind(world: Matrix, mesh?: Mesh): void;
  39313. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39314. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39315. }
  39316. }
  39317. declare module "babylonjs/Materials/materialFlags" {
  39318. /**
  39319. * This groups all the flags used to control the materials channel.
  39320. */
  39321. export class MaterialFlags {
  39322. private static _DiffuseTextureEnabled;
  39323. /**
  39324. * Are diffuse textures enabled in the application.
  39325. */
  39326. static DiffuseTextureEnabled: boolean;
  39327. private static _AmbientTextureEnabled;
  39328. /**
  39329. * Are ambient textures enabled in the application.
  39330. */
  39331. static AmbientTextureEnabled: boolean;
  39332. private static _OpacityTextureEnabled;
  39333. /**
  39334. * Are opacity textures enabled in the application.
  39335. */
  39336. static OpacityTextureEnabled: boolean;
  39337. private static _ReflectionTextureEnabled;
  39338. /**
  39339. * Are reflection textures enabled in the application.
  39340. */
  39341. static ReflectionTextureEnabled: boolean;
  39342. private static _EmissiveTextureEnabled;
  39343. /**
  39344. * Are emissive textures enabled in the application.
  39345. */
  39346. static EmissiveTextureEnabled: boolean;
  39347. private static _SpecularTextureEnabled;
  39348. /**
  39349. * Are specular textures enabled in the application.
  39350. */
  39351. static SpecularTextureEnabled: boolean;
  39352. private static _BumpTextureEnabled;
  39353. /**
  39354. * Are bump textures enabled in the application.
  39355. */
  39356. static BumpTextureEnabled: boolean;
  39357. private static _LightmapTextureEnabled;
  39358. /**
  39359. * Are lightmap textures enabled in the application.
  39360. */
  39361. static LightmapTextureEnabled: boolean;
  39362. private static _RefractionTextureEnabled;
  39363. /**
  39364. * Are refraction textures enabled in the application.
  39365. */
  39366. static RefractionTextureEnabled: boolean;
  39367. private static _ColorGradingTextureEnabled;
  39368. /**
  39369. * Are color grading textures enabled in the application.
  39370. */
  39371. static ColorGradingTextureEnabled: boolean;
  39372. private static _FresnelEnabled;
  39373. /**
  39374. * Are fresnels enabled in the application.
  39375. */
  39376. static FresnelEnabled: boolean;
  39377. private static _ClearCoatTextureEnabled;
  39378. /**
  39379. * Are clear coat textures enabled in the application.
  39380. */
  39381. static ClearCoatTextureEnabled: boolean;
  39382. private static _ClearCoatBumpTextureEnabled;
  39383. /**
  39384. * Are clear coat bump textures enabled in the application.
  39385. */
  39386. static ClearCoatBumpTextureEnabled: boolean;
  39387. private static _ClearCoatTintTextureEnabled;
  39388. /**
  39389. * Are clear coat tint textures enabled in the application.
  39390. */
  39391. static ClearCoatTintTextureEnabled: boolean;
  39392. private static _SheenTextureEnabled;
  39393. /**
  39394. * Are sheen textures enabled in the application.
  39395. */
  39396. static SheenTextureEnabled: boolean;
  39397. private static _AnisotropicTextureEnabled;
  39398. /**
  39399. * Are anisotropic textures enabled in the application.
  39400. */
  39401. static AnisotropicTextureEnabled: boolean;
  39402. private static _ThicknessTextureEnabled;
  39403. /**
  39404. * Are thickness textures enabled in the application.
  39405. */
  39406. static ThicknessTextureEnabled: boolean;
  39407. }
  39408. }
  39409. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39410. /** @hidden */
  39411. export var defaultFragmentDeclaration: {
  39412. name: string;
  39413. shader: string;
  39414. };
  39415. }
  39416. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39417. /** @hidden */
  39418. export var defaultUboDeclaration: {
  39419. name: string;
  39420. shader: string;
  39421. };
  39422. }
  39423. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39424. /** @hidden */
  39425. export var lightFragmentDeclaration: {
  39426. name: string;
  39427. shader: string;
  39428. };
  39429. }
  39430. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39431. /** @hidden */
  39432. export var lightUboDeclaration: {
  39433. name: string;
  39434. shader: string;
  39435. };
  39436. }
  39437. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39438. /** @hidden */
  39439. export var lightsFragmentFunctions: {
  39440. name: string;
  39441. shader: string;
  39442. };
  39443. }
  39444. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39445. /** @hidden */
  39446. export var shadowsFragmentFunctions: {
  39447. name: string;
  39448. shader: string;
  39449. };
  39450. }
  39451. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39452. /** @hidden */
  39453. export var fresnelFunction: {
  39454. name: string;
  39455. shader: string;
  39456. };
  39457. }
  39458. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39459. /** @hidden */
  39460. export var reflectionFunction: {
  39461. name: string;
  39462. shader: string;
  39463. };
  39464. }
  39465. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39466. /** @hidden */
  39467. export var bumpFragmentFunctions: {
  39468. name: string;
  39469. shader: string;
  39470. };
  39471. }
  39472. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39473. /** @hidden */
  39474. export var logDepthDeclaration: {
  39475. name: string;
  39476. shader: string;
  39477. };
  39478. }
  39479. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39480. /** @hidden */
  39481. export var bumpFragment: {
  39482. name: string;
  39483. shader: string;
  39484. };
  39485. }
  39486. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39487. /** @hidden */
  39488. export var depthPrePass: {
  39489. name: string;
  39490. shader: string;
  39491. };
  39492. }
  39493. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39494. /** @hidden */
  39495. export var lightFragment: {
  39496. name: string;
  39497. shader: string;
  39498. };
  39499. }
  39500. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39501. /** @hidden */
  39502. export var logDepthFragment: {
  39503. name: string;
  39504. shader: string;
  39505. };
  39506. }
  39507. declare module "babylonjs/Shaders/default.fragment" {
  39508. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39509. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39510. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39511. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39512. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39513. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39514. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39515. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39516. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39517. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39518. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39519. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39520. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39521. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39522. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39523. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39524. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39525. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39526. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39527. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39528. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39529. /** @hidden */
  39530. export var defaultPixelShader: {
  39531. name: string;
  39532. shader: string;
  39533. };
  39534. }
  39535. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39536. /** @hidden */
  39537. export var defaultVertexDeclaration: {
  39538. name: string;
  39539. shader: string;
  39540. };
  39541. }
  39542. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39543. /** @hidden */
  39544. export var bumpVertexDeclaration: {
  39545. name: string;
  39546. shader: string;
  39547. };
  39548. }
  39549. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39550. /** @hidden */
  39551. export var bumpVertex: {
  39552. name: string;
  39553. shader: string;
  39554. };
  39555. }
  39556. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39557. /** @hidden */
  39558. export var fogVertex: {
  39559. name: string;
  39560. shader: string;
  39561. };
  39562. }
  39563. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39564. /** @hidden */
  39565. export var shadowsVertex: {
  39566. name: string;
  39567. shader: string;
  39568. };
  39569. }
  39570. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39571. /** @hidden */
  39572. export var pointCloudVertex: {
  39573. name: string;
  39574. shader: string;
  39575. };
  39576. }
  39577. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39578. /** @hidden */
  39579. export var logDepthVertex: {
  39580. name: string;
  39581. shader: string;
  39582. };
  39583. }
  39584. declare module "babylonjs/Shaders/default.vertex" {
  39585. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39586. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39587. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39588. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39589. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39590. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39591. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39592. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39593. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39594. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39595. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39596. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39597. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39598. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39599. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39600. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39601. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39602. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39603. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39604. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39605. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39606. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39607. /** @hidden */
  39608. export var defaultVertexShader: {
  39609. name: string;
  39610. shader: string;
  39611. };
  39612. }
  39613. declare module "babylonjs/Materials/standardMaterial" {
  39614. import { SmartArray } from "babylonjs/Misc/smartArray";
  39615. import { IAnimatable } from "babylonjs/Misc/tools";
  39616. import { Nullable } from "babylonjs/types";
  39617. import { Scene } from "babylonjs/scene";
  39618. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39619. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39621. import { Mesh } from "babylonjs/Meshes/mesh";
  39622. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39623. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39624. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39625. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39626. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39627. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39628. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39629. import "babylonjs/Shaders/default.fragment";
  39630. import "babylonjs/Shaders/default.vertex";
  39631. /** @hidden */
  39632. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39633. MAINUV1: boolean;
  39634. MAINUV2: boolean;
  39635. DIFFUSE: boolean;
  39636. DIFFUSEDIRECTUV: number;
  39637. AMBIENT: boolean;
  39638. AMBIENTDIRECTUV: number;
  39639. OPACITY: boolean;
  39640. OPACITYDIRECTUV: number;
  39641. OPACITYRGB: boolean;
  39642. REFLECTION: boolean;
  39643. EMISSIVE: boolean;
  39644. EMISSIVEDIRECTUV: number;
  39645. SPECULAR: boolean;
  39646. SPECULARDIRECTUV: number;
  39647. BUMP: boolean;
  39648. BUMPDIRECTUV: number;
  39649. PARALLAX: boolean;
  39650. PARALLAXOCCLUSION: boolean;
  39651. SPECULAROVERALPHA: boolean;
  39652. CLIPPLANE: boolean;
  39653. CLIPPLANE2: boolean;
  39654. CLIPPLANE3: boolean;
  39655. CLIPPLANE4: boolean;
  39656. ALPHATEST: boolean;
  39657. DEPTHPREPASS: boolean;
  39658. ALPHAFROMDIFFUSE: boolean;
  39659. POINTSIZE: boolean;
  39660. FOG: boolean;
  39661. SPECULARTERM: boolean;
  39662. DIFFUSEFRESNEL: boolean;
  39663. OPACITYFRESNEL: boolean;
  39664. REFLECTIONFRESNEL: boolean;
  39665. REFRACTIONFRESNEL: boolean;
  39666. EMISSIVEFRESNEL: boolean;
  39667. FRESNEL: boolean;
  39668. NORMAL: boolean;
  39669. UV1: boolean;
  39670. UV2: boolean;
  39671. VERTEXCOLOR: boolean;
  39672. VERTEXALPHA: boolean;
  39673. NUM_BONE_INFLUENCERS: number;
  39674. BonesPerMesh: number;
  39675. BONETEXTURE: boolean;
  39676. INSTANCES: boolean;
  39677. GLOSSINESS: boolean;
  39678. ROUGHNESS: boolean;
  39679. EMISSIVEASILLUMINATION: boolean;
  39680. LINKEMISSIVEWITHDIFFUSE: boolean;
  39681. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39682. LIGHTMAP: boolean;
  39683. LIGHTMAPDIRECTUV: number;
  39684. OBJECTSPACE_NORMALMAP: boolean;
  39685. USELIGHTMAPASSHADOWMAP: boolean;
  39686. REFLECTIONMAP_3D: boolean;
  39687. REFLECTIONMAP_SPHERICAL: boolean;
  39688. REFLECTIONMAP_PLANAR: boolean;
  39689. REFLECTIONMAP_CUBIC: boolean;
  39690. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39691. REFLECTIONMAP_PROJECTION: boolean;
  39692. REFLECTIONMAP_SKYBOX: boolean;
  39693. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39694. REFLECTIONMAP_EXPLICIT: boolean;
  39695. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39696. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39697. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39698. INVERTCUBICMAP: boolean;
  39699. LOGARITHMICDEPTH: boolean;
  39700. REFRACTION: boolean;
  39701. REFRACTIONMAP_3D: boolean;
  39702. REFLECTIONOVERALPHA: boolean;
  39703. TWOSIDEDLIGHTING: boolean;
  39704. SHADOWFLOAT: boolean;
  39705. MORPHTARGETS: boolean;
  39706. MORPHTARGETS_NORMAL: boolean;
  39707. MORPHTARGETS_TANGENT: boolean;
  39708. NUM_MORPH_INFLUENCERS: number;
  39709. NONUNIFORMSCALING: boolean;
  39710. PREMULTIPLYALPHA: boolean;
  39711. IMAGEPROCESSING: boolean;
  39712. VIGNETTE: boolean;
  39713. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39714. VIGNETTEBLENDMODEOPAQUE: boolean;
  39715. TONEMAPPING: boolean;
  39716. TONEMAPPING_ACES: boolean;
  39717. CONTRAST: boolean;
  39718. COLORCURVES: boolean;
  39719. COLORGRADING: boolean;
  39720. COLORGRADING3D: boolean;
  39721. SAMPLER3DGREENDEPTH: boolean;
  39722. SAMPLER3DBGRMAP: boolean;
  39723. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39724. MULTIVIEW: boolean;
  39725. /**
  39726. * If the reflection texture on this material is in linear color space
  39727. * @hidden
  39728. */
  39729. IS_REFLECTION_LINEAR: boolean;
  39730. /**
  39731. * If the refraction texture on this material is in linear color space
  39732. * @hidden
  39733. */
  39734. IS_REFRACTION_LINEAR: boolean;
  39735. EXPOSURE: boolean;
  39736. constructor();
  39737. setReflectionMode(modeToEnable: string): void;
  39738. }
  39739. /**
  39740. * This is the default material used in Babylon. It is the best trade off between quality
  39741. * and performances.
  39742. * @see http://doc.babylonjs.com/babylon101/materials
  39743. */
  39744. export class StandardMaterial extends PushMaterial {
  39745. private _diffuseTexture;
  39746. /**
  39747. * The basic texture of the material as viewed under a light.
  39748. */
  39749. diffuseTexture: Nullable<BaseTexture>;
  39750. private _ambientTexture;
  39751. /**
  39752. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39753. */
  39754. ambientTexture: Nullable<BaseTexture>;
  39755. private _opacityTexture;
  39756. /**
  39757. * Define the transparency of the material from a texture.
  39758. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39759. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39760. */
  39761. opacityTexture: Nullable<BaseTexture>;
  39762. private _reflectionTexture;
  39763. /**
  39764. * Define the texture used to display the reflection.
  39765. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39766. */
  39767. reflectionTexture: Nullable<BaseTexture>;
  39768. private _emissiveTexture;
  39769. /**
  39770. * Define texture of the material as if self lit.
  39771. * This will be mixed in the final result even in the absence of light.
  39772. */
  39773. emissiveTexture: Nullable<BaseTexture>;
  39774. private _specularTexture;
  39775. /**
  39776. * Define how the color and intensity of the highlight given by the light in the material.
  39777. */
  39778. specularTexture: Nullable<BaseTexture>;
  39779. private _bumpTexture;
  39780. /**
  39781. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39782. * 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.
  39783. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39784. */
  39785. bumpTexture: Nullable<BaseTexture>;
  39786. private _lightmapTexture;
  39787. /**
  39788. * Complex lighting can be computationally expensive to compute at runtime.
  39789. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39790. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39791. */
  39792. lightmapTexture: Nullable<BaseTexture>;
  39793. private _refractionTexture;
  39794. /**
  39795. * Define the texture used to display the refraction.
  39796. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39797. */
  39798. refractionTexture: Nullable<BaseTexture>;
  39799. /**
  39800. * The color of the material lit by the environmental background lighting.
  39801. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39802. */
  39803. ambientColor: Color3;
  39804. /**
  39805. * The basic color of the material as viewed under a light.
  39806. */
  39807. diffuseColor: Color3;
  39808. /**
  39809. * Define how the color and intensity of the highlight given by the light in the material.
  39810. */
  39811. specularColor: Color3;
  39812. /**
  39813. * Define the color of the material as if self lit.
  39814. * This will be mixed in the final result even in the absence of light.
  39815. */
  39816. emissiveColor: Color3;
  39817. /**
  39818. * Defines how sharp are the highlights in the material.
  39819. * The bigger the value the sharper giving a more glossy feeling to the result.
  39820. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39821. */
  39822. specularPower: number;
  39823. private _useAlphaFromDiffuseTexture;
  39824. /**
  39825. * Does the transparency come from the diffuse texture alpha channel.
  39826. */
  39827. useAlphaFromDiffuseTexture: boolean;
  39828. private _useEmissiveAsIllumination;
  39829. /**
  39830. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39831. */
  39832. useEmissiveAsIllumination: boolean;
  39833. private _linkEmissiveWithDiffuse;
  39834. /**
  39835. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39836. * the emissive level when the final color is close to one.
  39837. */
  39838. linkEmissiveWithDiffuse: boolean;
  39839. private _useSpecularOverAlpha;
  39840. /**
  39841. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39842. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39843. */
  39844. useSpecularOverAlpha: boolean;
  39845. private _useReflectionOverAlpha;
  39846. /**
  39847. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39848. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39849. */
  39850. useReflectionOverAlpha: boolean;
  39851. private _disableLighting;
  39852. /**
  39853. * Does lights from the scene impacts this material.
  39854. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39855. */
  39856. disableLighting: boolean;
  39857. private _useObjectSpaceNormalMap;
  39858. /**
  39859. * Allows using an object space normal map (instead of tangent space).
  39860. */
  39861. useObjectSpaceNormalMap: boolean;
  39862. private _useParallax;
  39863. /**
  39864. * Is parallax enabled or not.
  39865. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39866. */
  39867. useParallax: boolean;
  39868. private _useParallaxOcclusion;
  39869. /**
  39870. * Is parallax occlusion enabled or not.
  39871. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39872. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39873. */
  39874. useParallaxOcclusion: boolean;
  39875. /**
  39876. * 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.
  39877. */
  39878. parallaxScaleBias: number;
  39879. private _roughness;
  39880. /**
  39881. * Helps to define how blurry the reflections should appears in the material.
  39882. */
  39883. roughness: number;
  39884. /**
  39885. * In case of refraction, define the value of the indice of refraction.
  39886. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39887. */
  39888. indexOfRefraction: number;
  39889. /**
  39890. * Invert the refraction texture alongside the y axis.
  39891. * It can be useful with procedural textures or probe for instance.
  39892. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39893. */
  39894. invertRefractionY: boolean;
  39895. /**
  39896. * Defines the alpha limits in alpha test mode.
  39897. */
  39898. alphaCutOff: number;
  39899. private _useLightmapAsShadowmap;
  39900. /**
  39901. * In case of light mapping, define whether the map contains light or shadow informations.
  39902. */
  39903. useLightmapAsShadowmap: boolean;
  39904. private _diffuseFresnelParameters;
  39905. /**
  39906. * Define the diffuse fresnel parameters of the material.
  39907. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39908. */
  39909. diffuseFresnelParameters: FresnelParameters;
  39910. private _opacityFresnelParameters;
  39911. /**
  39912. * Define the opacity fresnel parameters of the material.
  39913. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39914. */
  39915. opacityFresnelParameters: FresnelParameters;
  39916. private _reflectionFresnelParameters;
  39917. /**
  39918. * Define the reflection fresnel parameters of the material.
  39919. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39920. */
  39921. reflectionFresnelParameters: FresnelParameters;
  39922. private _refractionFresnelParameters;
  39923. /**
  39924. * Define the refraction fresnel parameters of the material.
  39925. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39926. */
  39927. refractionFresnelParameters: FresnelParameters;
  39928. private _emissiveFresnelParameters;
  39929. /**
  39930. * Define the emissive fresnel parameters of the material.
  39931. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39932. */
  39933. emissiveFresnelParameters: FresnelParameters;
  39934. private _useReflectionFresnelFromSpecular;
  39935. /**
  39936. * If true automatically deducts the fresnels values from the material specularity.
  39937. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39938. */
  39939. useReflectionFresnelFromSpecular: boolean;
  39940. private _useGlossinessFromSpecularMapAlpha;
  39941. /**
  39942. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39943. */
  39944. useGlossinessFromSpecularMapAlpha: boolean;
  39945. private _maxSimultaneousLights;
  39946. /**
  39947. * Defines the maximum number of lights that can be used in the material
  39948. */
  39949. maxSimultaneousLights: number;
  39950. private _invertNormalMapX;
  39951. /**
  39952. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39953. */
  39954. invertNormalMapX: boolean;
  39955. private _invertNormalMapY;
  39956. /**
  39957. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39958. */
  39959. invertNormalMapY: boolean;
  39960. private _twoSidedLighting;
  39961. /**
  39962. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39963. */
  39964. twoSidedLighting: boolean;
  39965. /**
  39966. * Default configuration related to image processing available in the standard Material.
  39967. */
  39968. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39969. /**
  39970. * Gets the image processing configuration used either in this material.
  39971. */
  39972. /**
  39973. * Sets the Default image processing configuration used either in the this material.
  39974. *
  39975. * If sets to null, the scene one is in use.
  39976. */
  39977. imageProcessingConfiguration: ImageProcessingConfiguration;
  39978. /**
  39979. * Keep track of the image processing observer to allow dispose and replace.
  39980. */
  39981. private _imageProcessingObserver;
  39982. /**
  39983. * Attaches a new image processing configuration to the Standard Material.
  39984. * @param configuration
  39985. */
  39986. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39987. /**
  39988. * Gets wether the color curves effect is enabled.
  39989. */
  39990. /**
  39991. * Sets wether the color curves effect is enabled.
  39992. */
  39993. cameraColorCurvesEnabled: boolean;
  39994. /**
  39995. * Gets wether the color grading effect is enabled.
  39996. */
  39997. /**
  39998. * Gets wether the color grading effect is enabled.
  39999. */
  40000. cameraColorGradingEnabled: boolean;
  40001. /**
  40002. * Gets wether tonemapping is enabled or not.
  40003. */
  40004. /**
  40005. * Sets wether tonemapping is enabled or not
  40006. */
  40007. cameraToneMappingEnabled: boolean;
  40008. /**
  40009. * The camera exposure used on this material.
  40010. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40011. * This corresponds to a photographic exposure.
  40012. */
  40013. /**
  40014. * The camera exposure used on this material.
  40015. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40016. * This corresponds to a photographic exposure.
  40017. */
  40018. cameraExposure: number;
  40019. /**
  40020. * Gets The camera contrast used on this material.
  40021. */
  40022. /**
  40023. * Sets The camera contrast used on this material.
  40024. */
  40025. cameraContrast: number;
  40026. /**
  40027. * Gets the Color Grading 2D Lookup Texture.
  40028. */
  40029. /**
  40030. * Sets the Color Grading 2D Lookup Texture.
  40031. */
  40032. cameraColorGradingTexture: Nullable<BaseTexture>;
  40033. /**
  40034. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40035. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40036. * 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;
  40037. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40038. */
  40039. /**
  40040. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40041. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40042. * 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;
  40043. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40044. */
  40045. cameraColorCurves: Nullable<ColorCurves>;
  40046. /**
  40047. * Custom callback helping to override the default shader used in the material.
  40048. */
  40049. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40050. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40051. protected _worldViewProjectionMatrix: Matrix;
  40052. protected _globalAmbientColor: Color3;
  40053. protected _useLogarithmicDepth: boolean;
  40054. /**
  40055. * Instantiates a new standard material.
  40056. * This is the default material used in Babylon. It is the best trade off between quality
  40057. * and performances.
  40058. * @see http://doc.babylonjs.com/babylon101/materials
  40059. * @param name Define the name of the material in the scene
  40060. * @param scene Define the scene the material belong to
  40061. */
  40062. constructor(name: string, scene: Scene);
  40063. /**
  40064. * Gets a boolean indicating that current material needs to register RTT
  40065. */
  40066. readonly hasRenderTargetTextures: boolean;
  40067. /**
  40068. * Gets the current class name of the material e.g. "StandardMaterial"
  40069. * Mainly use in serialization.
  40070. * @returns the class name
  40071. */
  40072. getClassName(): string;
  40073. /**
  40074. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40075. * You can try switching to logarithmic depth.
  40076. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40077. */
  40078. useLogarithmicDepth: boolean;
  40079. /**
  40080. * Specifies if the material will require alpha blending
  40081. * @returns a boolean specifying if alpha blending is needed
  40082. */
  40083. needAlphaBlending(): boolean;
  40084. /**
  40085. * Specifies if this material should be rendered in alpha test mode
  40086. * @returns a boolean specifying if an alpha test is needed.
  40087. */
  40088. needAlphaTesting(): boolean;
  40089. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40090. /**
  40091. * Get the texture used for alpha test purpose.
  40092. * @returns the diffuse texture in case of the standard material.
  40093. */
  40094. getAlphaTestTexture(): Nullable<BaseTexture>;
  40095. /**
  40096. * Get if the submesh is ready to be used and all its information available.
  40097. * Child classes can use it to update shaders
  40098. * @param mesh defines the mesh to check
  40099. * @param subMesh defines which submesh to check
  40100. * @param useInstances specifies that instances should be used
  40101. * @returns a boolean indicating that the submesh is ready or not
  40102. */
  40103. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40104. /**
  40105. * Builds the material UBO layouts.
  40106. * Used internally during the effect preparation.
  40107. */
  40108. buildUniformLayout(): void;
  40109. /**
  40110. * Unbinds the material from the mesh
  40111. */
  40112. unbind(): void;
  40113. /**
  40114. * Binds the submesh to this material by preparing the effect and shader to draw
  40115. * @param world defines the world transformation matrix
  40116. * @param mesh defines the mesh containing the submesh
  40117. * @param subMesh defines the submesh to bind the material to
  40118. */
  40119. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40120. /**
  40121. * Get the list of animatables in the material.
  40122. * @returns the list of animatables object used in the material
  40123. */
  40124. getAnimatables(): IAnimatable[];
  40125. /**
  40126. * Gets the active textures from the material
  40127. * @returns an array of textures
  40128. */
  40129. getActiveTextures(): BaseTexture[];
  40130. /**
  40131. * Specifies if the material uses a texture
  40132. * @param texture defines the texture to check against the material
  40133. * @returns a boolean specifying if the material uses the texture
  40134. */
  40135. hasTexture(texture: BaseTexture): boolean;
  40136. /**
  40137. * Disposes the material
  40138. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40139. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40140. */
  40141. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40142. /**
  40143. * Makes a duplicate of the material, and gives it a new name
  40144. * @param name defines the new name for the duplicated material
  40145. * @returns the cloned material
  40146. */
  40147. clone(name: string): StandardMaterial;
  40148. /**
  40149. * Serializes this material in a JSON representation
  40150. * @returns the serialized material object
  40151. */
  40152. serialize(): any;
  40153. /**
  40154. * Creates a standard material from parsed material data
  40155. * @param source defines the JSON representation of the material
  40156. * @param scene defines the hosting scene
  40157. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40158. * @returns a new standard material
  40159. */
  40160. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40161. /**
  40162. * Are diffuse textures enabled in the application.
  40163. */
  40164. static DiffuseTextureEnabled: boolean;
  40165. /**
  40166. * Are ambient textures enabled in the application.
  40167. */
  40168. static AmbientTextureEnabled: boolean;
  40169. /**
  40170. * Are opacity textures enabled in the application.
  40171. */
  40172. static OpacityTextureEnabled: boolean;
  40173. /**
  40174. * Are reflection textures enabled in the application.
  40175. */
  40176. static ReflectionTextureEnabled: boolean;
  40177. /**
  40178. * Are emissive textures enabled in the application.
  40179. */
  40180. static EmissiveTextureEnabled: boolean;
  40181. /**
  40182. * Are specular textures enabled in the application.
  40183. */
  40184. static SpecularTextureEnabled: boolean;
  40185. /**
  40186. * Are bump textures enabled in the application.
  40187. */
  40188. static BumpTextureEnabled: boolean;
  40189. /**
  40190. * Are lightmap textures enabled in the application.
  40191. */
  40192. static LightmapTextureEnabled: boolean;
  40193. /**
  40194. * Are refraction textures enabled in the application.
  40195. */
  40196. static RefractionTextureEnabled: boolean;
  40197. /**
  40198. * Are color grading textures enabled in the application.
  40199. */
  40200. static ColorGradingTextureEnabled: boolean;
  40201. /**
  40202. * Are fresnels enabled in the application.
  40203. */
  40204. static FresnelEnabled: boolean;
  40205. }
  40206. }
  40207. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40208. import { Scene } from "babylonjs/scene";
  40209. import { Texture } from "babylonjs/Materials/Textures/texture";
  40210. /**
  40211. * A class extending Texture allowing drawing on a texture
  40212. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40213. */
  40214. export class DynamicTexture extends Texture {
  40215. private _generateMipMaps;
  40216. private _canvas;
  40217. private _context;
  40218. private _engine;
  40219. /**
  40220. * Creates a DynamicTexture
  40221. * @param name defines the name of the texture
  40222. * @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
  40223. * @param scene defines the scene where you want the texture
  40224. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40225. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40226. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40227. */
  40228. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40229. /**
  40230. * Get the current class name of the texture useful for serialization or dynamic coding.
  40231. * @returns "DynamicTexture"
  40232. */
  40233. getClassName(): string;
  40234. /**
  40235. * Gets the current state of canRescale
  40236. */
  40237. readonly canRescale: boolean;
  40238. private _recreate;
  40239. /**
  40240. * Scales the texture
  40241. * @param ratio the scale factor to apply to both width and height
  40242. */
  40243. scale(ratio: number): void;
  40244. /**
  40245. * Resizes the texture
  40246. * @param width the new width
  40247. * @param height the new height
  40248. */
  40249. scaleTo(width: number, height: number): void;
  40250. /**
  40251. * Gets the context of the canvas used by the texture
  40252. * @returns the canvas context of the dynamic texture
  40253. */
  40254. getContext(): CanvasRenderingContext2D;
  40255. /**
  40256. * Clears the texture
  40257. */
  40258. clear(): void;
  40259. /**
  40260. * Updates the texture
  40261. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40262. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40263. */
  40264. update(invertY?: boolean, premulAlpha?: boolean): void;
  40265. /**
  40266. * Draws text onto the texture
  40267. * @param text defines the text to be drawn
  40268. * @param x defines the placement of the text from the left
  40269. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40270. * @param font defines the font to be used with font-style, font-size, font-name
  40271. * @param color defines the color used for the text
  40272. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40273. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40274. * @param update defines whether texture is immediately update (default is true)
  40275. */
  40276. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40277. /**
  40278. * Clones the texture
  40279. * @returns the clone of the texture.
  40280. */
  40281. clone(): DynamicTexture;
  40282. /**
  40283. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40284. * @returns a serialized dynamic texture object
  40285. */
  40286. serialize(): any;
  40287. /** @hidden */
  40288. _rebuild(): void;
  40289. }
  40290. }
  40291. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40292. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40293. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40294. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40295. /** @hidden */
  40296. export var imageProcessingPixelShader: {
  40297. name: string;
  40298. shader: string;
  40299. };
  40300. }
  40301. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40302. import { Nullable } from "babylonjs/types";
  40303. import { Color4 } from "babylonjs/Maths/math";
  40304. import { Camera } from "babylonjs/Cameras/camera";
  40305. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40306. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40307. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40308. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40309. import { Engine } from "babylonjs/Engines/engine";
  40310. import "babylonjs/Shaders/imageProcessing.fragment";
  40311. import "babylonjs/Shaders/postprocess.vertex";
  40312. /**
  40313. * ImageProcessingPostProcess
  40314. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40315. */
  40316. export class ImageProcessingPostProcess extends PostProcess {
  40317. /**
  40318. * Default configuration related to image processing available in the PBR Material.
  40319. */
  40320. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40321. /**
  40322. * Gets the image processing configuration used either in this material.
  40323. */
  40324. /**
  40325. * Sets the Default image processing configuration used either in the this material.
  40326. *
  40327. * If sets to null, the scene one is in use.
  40328. */
  40329. imageProcessingConfiguration: ImageProcessingConfiguration;
  40330. /**
  40331. * Keep track of the image processing observer to allow dispose and replace.
  40332. */
  40333. private _imageProcessingObserver;
  40334. /**
  40335. * Attaches a new image processing configuration to the PBR Material.
  40336. * @param configuration
  40337. */
  40338. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40339. /**
  40340. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40341. */
  40342. /**
  40343. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40344. */
  40345. colorCurves: Nullable<ColorCurves>;
  40346. /**
  40347. * Gets wether the color curves effect is enabled.
  40348. */
  40349. /**
  40350. * Sets wether the color curves effect is enabled.
  40351. */
  40352. colorCurvesEnabled: boolean;
  40353. /**
  40354. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40355. */
  40356. /**
  40357. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40358. */
  40359. colorGradingTexture: Nullable<BaseTexture>;
  40360. /**
  40361. * Gets wether the color grading effect is enabled.
  40362. */
  40363. /**
  40364. * Gets wether the color grading effect is enabled.
  40365. */
  40366. colorGradingEnabled: boolean;
  40367. /**
  40368. * Gets exposure used in the effect.
  40369. */
  40370. /**
  40371. * Sets exposure used in the effect.
  40372. */
  40373. exposure: number;
  40374. /**
  40375. * Gets wether tonemapping is enabled or not.
  40376. */
  40377. /**
  40378. * Sets wether tonemapping is enabled or not
  40379. */
  40380. toneMappingEnabled: boolean;
  40381. /**
  40382. * Gets the type of tone mapping effect.
  40383. */
  40384. /**
  40385. * Sets the type of tone mapping effect.
  40386. */
  40387. toneMappingType: number;
  40388. /**
  40389. * Gets contrast used in the effect.
  40390. */
  40391. /**
  40392. * Sets contrast used in the effect.
  40393. */
  40394. contrast: number;
  40395. /**
  40396. * Gets Vignette stretch size.
  40397. */
  40398. /**
  40399. * Sets Vignette stretch size.
  40400. */
  40401. vignetteStretch: number;
  40402. /**
  40403. * Gets Vignette centre X Offset.
  40404. */
  40405. /**
  40406. * Sets Vignette centre X Offset.
  40407. */
  40408. vignetteCentreX: number;
  40409. /**
  40410. * Gets Vignette centre Y Offset.
  40411. */
  40412. /**
  40413. * Sets Vignette centre Y Offset.
  40414. */
  40415. vignetteCentreY: number;
  40416. /**
  40417. * Gets Vignette weight or intensity of the vignette effect.
  40418. */
  40419. /**
  40420. * Sets Vignette weight or intensity of the vignette effect.
  40421. */
  40422. vignetteWeight: number;
  40423. /**
  40424. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40425. * if vignetteEnabled is set to true.
  40426. */
  40427. /**
  40428. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40429. * if vignetteEnabled is set to true.
  40430. */
  40431. vignetteColor: Color4;
  40432. /**
  40433. * Gets Camera field of view used by the Vignette effect.
  40434. */
  40435. /**
  40436. * Sets Camera field of view used by the Vignette effect.
  40437. */
  40438. vignetteCameraFov: number;
  40439. /**
  40440. * Gets the vignette blend mode allowing different kind of effect.
  40441. */
  40442. /**
  40443. * Sets the vignette blend mode allowing different kind of effect.
  40444. */
  40445. vignetteBlendMode: number;
  40446. /**
  40447. * Gets wether the vignette effect is enabled.
  40448. */
  40449. /**
  40450. * Sets wether the vignette effect is enabled.
  40451. */
  40452. vignetteEnabled: boolean;
  40453. private _fromLinearSpace;
  40454. /**
  40455. * Gets wether the input of the processing is in Gamma or Linear Space.
  40456. */
  40457. /**
  40458. * Sets wether the input of the processing is in Gamma or Linear Space.
  40459. */
  40460. fromLinearSpace: boolean;
  40461. /**
  40462. * Defines cache preventing GC.
  40463. */
  40464. private _defines;
  40465. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40466. /**
  40467. * "ImageProcessingPostProcess"
  40468. * @returns "ImageProcessingPostProcess"
  40469. */
  40470. getClassName(): string;
  40471. protected _updateParameters(): void;
  40472. dispose(camera?: Camera): void;
  40473. }
  40474. }
  40475. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40476. import { Scene } from "babylonjs/scene";
  40477. import { Color3 } from "babylonjs/Maths/math";
  40478. import { Mesh } from "babylonjs/Meshes/mesh";
  40479. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40480. import { Nullable } from "babylonjs/types";
  40481. /**
  40482. * Class containing static functions to help procedurally build meshes
  40483. */
  40484. export class GroundBuilder {
  40485. /**
  40486. * Creates a ground mesh
  40487. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40488. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40490. * @param name defines the name of the mesh
  40491. * @param options defines the options used to create the mesh
  40492. * @param scene defines the hosting scene
  40493. * @returns the ground mesh
  40494. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40495. */
  40496. static CreateGround(name: string, options: {
  40497. width?: number;
  40498. height?: number;
  40499. subdivisions?: number;
  40500. subdivisionsX?: number;
  40501. subdivisionsY?: number;
  40502. updatable?: boolean;
  40503. }, scene: any): Mesh;
  40504. /**
  40505. * Creates a tiled ground mesh
  40506. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40507. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40508. * * 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
  40509. * * 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
  40510. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40511. * @param name defines the name of the mesh
  40512. * @param options defines the options used to create the mesh
  40513. * @param scene defines the hosting scene
  40514. * @returns the tiled ground mesh
  40515. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40516. */
  40517. static CreateTiledGround(name: string, options: {
  40518. xmin: number;
  40519. zmin: number;
  40520. xmax: number;
  40521. zmax: number;
  40522. subdivisions?: {
  40523. w: number;
  40524. h: number;
  40525. };
  40526. precision?: {
  40527. w: number;
  40528. h: number;
  40529. };
  40530. updatable?: boolean;
  40531. }, scene?: Nullable<Scene>): Mesh;
  40532. /**
  40533. * Creates a ground mesh from a height map
  40534. * * The parameter `url` sets the URL of the height map image resource.
  40535. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40536. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40537. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40538. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40539. * * 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.
  40540. * * 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).
  40541. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40543. * @param name defines the name of the mesh
  40544. * @param url defines the url to the height map
  40545. * @param options defines the options used to create the mesh
  40546. * @param scene defines the hosting scene
  40547. * @returns the ground mesh
  40548. * @see https://doc.babylonjs.com/babylon101/height_map
  40549. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40550. */
  40551. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40552. width?: number;
  40553. height?: number;
  40554. subdivisions?: number;
  40555. minHeight?: number;
  40556. maxHeight?: number;
  40557. colorFilter?: Color3;
  40558. alphaFilter?: number;
  40559. updatable?: boolean;
  40560. onReady?: (mesh: GroundMesh) => void;
  40561. }, scene?: Nullable<Scene>): GroundMesh;
  40562. }
  40563. }
  40564. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40565. import { Vector4 } from "babylonjs/Maths/math";
  40566. import { Mesh } from "babylonjs/Meshes/mesh";
  40567. /**
  40568. * Class containing static functions to help procedurally build meshes
  40569. */
  40570. export class TorusBuilder {
  40571. /**
  40572. * Creates a torus mesh
  40573. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40574. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40575. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40576. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40577. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40579. * @param name defines the name of the mesh
  40580. * @param options defines the options used to create the mesh
  40581. * @param scene defines the hosting scene
  40582. * @returns the torus mesh
  40583. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40584. */
  40585. static CreateTorus(name: string, options: {
  40586. diameter?: number;
  40587. thickness?: number;
  40588. tessellation?: number;
  40589. updatable?: boolean;
  40590. sideOrientation?: number;
  40591. frontUVs?: Vector4;
  40592. backUVs?: Vector4;
  40593. }, scene: any): Mesh;
  40594. }
  40595. }
  40596. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40597. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40598. import { Mesh } from "babylonjs/Meshes/mesh";
  40599. /**
  40600. * Class containing static functions to help procedurally build meshes
  40601. */
  40602. export class CylinderBuilder {
  40603. /**
  40604. * Creates a cylinder or a cone mesh
  40605. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40606. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40607. * * 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.
  40608. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40609. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40610. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40611. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40612. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40613. * * 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).
  40614. * * 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
  40615. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40616. * * 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
  40617. * * 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.
  40618. * * If `enclose` is false, a ring surface is one element.
  40619. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40620. * * 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
  40621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40622. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40624. * @param name defines the name of the mesh
  40625. * @param options defines the options used to create the mesh
  40626. * @param scene defines the hosting scene
  40627. * @returns the cylinder mesh
  40628. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40629. */
  40630. static CreateCylinder(name: string, options: {
  40631. height?: number;
  40632. diameterTop?: number;
  40633. diameterBottom?: number;
  40634. diameter?: number;
  40635. tessellation?: number;
  40636. subdivisions?: number;
  40637. arc?: number;
  40638. faceColors?: Color4[];
  40639. faceUV?: Vector4[];
  40640. updatable?: boolean;
  40641. hasRings?: boolean;
  40642. enclose?: boolean;
  40643. sideOrientation?: number;
  40644. frontUVs?: Vector4;
  40645. backUVs?: Vector4;
  40646. }, scene: any): Mesh;
  40647. }
  40648. }
  40649. declare module "babylonjs/Gamepads/gamepadManager" {
  40650. import { Observable } from "babylonjs/Misc/observable";
  40651. import { Nullable } from "babylonjs/types";
  40652. import { Scene } from "babylonjs/scene";
  40653. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40654. /**
  40655. * Manager for handling gamepads
  40656. */
  40657. export class GamepadManager {
  40658. private _scene?;
  40659. private _babylonGamepads;
  40660. private _oneGamepadConnected;
  40661. /** @hidden */
  40662. _isMonitoring: boolean;
  40663. private _gamepadEventSupported;
  40664. private _gamepadSupport;
  40665. /**
  40666. * observable to be triggered when the gamepad controller has been connected
  40667. */
  40668. onGamepadConnectedObservable: Observable<Gamepad>;
  40669. /**
  40670. * observable to be triggered when the gamepad controller has been disconnected
  40671. */
  40672. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40673. private _onGamepadConnectedEvent;
  40674. private _onGamepadDisconnectedEvent;
  40675. /**
  40676. * Initializes the gamepad manager
  40677. * @param _scene BabylonJS scene
  40678. */
  40679. constructor(_scene?: Scene | undefined);
  40680. /**
  40681. * The gamepads in the game pad manager
  40682. */
  40683. readonly gamepads: Gamepad[];
  40684. /**
  40685. * Get the gamepad controllers based on type
  40686. * @param type The type of gamepad controller
  40687. * @returns Nullable gamepad
  40688. */
  40689. getGamepadByType(type?: number): Nullable<Gamepad>;
  40690. /**
  40691. * Disposes the gamepad manager
  40692. */
  40693. dispose(): void;
  40694. private _addNewGamepad;
  40695. private _startMonitoringGamepads;
  40696. private _stopMonitoringGamepads;
  40697. /** @hidden */
  40698. _checkGamepadsStatus(): void;
  40699. private _updateGamepadObjects;
  40700. }
  40701. }
  40702. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40703. import { Nullable } from "babylonjs/types";
  40704. import { Scene } from "babylonjs/scene";
  40705. import { ISceneComponent } from "babylonjs/sceneComponent";
  40706. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40707. module "babylonjs/scene" {
  40708. interface Scene {
  40709. /** @hidden */
  40710. _gamepadManager: Nullable<GamepadManager>;
  40711. /**
  40712. * Gets the gamepad manager associated with the scene
  40713. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40714. */
  40715. gamepadManager: GamepadManager;
  40716. }
  40717. }
  40718. module "babylonjs/Cameras/freeCameraInputsManager" {
  40719. /**
  40720. * Interface representing a free camera inputs manager
  40721. */
  40722. interface FreeCameraInputsManager {
  40723. /**
  40724. * Adds gamepad input support to the FreeCameraInputsManager.
  40725. * @returns the FreeCameraInputsManager
  40726. */
  40727. addGamepad(): FreeCameraInputsManager;
  40728. }
  40729. }
  40730. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40731. /**
  40732. * Interface representing an arc rotate camera inputs manager
  40733. */
  40734. interface ArcRotateCameraInputsManager {
  40735. /**
  40736. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40737. * @returns the camera inputs manager
  40738. */
  40739. addGamepad(): ArcRotateCameraInputsManager;
  40740. }
  40741. }
  40742. /**
  40743. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40744. */
  40745. export class GamepadSystemSceneComponent implements ISceneComponent {
  40746. /**
  40747. * The component name helpfull to identify the component in the list of scene components.
  40748. */
  40749. readonly name: string;
  40750. /**
  40751. * The scene the component belongs to.
  40752. */
  40753. scene: Scene;
  40754. /**
  40755. * Creates a new instance of the component for the given scene
  40756. * @param scene Defines the scene to register the component in
  40757. */
  40758. constructor(scene: Scene);
  40759. /**
  40760. * Registers the component in a given scene
  40761. */
  40762. register(): void;
  40763. /**
  40764. * Rebuilds the elements related to this component in case of
  40765. * context lost for instance.
  40766. */
  40767. rebuild(): void;
  40768. /**
  40769. * Disposes the component and the associated ressources
  40770. */
  40771. dispose(): void;
  40772. private _beforeCameraUpdate;
  40773. }
  40774. }
  40775. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40776. import { Observable } from "babylonjs/Misc/observable";
  40777. import { Nullable } from "babylonjs/types";
  40778. import { Camera } from "babylonjs/Cameras/camera";
  40779. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40780. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40781. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40782. import { Scene } from "babylonjs/scene";
  40783. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40784. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40786. import { Mesh } from "babylonjs/Meshes/mesh";
  40787. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40788. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40789. import "babylonjs/Meshes/Builders/groundBuilder";
  40790. import "babylonjs/Meshes/Builders/torusBuilder";
  40791. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40792. import "babylonjs/Gamepads/gamepadSceneComponent";
  40793. import "babylonjs/Animations/animatable";
  40794. /**
  40795. * Options to modify the vr teleportation behavior.
  40796. */
  40797. export interface VRTeleportationOptions {
  40798. /**
  40799. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40800. */
  40801. floorMeshName?: string;
  40802. /**
  40803. * A list of meshes to be used as the teleportation floor. (default: empty)
  40804. */
  40805. floorMeshes?: Mesh[];
  40806. }
  40807. /**
  40808. * Options to modify the vr experience helper's behavior.
  40809. */
  40810. export interface VRExperienceHelperOptions extends WebVROptions {
  40811. /**
  40812. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40813. */
  40814. createDeviceOrientationCamera?: boolean;
  40815. /**
  40816. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40817. */
  40818. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40819. /**
  40820. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40821. */
  40822. laserToggle?: boolean;
  40823. /**
  40824. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40825. */
  40826. floorMeshes?: Mesh[];
  40827. /**
  40828. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40829. */
  40830. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40831. }
  40832. /**
  40833. * Event containing information after VR has been entered
  40834. */
  40835. export class OnAfterEnteringVRObservableEvent {
  40836. /**
  40837. * If entering vr was successful
  40838. */
  40839. success: boolean;
  40840. }
  40841. /**
  40842. * Helps to quickly add VR support to an existing scene.
  40843. * See http://doc.babylonjs.com/how_to/webvr_helper
  40844. */
  40845. export class VRExperienceHelper {
  40846. /** Options to modify the vr experience helper's behavior. */
  40847. webVROptions: VRExperienceHelperOptions;
  40848. private _scene;
  40849. private _position;
  40850. private _btnVR;
  40851. private _btnVRDisplayed;
  40852. private _webVRsupported;
  40853. private _webVRready;
  40854. private _webVRrequesting;
  40855. private _webVRpresenting;
  40856. private _hasEnteredVR;
  40857. private _fullscreenVRpresenting;
  40858. private _canvas;
  40859. private _webVRCamera;
  40860. private _vrDeviceOrientationCamera;
  40861. private _deviceOrientationCamera;
  40862. private _existingCamera;
  40863. private _onKeyDown;
  40864. private _onVrDisplayPresentChange;
  40865. private _onVRDisplayChanged;
  40866. private _onVRRequestPresentStart;
  40867. private _onVRRequestPresentComplete;
  40868. /**
  40869. * Observable raised right before entering VR.
  40870. */
  40871. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40872. /**
  40873. * Observable raised when entering VR has completed.
  40874. */
  40875. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40876. /**
  40877. * Observable raised when exiting VR.
  40878. */
  40879. onExitingVRObservable: Observable<VRExperienceHelper>;
  40880. /**
  40881. * Observable raised when controller mesh is loaded.
  40882. */
  40883. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40884. /** Return this.onEnteringVRObservable
  40885. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40886. */
  40887. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40888. /** Return this.onExitingVRObservable
  40889. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40890. */
  40891. readonly onExitingVR: Observable<VRExperienceHelper>;
  40892. /** Return this.onControllerMeshLoadedObservable
  40893. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40894. */
  40895. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40896. private _rayLength;
  40897. private _useCustomVRButton;
  40898. private _teleportationRequested;
  40899. private _teleportActive;
  40900. private _floorMeshName;
  40901. private _floorMeshesCollection;
  40902. private _rotationAllowed;
  40903. private _teleportBackwardsVector;
  40904. private _teleportationTarget;
  40905. private _isDefaultTeleportationTarget;
  40906. private _postProcessMove;
  40907. private _teleportationFillColor;
  40908. private _teleportationBorderColor;
  40909. private _rotationAngle;
  40910. private _haloCenter;
  40911. private _cameraGazer;
  40912. private _padSensibilityUp;
  40913. private _padSensibilityDown;
  40914. private _leftController;
  40915. private _rightController;
  40916. /**
  40917. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40918. */
  40919. onNewMeshSelected: Observable<AbstractMesh>;
  40920. /**
  40921. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40922. */
  40923. onNewMeshPicked: Observable<PickingInfo>;
  40924. private _circleEase;
  40925. /**
  40926. * Observable raised before camera teleportation
  40927. */
  40928. onBeforeCameraTeleport: Observable<Vector3>;
  40929. /**
  40930. * Observable raised after camera teleportation
  40931. */
  40932. onAfterCameraTeleport: Observable<Vector3>;
  40933. /**
  40934. * Observable raised when current selected mesh gets unselected
  40935. */
  40936. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40937. private _raySelectionPredicate;
  40938. /**
  40939. * To be optionaly changed by user to define custom ray selection
  40940. */
  40941. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40942. /**
  40943. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40944. */
  40945. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40946. /**
  40947. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40948. */
  40949. teleportationEnabled: boolean;
  40950. private _defaultHeight;
  40951. private _teleportationInitialized;
  40952. private _interactionsEnabled;
  40953. private _interactionsRequested;
  40954. private _displayGaze;
  40955. private _displayLaserPointer;
  40956. /**
  40957. * The mesh used to display where the user is going to teleport.
  40958. */
  40959. /**
  40960. * Sets the mesh to be used to display where the user is going to teleport.
  40961. */
  40962. teleportationTarget: Mesh;
  40963. /**
  40964. * 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
  40965. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40966. * See http://doc.babylonjs.com/resources/baking_transformations
  40967. */
  40968. gazeTrackerMesh: Mesh;
  40969. /**
  40970. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40971. */
  40972. updateGazeTrackerScale: boolean;
  40973. /**
  40974. * If the gaze trackers color should be updated when selecting meshes
  40975. */
  40976. updateGazeTrackerColor: boolean;
  40977. /**
  40978. * The gaze tracking mesh corresponding to the left controller
  40979. */
  40980. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40981. /**
  40982. * The gaze tracking mesh corresponding to the right controller
  40983. */
  40984. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40985. /**
  40986. * If the ray of the gaze should be displayed.
  40987. */
  40988. /**
  40989. * Sets if the ray of the gaze should be displayed.
  40990. */
  40991. displayGaze: boolean;
  40992. /**
  40993. * If the ray of the LaserPointer should be displayed.
  40994. */
  40995. /**
  40996. * Sets if the ray of the LaserPointer should be displayed.
  40997. */
  40998. displayLaserPointer: boolean;
  40999. /**
  41000. * The deviceOrientationCamera used as the camera when not in VR.
  41001. */
  41002. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41003. /**
  41004. * Based on the current WebVR support, returns the current VR camera used.
  41005. */
  41006. readonly currentVRCamera: Nullable<Camera>;
  41007. /**
  41008. * The webVRCamera which is used when in VR.
  41009. */
  41010. readonly webVRCamera: WebVRFreeCamera;
  41011. /**
  41012. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41013. */
  41014. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41015. private readonly _teleportationRequestInitiated;
  41016. /**
  41017. * Defines wether or not Pointer lock should be requested when switching to
  41018. * full screen.
  41019. */
  41020. requestPointerLockOnFullScreen: boolean;
  41021. /**
  41022. * Instantiates a VRExperienceHelper.
  41023. * Helps to quickly add VR support to an existing scene.
  41024. * @param scene The scene the VRExperienceHelper belongs to.
  41025. * @param webVROptions Options to modify the vr experience helper's behavior.
  41026. */
  41027. constructor(scene: Scene,
  41028. /** Options to modify the vr experience helper's behavior. */
  41029. webVROptions?: VRExperienceHelperOptions);
  41030. private _onDefaultMeshLoaded;
  41031. private _onResize;
  41032. private _onFullscreenChange;
  41033. /**
  41034. * Gets a value indicating if we are currently in VR mode.
  41035. */
  41036. readonly isInVRMode: boolean;
  41037. private onVrDisplayPresentChange;
  41038. private onVRDisplayChanged;
  41039. private moveButtonToBottomRight;
  41040. private displayVRButton;
  41041. private updateButtonVisibility;
  41042. private _cachedAngularSensibility;
  41043. /**
  41044. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41045. * Otherwise, will use the fullscreen API.
  41046. */
  41047. enterVR(): void;
  41048. /**
  41049. * Attempt to exit VR, or fullscreen.
  41050. */
  41051. exitVR(): void;
  41052. /**
  41053. * The position of the vr experience helper.
  41054. */
  41055. /**
  41056. * Sets the position of the vr experience helper.
  41057. */
  41058. position: Vector3;
  41059. /**
  41060. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41061. */
  41062. enableInteractions(): void;
  41063. private readonly _noControllerIsActive;
  41064. private beforeRender;
  41065. private _isTeleportationFloor;
  41066. /**
  41067. * Adds a floor mesh to be used for teleportation.
  41068. * @param floorMesh the mesh to be used for teleportation.
  41069. */
  41070. addFloorMesh(floorMesh: Mesh): void;
  41071. /**
  41072. * Removes a floor mesh from being used for teleportation.
  41073. * @param floorMesh the mesh to be removed.
  41074. */
  41075. removeFloorMesh(floorMesh: Mesh): void;
  41076. /**
  41077. * Enables interactions and teleportation using the VR controllers and gaze.
  41078. * @param vrTeleportationOptions options to modify teleportation behavior.
  41079. */
  41080. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41081. private _onNewGamepadConnected;
  41082. private _tryEnableInteractionOnController;
  41083. private _onNewGamepadDisconnected;
  41084. private _enableInteractionOnController;
  41085. private _checkTeleportWithRay;
  41086. private _checkRotate;
  41087. private _checkTeleportBackwards;
  41088. private _enableTeleportationOnController;
  41089. private _createTeleportationCircles;
  41090. private _displayTeleportationTarget;
  41091. private _hideTeleportationTarget;
  41092. private _rotateCamera;
  41093. private _moveTeleportationSelectorTo;
  41094. private _workingVector;
  41095. private _workingQuaternion;
  41096. private _workingMatrix;
  41097. /**
  41098. * Teleports the users feet to the desired location
  41099. * @param location The location where the user's feet should be placed
  41100. */
  41101. teleportCamera(location: Vector3): void;
  41102. private _convertNormalToDirectionOfRay;
  41103. private _castRayAndSelectObject;
  41104. private _notifySelectedMeshUnselected;
  41105. /**
  41106. * Sets the color of the laser ray from the vr controllers.
  41107. * @param color new color for the ray.
  41108. */
  41109. changeLaserColor(color: Color3): void;
  41110. /**
  41111. * Sets the color of the ray from the vr headsets gaze.
  41112. * @param color new color for the ray.
  41113. */
  41114. changeGazeColor(color: Color3): void;
  41115. /**
  41116. * Exits VR and disposes of the vr experience helper
  41117. */
  41118. dispose(): void;
  41119. /**
  41120. * Gets the name of the VRExperienceHelper class
  41121. * @returns "VRExperienceHelper"
  41122. */
  41123. getClassName(): string;
  41124. }
  41125. }
  41126. declare module "babylonjs/Cameras/VR/index" {
  41127. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41128. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41129. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41130. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41131. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41132. export * from "babylonjs/Cameras/VR/webVRCamera";
  41133. }
  41134. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41135. import { Observable } from "babylonjs/Misc/observable";
  41136. import { Nullable } from "babylonjs/types";
  41137. import { IDisposable, Scene } from "babylonjs/scene";
  41138. import { Vector3 } from "babylonjs/Maths/math";
  41139. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41140. import { Ray } from "babylonjs/Culling/ray";
  41141. /**
  41142. * Manages an XRSession
  41143. * @see https://doc.babylonjs.com/how_to/webxr
  41144. */
  41145. export class WebXRSessionManager implements IDisposable {
  41146. private scene;
  41147. /**
  41148. * Fires every time a new xrFrame arrives which can be used to update the camera
  41149. */
  41150. onXRFrameObservable: Observable<any>;
  41151. /**
  41152. * Fires when the xr session is ended either by the device or manually done
  41153. */
  41154. onXRSessionEnded: Observable<any>;
  41155. /** @hidden */
  41156. _xrSession: XRSession;
  41157. /** @hidden */
  41158. _frameOfReference: XRFrameOfReference;
  41159. /** @hidden */
  41160. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41161. /** @hidden */
  41162. _currentXRFrame: Nullable<XRFrame>;
  41163. private _xrNavigator;
  41164. private _xrDevice;
  41165. private _tmpMatrix;
  41166. /**
  41167. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41168. * @param scene The scene which the session should be created for
  41169. */
  41170. constructor(scene: Scene);
  41171. /**
  41172. * Initializes the manager
  41173. * After initialization enterXR can be called to start an XR session
  41174. * @returns Promise which resolves after it is initialized
  41175. */
  41176. initializeAsync(): Promise<void>;
  41177. /**
  41178. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41179. * @param sessionCreationOptions xr options to create the session with
  41180. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41181. * @returns Promise which resolves after it enters XR
  41182. */
  41183. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41184. /**
  41185. * Stops the xrSession and restores the renderloop
  41186. * @returns Promise which resolves after it exits XR
  41187. */
  41188. exitXRAsync(): Promise<void>;
  41189. /**
  41190. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41191. * @param ray ray to cast into the environment
  41192. * @returns Promise which resolves with a collision point in the environment if it exists
  41193. */
  41194. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41195. /**
  41196. * Checks if a session would be supported for the creation options specified
  41197. * @param options creation options to check if they are supported
  41198. * @returns true if supported
  41199. */
  41200. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41201. /**
  41202. * @hidden
  41203. * Converts the render layer of xrSession to a render target
  41204. * @param session session to create render target for
  41205. * @param scene scene the new render target should be created for
  41206. */
  41207. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41208. /**
  41209. * Disposes of the session manager
  41210. */
  41211. dispose(): void;
  41212. }
  41213. }
  41214. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41215. import { Scene } from "babylonjs/scene";
  41216. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41217. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41218. /**
  41219. * WebXR Camera which holds the views for the xrSession
  41220. * @see https://doc.babylonjs.com/how_to/webxr
  41221. */
  41222. export class WebXRCamera extends FreeCamera {
  41223. private static _TmpMatrix;
  41224. /**
  41225. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41226. * @param name the name of the camera
  41227. * @param scene the scene to add the camera to
  41228. */
  41229. constructor(name: string, scene: Scene);
  41230. private _updateNumberOfRigCameras;
  41231. /** @hidden */
  41232. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41233. /**
  41234. * Updates the cameras position from the current pose information of the XR session
  41235. * @param xrSessionManager the session containing pose information
  41236. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41237. */
  41238. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41239. }
  41240. }
  41241. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41242. import { Nullable } from "babylonjs/types";
  41243. import { Observable } from "babylonjs/Misc/observable";
  41244. import { IDisposable, Scene } from "babylonjs/scene";
  41245. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41247. import { Ray } from "babylonjs/Culling/ray";
  41248. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41249. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41250. /**
  41251. * States of the webXR experience
  41252. */
  41253. export enum WebXRState {
  41254. /**
  41255. * Transitioning to being in XR mode
  41256. */
  41257. ENTERING_XR = 0,
  41258. /**
  41259. * Transitioning to non XR mode
  41260. */
  41261. EXITING_XR = 1,
  41262. /**
  41263. * In XR mode and presenting
  41264. */
  41265. IN_XR = 2,
  41266. /**
  41267. * Not entered XR mode
  41268. */
  41269. NOT_IN_XR = 3
  41270. }
  41271. /**
  41272. * Helper class used to enable XR
  41273. * @see https://doc.babylonjs.com/how_to/webxr
  41274. */
  41275. export class WebXRExperienceHelper implements IDisposable {
  41276. private scene;
  41277. /**
  41278. * 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
  41279. */
  41280. container: AbstractMesh;
  41281. /**
  41282. * Camera used to render xr content
  41283. */
  41284. camera: WebXRCamera;
  41285. /**
  41286. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41287. */
  41288. state: WebXRState;
  41289. private _setState;
  41290. private static _TmpVector;
  41291. /**
  41292. * Fires when the state of the experience helper has changed
  41293. */
  41294. onStateChangedObservable: Observable<WebXRState>;
  41295. /** @hidden */
  41296. _sessionManager: WebXRSessionManager;
  41297. private _nonVRCamera;
  41298. private _originalSceneAutoClear;
  41299. private _supported;
  41300. /**
  41301. * Creates the experience helper
  41302. * @param scene the scene to attach the experience helper to
  41303. * @returns a promise for the experience helper
  41304. */
  41305. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41306. /**
  41307. * Creates a WebXRExperienceHelper
  41308. * @param scene The scene the helper should be created in
  41309. */
  41310. private constructor();
  41311. /**
  41312. * Exits XR mode and returns the scene to its original state
  41313. * @returns promise that resolves after xr mode has exited
  41314. */
  41315. exitXRAsync(): Promise<void>;
  41316. /**
  41317. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41318. * @param sessionCreationOptions options for the XR session
  41319. * @param frameOfReference frame of reference of the XR session
  41320. * @returns promise that resolves after xr mode has entered
  41321. */
  41322. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41323. /**
  41324. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41325. * @param ray ray to cast into the environment
  41326. * @returns Promise which resolves with a collision point in the environment if it exists
  41327. */
  41328. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41329. /**
  41330. * Updates the global position of the camera by moving the camera's container
  41331. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41332. * @param position The desired global position of the camera
  41333. */
  41334. setPositionOfCameraUsingContainer(position: Vector3): void;
  41335. /**
  41336. * Rotates the xr camera by rotating the camera's container around the camera's position
  41337. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41338. * @param rotation the desired quaternion rotation to apply to the camera
  41339. */
  41340. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41341. /**
  41342. * Checks if the creation options are supported by the xr session
  41343. * @param options creation options
  41344. * @returns true if supported
  41345. */
  41346. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41347. /**
  41348. * Disposes of the experience helper
  41349. */
  41350. dispose(): void;
  41351. }
  41352. }
  41353. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41354. import { Nullable } from "babylonjs/types";
  41355. import { Observable } from "babylonjs/Misc/observable";
  41356. import { IDisposable, Scene } from "babylonjs/scene";
  41357. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41358. /**
  41359. * Button which can be used to enter a different mode of XR
  41360. */
  41361. export class WebXREnterExitUIButton {
  41362. /** button element */
  41363. element: HTMLElement;
  41364. /** XR initialization options for the button */
  41365. initializationOptions: XRSessionCreationOptions;
  41366. /**
  41367. * Creates a WebXREnterExitUIButton
  41368. * @param element button element
  41369. * @param initializationOptions XR initialization options for the button
  41370. */
  41371. constructor(
  41372. /** button element */
  41373. element: HTMLElement,
  41374. /** XR initialization options for the button */
  41375. initializationOptions: XRSessionCreationOptions);
  41376. /**
  41377. * Overwritable function which can be used to update the button's visuals when the state changes
  41378. * @param activeButton the current active button in the UI
  41379. */
  41380. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41381. }
  41382. /**
  41383. * Options to create the webXR UI
  41384. */
  41385. export class WebXREnterExitUIOptions {
  41386. /**
  41387. * Context to enter xr with
  41388. */
  41389. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41390. /**
  41391. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41392. */
  41393. customButtons?: Array<WebXREnterExitUIButton>;
  41394. }
  41395. /**
  41396. * UI to allow the user to enter/exit XR mode
  41397. */
  41398. export class WebXREnterExitUI implements IDisposable {
  41399. private scene;
  41400. private _overlay;
  41401. private _buttons;
  41402. private _activeButton;
  41403. /**
  41404. * Fired every time the active button is changed.
  41405. *
  41406. * When xr is entered via a button that launches xr that button will be the callback parameter
  41407. *
  41408. * When exiting xr the callback parameter will be null)
  41409. */
  41410. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41411. /**
  41412. * Creates UI to allow the user to enter/exit XR mode
  41413. * @param scene the scene to add the ui to
  41414. * @param helper the xr experience helper to enter/exit xr with
  41415. * @param options options to configure the UI
  41416. * @returns the created ui
  41417. */
  41418. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41419. private constructor();
  41420. private _updateButtons;
  41421. /**
  41422. * Disposes of the object
  41423. */
  41424. dispose(): void;
  41425. }
  41426. }
  41427. declare module "babylonjs/Cameras/XR/webXRInput" {
  41428. import { IDisposable, Scene } from "babylonjs/scene";
  41429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41430. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41431. /**
  41432. * Represents an XR input
  41433. */
  41434. export class WebXRController {
  41435. /**
  41436. * 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
  41437. */
  41438. grip?: AbstractMesh;
  41439. /**
  41440. * Pointer which can be used to select objects or attach a visible laser to
  41441. */
  41442. pointer: AbstractMesh;
  41443. /**
  41444. * Creates the controller
  41445. * @see https://doc.babylonjs.com/how_to/webxr
  41446. * @param scene the scene which the controller should be associated to
  41447. */
  41448. constructor(scene: Scene);
  41449. /**
  41450. * Disposes of the object
  41451. */
  41452. dispose(): void;
  41453. }
  41454. /**
  41455. * XR input used to track XR inputs such as controllers/rays
  41456. */
  41457. export class WebXRInput implements IDisposable {
  41458. private helper;
  41459. /**
  41460. * XR controllers being tracked
  41461. */
  41462. controllers: Array<WebXRController>;
  41463. private _tmpMatrix;
  41464. private _frameObserver;
  41465. /**
  41466. * Initializes the WebXRInput
  41467. * @param helper experience helper which the input should be created for
  41468. */
  41469. constructor(helper: WebXRExperienceHelper);
  41470. /**
  41471. * Disposes of the object
  41472. */
  41473. dispose(): void;
  41474. }
  41475. }
  41476. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41477. import { Nullable } from "babylonjs/types";
  41478. import { IDisposable } from "babylonjs/scene";
  41479. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41480. /**
  41481. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41482. */
  41483. export class WebXRManagedOutputCanvas implements IDisposable {
  41484. private _canvas;
  41485. /**
  41486. * xrpresent context of the canvas which can be used to display/mirror xr content
  41487. */
  41488. canvasContext: Nullable<WebGLRenderingContext>;
  41489. /**
  41490. * Initializes the canvas to be added/removed upon entering/exiting xr
  41491. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41492. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41493. */
  41494. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41495. /**
  41496. * Disposes of the object
  41497. */
  41498. dispose(): void;
  41499. private _setManagedOutputCanvas;
  41500. private _addCanvas;
  41501. private _removeCanvas;
  41502. }
  41503. }
  41504. declare module "babylonjs/Cameras/XR/index" {
  41505. export * from "babylonjs/Cameras/XR/webXRCamera";
  41506. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41507. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41508. export * from "babylonjs/Cameras/XR/webXRInput";
  41509. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41510. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41511. }
  41512. declare module "babylonjs/Cameras/RigModes/index" {
  41513. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41514. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41515. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41516. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41517. }
  41518. declare module "babylonjs/Cameras/index" {
  41519. export * from "babylonjs/Cameras/Inputs/index";
  41520. export * from "babylonjs/Cameras/cameraInputsManager";
  41521. export * from "babylonjs/Cameras/camera";
  41522. export * from "babylonjs/Cameras/targetCamera";
  41523. export * from "babylonjs/Cameras/freeCamera";
  41524. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41525. export * from "babylonjs/Cameras/touchCamera";
  41526. export * from "babylonjs/Cameras/arcRotateCamera";
  41527. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41528. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41529. export * from "babylonjs/Cameras/flyCamera";
  41530. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41531. export * from "babylonjs/Cameras/followCamera";
  41532. export * from "babylonjs/Cameras/gamepadCamera";
  41533. export * from "babylonjs/Cameras/Stereoscopic/index";
  41534. export * from "babylonjs/Cameras/universalCamera";
  41535. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41536. export * from "babylonjs/Cameras/VR/index";
  41537. export * from "babylonjs/Cameras/XR/index";
  41538. export * from "babylonjs/Cameras/RigModes/index";
  41539. }
  41540. declare module "babylonjs/Collisions/index" {
  41541. export * from "babylonjs/Collisions/collider";
  41542. export * from "babylonjs/Collisions/collisionCoordinator";
  41543. export * from "babylonjs/Collisions/pickingInfo";
  41544. export * from "babylonjs/Collisions/intersectionInfo";
  41545. }
  41546. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41547. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41548. import { Vector3, Plane } from "babylonjs/Maths/math";
  41549. import { Ray } from "babylonjs/Culling/ray";
  41550. /**
  41551. * Contains an array of blocks representing the octree
  41552. */
  41553. export interface IOctreeContainer<T> {
  41554. /**
  41555. * Blocks within the octree
  41556. */
  41557. blocks: Array<OctreeBlock<T>>;
  41558. }
  41559. /**
  41560. * Class used to store a cell in an octree
  41561. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41562. */
  41563. export class OctreeBlock<T> {
  41564. /**
  41565. * Gets the content of the current block
  41566. */
  41567. entries: T[];
  41568. /**
  41569. * Gets the list of block children
  41570. */
  41571. blocks: Array<OctreeBlock<T>>;
  41572. private _depth;
  41573. private _maxDepth;
  41574. private _capacity;
  41575. private _minPoint;
  41576. private _maxPoint;
  41577. private _boundingVectors;
  41578. private _creationFunc;
  41579. /**
  41580. * Creates a new block
  41581. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41582. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41583. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41584. * @param depth defines the current depth of this block in the octree
  41585. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41586. * @param creationFunc defines a callback to call when an element is added to the block
  41587. */
  41588. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41589. /**
  41590. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41591. */
  41592. readonly capacity: number;
  41593. /**
  41594. * Gets the minimum vector (in world space) of the block's bounding box
  41595. */
  41596. readonly minPoint: Vector3;
  41597. /**
  41598. * Gets the maximum vector (in world space) of the block's bounding box
  41599. */
  41600. readonly maxPoint: Vector3;
  41601. /**
  41602. * Add a new element to this block
  41603. * @param entry defines the element to add
  41604. */
  41605. addEntry(entry: T): void;
  41606. /**
  41607. * Remove an element from this block
  41608. * @param entry defines the element to remove
  41609. */
  41610. removeEntry(entry: T): void;
  41611. /**
  41612. * Add an array of elements to this block
  41613. * @param entries defines the array of elements to add
  41614. */
  41615. addEntries(entries: T[]): void;
  41616. /**
  41617. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41618. * @param frustumPlanes defines the frustum planes to test
  41619. * @param selection defines the array to store current content if selection is positive
  41620. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41621. */
  41622. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41623. /**
  41624. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41625. * @param sphereCenter defines the bounding sphere center
  41626. * @param sphereRadius defines the bounding sphere radius
  41627. * @param selection defines the array to store current content if selection is positive
  41628. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41629. */
  41630. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41631. /**
  41632. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41633. * @param ray defines the ray to test with
  41634. * @param selection defines the array to store current content if selection is positive
  41635. */
  41636. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41637. /**
  41638. * Subdivide the content into child blocks (this block will then be empty)
  41639. */
  41640. createInnerBlocks(): void;
  41641. /**
  41642. * @hidden
  41643. */
  41644. 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;
  41645. }
  41646. }
  41647. declare module "babylonjs/Culling/Octrees/octree" {
  41648. import { SmartArray } from "babylonjs/Misc/smartArray";
  41649. import { Vector3, Plane } from "babylonjs/Maths/math";
  41650. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41652. import { Ray } from "babylonjs/Culling/ray";
  41653. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41654. /**
  41655. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41656. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41657. */
  41658. export class Octree<T> {
  41659. /** 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.) */
  41660. maxDepth: number;
  41661. /**
  41662. * Blocks within the octree containing objects
  41663. */
  41664. blocks: Array<OctreeBlock<T>>;
  41665. /**
  41666. * Content stored in the octree
  41667. */
  41668. dynamicContent: T[];
  41669. private _maxBlockCapacity;
  41670. private _selectionContent;
  41671. private _creationFunc;
  41672. /**
  41673. * Creates a octree
  41674. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41675. * @param creationFunc function to be used to instatiate the octree
  41676. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41677. * @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.)
  41678. */
  41679. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41680. /** 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.) */
  41681. maxDepth?: number);
  41682. /**
  41683. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41684. * @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);
  41685. * @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);
  41686. * @param entries meshes to be added to the octree blocks
  41687. */
  41688. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41689. /**
  41690. * Adds a mesh to the octree
  41691. * @param entry Mesh to add to the octree
  41692. */
  41693. addMesh(entry: T): void;
  41694. /**
  41695. * Remove an element from the octree
  41696. * @param entry defines the element to remove
  41697. */
  41698. removeMesh(entry: T): void;
  41699. /**
  41700. * Selects an array of meshes within the frustum
  41701. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41702. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41703. * @returns array of meshes within the frustum
  41704. */
  41705. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41706. /**
  41707. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41708. * @param sphereCenter defines the bounding sphere center
  41709. * @param sphereRadius defines the bounding sphere radius
  41710. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41711. * @returns an array of objects that intersect the sphere
  41712. */
  41713. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41714. /**
  41715. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41716. * @param ray defines the ray to test with
  41717. * @returns array of intersected objects
  41718. */
  41719. intersectsRay(ray: Ray): SmartArray<T>;
  41720. /**
  41721. * Adds a mesh into the octree block if it intersects the block
  41722. */
  41723. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41724. /**
  41725. * Adds a submesh into the octree block if it intersects the block
  41726. */
  41727. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41728. }
  41729. }
  41730. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41731. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41732. import { Scene } from "babylonjs/scene";
  41733. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41735. import { Ray } from "babylonjs/Culling/ray";
  41736. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41737. import { Collider } from "babylonjs/Collisions/collider";
  41738. module "babylonjs/scene" {
  41739. interface Scene {
  41740. /**
  41741. * @hidden
  41742. * Backing Filed
  41743. */
  41744. _selectionOctree: Octree<AbstractMesh>;
  41745. /**
  41746. * Gets the octree used to boost mesh selection (picking)
  41747. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41748. */
  41749. selectionOctree: Octree<AbstractMesh>;
  41750. /**
  41751. * Creates or updates the octree used to boost selection (picking)
  41752. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41753. * @param maxCapacity defines the maximum capacity per leaf
  41754. * @param maxDepth defines the maximum depth of the octree
  41755. * @returns an octree of AbstractMesh
  41756. */
  41757. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41758. }
  41759. }
  41760. module "babylonjs/Meshes/abstractMesh" {
  41761. interface AbstractMesh {
  41762. /**
  41763. * @hidden
  41764. * Backing Field
  41765. */
  41766. _submeshesOctree: Octree<SubMesh>;
  41767. /**
  41768. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41769. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41770. * @param maxCapacity defines the maximum size of each block (64 by default)
  41771. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41772. * @returns the new octree
  41773. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41774. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41775. */
  41776. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41777. }
  41778. }
  41779. /**
  41780. * Defines the octree scene component responsible to manage any octrees
  41781. * in a given scene.
  41782. */
  41783. export class OctreeSceneComponent {
  41784. /**
  41785. * The component name helpfull to identify the component in the list of scene components.
  41786. */
  41787. readonly name: string;
  41788. /**
  41789. * The scene the component belongs to.
  41790. */
  41791. scene: Scene;
  41792. /**
  41793. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41794. */
  41795. readonly checksIsEnabled: boolean;
  41796. /**
  41797. * Creates a new instance of the component for the given scene
  41798. * @param scene Defines the scene to register the component in
  41799. */
  41800. constructor(scene: Scene);
  41801. /**
  41802. * Registers the component in a given scene
  41803. */
  41804. register(): void;
  41805. /**
  41806. * Return the list of active meshes
  41807. * @returns the list of active meshes
  41808. */
  41809. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41810. /**
  41811. * Return the list of active sub meshes
  41812. * @param mesh The mesh to get the candidates sub meshes from
  41813. * @returns the list of active sub meshes
  41814. */
  41815. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41816. private _tempRay;
  41817. /**
  41818. * Return the list of sub meshes intersecting with a given local ray
  41819. * @param mesh defines the mesh to find the submesh for
  41820. * @param localRay defines the ray in local space
  41821. * @returns the list of intersecting sub meshes
  41822. */
  41823. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41824. /**
  41825. * Return the list of sub meshes colliding with a collider
  41826. * @param mesh defines the mesh to find the submesh for
  41827. * @param collider defines the collider to evaluate the collision against
  41828. * @returns the list of colliding sub meshes
  41829. */
  41830. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41831. /**
  41832. * Rebuilds the elements related to this component in case of
  41833. * context lost for instance.
  41834. */
  41835. rebuild(): void;
  41836. /**
  41837. * Disposes the component and the associated ressources.
  41838. */
  41839. dispose(): void;
  41840. }
  41841. }
  41842. declare module "babylonjs/Culling/Octrees/index" {
  41843. export * from "babylonjs/Culling/Octrees/octree";
  41844. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41845. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41846. }
  41847. declare module "babylonjs/Culling/index" {
  41848. export * from "babylonjs/Culling/boundingBox";
  41849. export * from "babylonjs/Culling/boundingInfo";
  41850. export * from "babylonjs/Culling/boundingSphere";
  41851. export * from "babylonjs/Culling/Octrees/index";
  41852. export * from "babylonjs/Culling/ray";
  41853. }
  41854. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41855. import { IDisposable, Scene } from "babylonjs/scene";
  41856. import { Nullable } from "babylonjs/types";
  41857. import { Observable } from "babylonjs/Misc/observable";
  41858. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41859. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  41860. /**
  41861. * Renders a layer on top of an existing scene
  41862. */
  41863. export class UtilityLayerRenderer implements IDisposable {
  41864. /** the original scene that will be rendered on top of */
  41865. originalScene: Scene;
  41866. private _pointerCaptures;
  41867. private _lastPointerEvents;
  41868. private static _DefaultUtilityLayer;
  41869. private static _DefaultKeepDepthUtilityLayer;
  41870. private _sharedGizmoLight;
  41871. /**
  41872. * @hidden
  41873. * Light which used by gizmos to get light shading
  41874. */
  41875. _getSharedGizmoLight(): HemisphericLight;
  41876. /**
  41877. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41878. */
  41879. pickUtilitySceneFirst: boolean;
  41880. /**
  41881. * 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)
  41882. */
  41883. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41884. /**
  41885. * 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)
  41886. */
  41887. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41888. /**
  41889. * The scene that is rendered on top of the original scene
  41890. */
  41891. utilityLayerScene: Scene;
  41892. /**
  41893. * If the utility layer should automatically be rendered on top of existing scene
  41894. */
  41895. shouldRender: boolean;
  41896. /**
  41897. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41898. */
  41899. onlyCheckPointerDownEvents: boolean;
  41900. /**
  41901. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41902. */
  41903. processAllEvents: boolean;
  41904. /**
  41905. * Observable raised when the pointer move from the utility layer scene to the main scene
  41906. */
  41907. onPointerOutObservable: Observable<number>;
  41908. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41909. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41910. private _afterRenderObserver;
  41911. private _sceneDisposeObserver;
  41912. private _originalPointerObserver;
  41913. /**
  41914. * Instantiates a UtilityLayerRenderer
  41915. * @param originalScene the original scene that will be rendered on top of
  41916. * @param handleEvents boolean indicating if the utility layer should handle events
  41917. */
  41918. constructor(
  41919. /** the original scene that will be rendered on top of */
  41920. originalScene: Scene, handleEvents?: boolean);
  41921. private _notifyObservers;
  41922. /**
  41923. * Renders the utility layers scene on top of the original scene
  41924. */
  41925. render(): void;
  41926. /**
  41927. * Disposes of the renderer
  41928. */
  41929. dispose(): void;
  41930. private _updateCamera;
  41931. }
  41932. }
  41933. declare module "babylonjs/Gizmos/gizmo" {
  41934. import { Nullable } from "babylonjs/types";
  41935. import { IDisposable } from "babylonjs/scene";
  41936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41937. import { Mesh } from "babylonjs/Meshes/mesh";
  41938. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41939. /**
  41940. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41941. */
  41942. export class Gizmo implements IDisposable {
  41943. /** The utility layer the gizmo will be added to */
  41944. gizmoLayer: UtilityLayerRenderer;
  41945. /**
  41946. * The root mesh of the gizmo
  41947. */
  41948. _rootMesh: Mesh;
  41949. private _attachedMesh;
  41950. /**
  41951. * Ratio for the scale of the gizmo (Default: 1)
  41952. */
  41953. scaleRatio: number;
  41954. /**
  41955. * If a custom mesh has been set (Default: false)
  41956. */
  41957. protected _customMeshSet: boolean;
  41958. /**
  41959. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41960. * * When set, interactions will be enabled
  41961. */
  41962. attachedMesh: Nullable<AbstractMesh>;
  41963. /**
  41964. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41965. * @param mesh The mesh to replace the default mesh of the gizmo
  41966. */
  41967. setCustomMesh(mesh: Mesh): void;
  41968. /**
  41969. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41970. */
  41971. updateGizmoRotationToMatchAttachedMesh: boolean;
  41972. /**
  41973. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41974. */
  41975. updateGizmoPositionToMatchAttachedMesh: boolean;
  41976. /**
  41977. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41978. */
  41979. protected _updateScale: boolean;
  41980. protected _interactionsEnabled: boolean;
  41981. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41982. private _beforeRenderObserver;
  41983. private _tempVector;
  41984. /**
  41985. * Creates a gizmo
  41986. * @param gizmoLayer The utility layer the gizmo will be added to
  41987. */
  41988. constructor(
  41989. /** The utility layer the gizmo will be added to */
  41990. gizmoLayer?: UtilityLayerRenderer);
  41991. /**
  41992. * Updates the gizmo to match the attached mesh's position/rotation
  41993. */
  41994. protected _update(): void;
  41995. /**
  41996. * Disposes of the gizmo
  41997. */
  41998. dispose(): void;
  41999. }
  42000. }
  42001. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42002. import { Observable } from "babylonjs/Misc/observable";
  42003. import { Nullable } from "babylonjs/types";
  42004. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42005. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42007. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42008. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42009. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42010. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42011. import { Scene } from "babylonjs/scene";
  42012. /**
  42013. * Single axis drag gizmo
  42014. */
  42015. export class AxisDragGizmo extends Gizmo {
  42016. /**
  42017. * Drag behavior responsible for the gizmos dragging interactions
  42018. */
  42019. dragBehavior: PointerDragBehavior;
  42020. private _pointerObserver;
  42021. /**
  42022. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42023. */
  42024. snapDistance: number;
  42025. /**
  42026. * Event that fires each time the gizmo snaps to a new location.
  42027. * * snapDistance is the the change in distance
  42028. */
  42029. onSnapObservable: Observable<{
  42030. snapDistance: number;
  42031. }>;
  42032. /** @hidden */
  42033. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42034. /** @hidden */
  42035. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42036. /**
  42037. * Creates an AxisDragGizmo
  42038. * @param gizmoLayer The utility layer the gizmo will be added to
  42039. * @param dragAxis The axis which the gizmo will be able to drag on
  42040. * @param color The color of the gizmo
  42041. */
  42042. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42043. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42044. /**
  42045. * Disposes of the gizmo
  42046. */
  42047. dispose(): void;
  42048. }
  42049. }
  42050. declare module "babylonjs/Debug/axesViewer" {
  42051. import { Vector3 } from "babylonjs/Maths/math";
  42052. import { Nullable } from "babylonjs/types";
  42053. import { Scene } from "babylonjs/scene";
  42054. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42055. /**
  42056. * The Axes viewer will show 3 axes in a specific point in space
  42057. */
  42058. export class AxesViewer {
  42059. private _xAxis;
  42060. private _yAxis;
  42061. private _zAxis;
  42062. private _scaleLinesFactor;
  42063. private _instanced;
  42064. /**
  42065. * Gets the hosting scene
  42066. */
  42067. scene: Scene;
  42068. /**
  42069. * Gets or sets a number used to scale line length
  42070. */
  42071. scaleLines: number;
  42072. /** Gets the node hierarchy used to render x-axis */
  42073. readonly xAxis: TransformNode;
  42074. /** Gets the node hierarchy used to render y-axis */
  42075. readonly yAxis: TransformNode;
  42076. /** Gets the node hierarchy used to render z-axis */
  42077. readonly zAxis: TransformNode;
  42078. /**
  42079. * Creates a new AxesViewer
  42080. * @param scene defines the hosting scene
  42081. * @param scaleLines defines a number used to scale line length (1 by default)
  42082. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42083. * @param xAxis defines the node hierarchy used to render the x-axis
  42084. * @param yAxis defines the node hierarchy used to render the y-axis
  42085. * @param zAxis defines the node hierarchy used to render the z-axis
  42086. */
  42087. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42088. /**
  42089. * Force the viewer to update
  42090. * @param position defines the position of the viewer
  42091. * @param xaxis defines the x axis of the viewer
  42092. * @param yaxis defines the y axis of the viewer
  42093. * @param zaxis defines the z axis of the viewer
  42094. */
  42095. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42096. /**
  42097. * Creates an instance of this axes viewer.
  42098. * @returns a new axes viewer with instanced meshes
  42099. */
  42100. createInstance(): AxesViewer;
  42101. /** Releases resources */
  42102. dispose(): void;
  42103. private static _SetRenderingGroupId;
  42104. }
  42105. }
  42106. declare module "babylonjs/Debug/boneAxesViewer" {
  42107. import { Nullable } from "babylonjs/types";
  42108. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42109. import { Vector3 } from "babylonjs/Maths/math";
  42110. import { Mesh } from "babylonjs/Meshes/mesh";
  42111. import { Bone } from "babylonjs/Bones/bone";
  42112. import { Scene } from "babylonjs/scene";
  42113. /**
  42114. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42115. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42116. */
  42117. export class BoneAxesViewer extends AxesViewer {
  42118. /**
  42119. * Gets or sets the target mesh where to display the axes viewer
  42120. */
  42121. mesh: Nullable<Mesh>;
  42122. /**
  42123. * Gets or sets the target bone where to display the axes viewer
  42124. */
  42125. bone: Nullable<Bone>;
  42126. /** Gets current position */
  42127. pos: Vector3;
  42128. /** Gets direction of X axis */
  42129. xaxis: Vector3;
  42130. /** Gets direction of Y axis */
  42131. yaxis: Vector3;
  42132. /** Gets direction of Z axis */
  42133. zaxis: Vector3;
  42134. /**
  42135. * Creates a new BoneAxesViewer
  42136. * @param scene defines the hosting scene
  42137. * @param bone defines the target bone
  42138. * @param mesh defines the target mesh
  42139. * @param scaleLines defines a scaling factor for line length (1 by default)
  42140. */
  42141. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42142. /**
  42143. * Force the viewer to update
  42144. */
  42145. update(): void;
  42146. /** Releases resources */
  42147. dispose(): void;
  42148. }
  42149. }
  42150. declare module "babylonjs/Debug/debugLayer" {
  42151. import { Observable } from "babylonjs/Misc/observable";
  42152. import { Scene } from "babylonjs/scene";
  42153. /**
  42154. * Interface used to define scene explorer extensibility option
  42155. */
  42156. export interface IExplorerExtensibilityOption {
  42157. /**
  42158. * Define the option label
  42159. */
  42160. label: string;
  42161. /**
  42162. * Defines the action to execute on click
  42163. */
  42164. action: (entity: any) => void;
  42165. }
  42166. /**
  42167. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42168. */
  42169. export interface IExplorerExtensibilityGroup {
  42170. /**
  42171. * Defines a predicate to test if a given type mut be extended
  42172. */
  42173. predicate: (entity: any) => boolean;
  42174. /**
  42175. * Gets the list of options added to a type
  42176. */
  42177. entries: IExplorerExtensibilityOption[];
  42178. }
  42179. /**
  42180. * Interface used to define the options to use to create the Inspector
  42181. */
  42182. export interface IInspectorOptions {
  42183. /**
  42184. * Display in overlay mode (default: false)
  42185. */
  42186. overlay?: boolean;
  42187. /**
  42188. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42189. */
  42190. globalRoot?: HTMLElement;
  42191. /**
  42192. * Display the Scene explorer
  42193. */
  42194. showExplorer?: boolean;
  42195. /**
  42196. * Display the property inspector
  42197. */
  42198. showInspector?: boolean;
  42199. /**
  42200. * Display in embed mode (both panes on the right)
  42201. */
  42202. embedMode?: boolean;
  42203. /**
  42204. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42205. */
  42206. handleResize?: boolean;
  42207. /**
  42208. * Allow the panes to popup (default: true)
  42209. */
  42210. enablePopup?: boolean;
  42211. /**
  42212. * Allow the panes to be closed by users (default: true)
  42213. */
  42214. enableClose?: boolean;
  42215. /**
  42216. * Optional list of extensibility entries
  42217. */
  42218. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42219. /**
  42220. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42221. */
  42222. inspectorURL?: string;
  42223. }
  42224. module "babylonjs/scene" {
  42225. interface Scene {
  42226. /**
  42227. * @hidden
  42228. * Backing field
  42229. */
  42230. _debugLayer: DebugLayer;
  42231. /**
  42232. * Gets the debug layer (aka Inspector) associated with the scene
  42233. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42234. */
  42235. debugLayer: DebugLayer;
  42236. }
  42237. }
  42238. /**
  42239. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42240. * what is happening in your scene
  42241. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42242. */
  42243. export class DebugLayer {
  42244. /**
  42245. * Define the url to get the inspector script from.
  42246. * By default it uses the babylonjs CDN.
  42247. * @ignoreNaming
  42248. */
  42249. static InspectorURL: string;
  42250. private _scene;
  42251. private BJSINSPECTOR;
  42252. /**
  42253. * Observable triggered when a property is changed through the inspector.
  42254. */
  42255. onPropertyChangedObservable: Observable<{
  42256. object: any;
  42257. property: string;
  42258. value: any;
  42259. initialValue: any;
  42260. }>;
  42261. /**
  42262. * Instantiates a new debug layer.
  42263. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42264. * what is happening in your scene
  42265. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42266. * @param scene Defines the scene to inspect
  42267. */
  42268. constructor(scene: Scene);
  42269. /** Creates the inspector window. */
  42270. private _createInspector;
  42271. /**
  42272. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42273. * @param entity defines the entity to select
  42274. * @param lineContainerTitle defines the specific block to highlight
  42275. */
  42276. select(entity: any, lineContainerTitle?: string): void;
  42277. /** Get the inspector from bundle or global */
  42278. private _getGlobalInspector;
  42279. /**
  42280. * Get if the inspector is visible or not.
  42281. * @returns true if visible otherwise, false
  42282. */
  42283. isVisible(): boolean;
  42284. /**
  42285. * Hide the inspector and close its window.
  42286. */
  42287. hide(): void;
  42288. /**
  42289. * Launch the debugLayer.
  42290. * @param config Define the configuration of the inspector
  42291. * @return a promise fulfilled when the debug layer is visible
  42292. */
  42293. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42294. }
  42295. }
  42296. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42297. import { Nullable } from "babylonjs/types";
  42298. import { Scene } from "babylonjs/scene";
  42299. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42300. import { Mesh } from "babylonjs/Meshes/mesh";
  42301. /**
  42302. * Class containing static functions to help procedurally build meshes
  42303. */
  42304. export class BoxBuilder {
  42305. /**
  42306. * Creates a box mesh
  42307. * * The parameter `size` sets the size (float) of each box side (default 1)
  42308. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42309. * * 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)
  42310. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42311. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42312. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42314. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42315. * @param name defines the name of the mesh
  42316. * @param options defines the options used to create the mesh
  42317. * @param scene defines the hosting scene
  42318. * @returns the box mesh
  42319. */
  42320. static CreateBox(name: string, options: {
  42321. size?: number;
  42322. width?: number;
  42323. height?: number;
  42324. depth?: number;
  42325. faceUV?: Vector4[];
  42326. faceColors?: Color4[];
  42327. sideOrientation?: number;
  42328. frontUVs?: Vector4;
  42329. backUVs?: Vector4;
  42330. wrap?: boolean;
  42331. topBaseAt?: number;
  42332. bottomBaseAt?: number;
  42333. updatable?: boolean;
  42334. }, scene?: Nullable<Scene>): Mesh;
  42335. }
  42336. }
  42337. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42338. import { Vector4 } from "babylonjs/Maths/math";
  42339. import { Mesh } from "babylonjs/Meshes/mesh";
  42340. /**
  42341. * Class containing static functions to help procedurally build meshes
  42342. */
  42343. export class SphereBuilder {
  42344. /**
  42345. * Creates a sphere mesh
  42346. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42347. * * 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`)
  42348. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42349. * * 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
  42350. * * 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)
  42351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42352. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42354. * @param name defines the name of the mesh
  42355. * @param options defines the options used to create the mesh
  42356. * @param scene defines the hosting scene
  42357. * @returns the sphere mesh
  42358. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42359. */
  42360. static CreateSphere(name: string, options: {
  42361. segments?: number;
  42362. diameter?: number;
  42363. diameterX?: number;
  42364. diameterY?: number;
  42365. diameterZ?: number;
  42366. arc?: number;
  42367. slice?: number;
  42368. sideOrientation?: number;
  42369. frontUVs?: Vector4;
  42370. backUVs?: Vector4;
  42371. updatable?: boolean;
  42372. }, scene: any): Mesh;
  42373. }
  42374. }
  42375. declare module "babylonjs/Debug/physicsViewer" {
  42376. import { Nullable } from "babylonjs/types";
  42377. import { Scene } from "babylonjs/scene";
  42378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42379. import { Mesh } from "babylonjs/Meshes/mesh";
  42380. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42381. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42382. /**
  42383. * Used to show the physics impostor around the specific mesh
  42384. */
  42385. export class PhysicsViewer {
  42386. /** @hidden */
  42387. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42388. /** @hidden */
  42389. protected _meshes: Array<Nullable<AbstractMesh>>;
  42390. /** @hidden */
  42391. protected _scene: Nullable<Scene>;
  42392. /** @hidden */
  42393. protected _numMeshes: number;
  42394. /** @hidden */
  42395. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42396. private _renderFunction;
  42397. private _utilityLayer;
  42398. private _debugBoxMesh;
  42399. private _debugSphereMesh;
  42400. private _debugCylinderMesh;
  42401. private _debugMaterial;
  42402. private _debugMeshMeshes;
  42403. /**
  42404. * Creates a new PhysicsViewer
  42405. * @param scene defines the hosting scene
  42406. */
  42407. constructor(scene: Scene);
  42408. /** @hidden */
  42409. protected _updateDebugMeshes(): void;
  42410. /**
  42411. * Renders a specified physic impostor
  42412. * @param impostor defines the impostor to render
  42413. * @param targetMesh defines the mesh represented by the impostor
  42414. * @returns the new debug mesh used to render the impostor
  42415. */
  42416. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42417. /**
  42418. * Hides a specified physic impostor
  42419. * @param impostor defines the impostor to hide
  42420. */
  42421. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42422. private _getDebugMaterial;
  42423. private _getDebugBoxMesh;
  42424. private _getDebugSphereMesh;
  42425. private _getDebugCylinderMesh;
  42426. private _getDebugMeshMesh;
  42427. private _getDebugMesh;
  42428. /** Releases all resources */
  42429. dispose(): void;
  42430. }
  42431. }
  42432. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  42433. import { Vector3, Color4 } from "babylonjs/Maths/math";
  42434. import { Nullable } from "babylonjs/types";
  42435. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42436. import { Scene } from "babylonjs/scene";
  42437. /**
  42438. * Class containing static functions to help procedurally build meshes
  42439. */
  42440. export class LinesBuilder {
  42441. /**
  42442. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42443. * * 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
  42444. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42445. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42446. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42447. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42448. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42449. * * 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
  42450. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42452. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42453. * @param name defines the name of the new line system
  42454. * @param options defines the options used to create the line system
  42455. * @param scene defines the hosting scene
  42456. * @returns a new line system mesh
  42457. */
  42458. static CreateLineSystem(name: string, options: {
  42459. lines: Vector3[][];
  42460. updatable?: boolean;
  42461. instance?: Nullable<LinesMesh>;
  42462. colors?: Nullable<Color4[][]>;
  42463. useVertexAlpha?: boolean;
  42464. }, scene: Nullable<Scene>): LinesMesh;
  42465. /**
  42466. * Creates a line mesh
  42467. * 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
  42468. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42469. * * The parameter `points` is an array successive Vector3
  42470. * * 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
  42471. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42472. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42473. * * When updating an instance, remember that only point positions can change, not the number of points
  42474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42475. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42476. * @param name defines the name of the new line system
  42477. * @param options defines the options used to create the line system
  42478. * @param scene defines the hosting scene
  42479. * @returns a new line mesh
  42480. */
  42481. static CreateLines(name: string, options: {
  42482. points: Vector3[];
  42483. updatable?: boolean;
  42484. instance?: Nullable<LinesMesh>;
  42485. colors?: Color4[];
  42486. useVertexAlpha?: boolean;
  42487. }, scene?: Nullable<Scene>): LinesMesh;
  42488. /**
  42489. * Creates a dashed line mesh
  42490. * * 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
  42491. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42492. * * The parameter `points` is an array successive Vector3
  42493. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42494. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42495. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42496. * * 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
  42497. * * When updating an instance, remember that only point positions can change, not the number of points
  42498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42499. * @param name defines the name of the mesh
  42500. * @param options defines the options used to create the mesh
  42501. * @param scene defines the hosting scene
  42502. * @returns the dashed line mesh
  42503. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42504. */
  42505. static CreateDashedLines(name: string, options: {
  42506. points: Vector3[];
  42507. dashSize?: number;
  42508. gapSize?: number;
  42509. dashNb?: number;
  42510. updatable?: boolean;
  42511. instance?: LinesMesh;
  42512. }, scene?: Nullable<Scene>): LinesMesh;
  42513. }
  42514. }
  42515. declare module "babylonjs/Debug/rayHelper" {
  42516. import { Nullable } from "babylonjs/types";
  42517. import { Ray } from "babylonjs/Culling/ray";
  42518. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42519. import { Scene } from "babylonjs/scene";
  42520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42521. import "babylonjs/Meshes/Builders/linesBuilder";
  42522. /**
  42523. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42524. * in order to better appreciate the issue one might have.
  42525. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42526. */
  42527. export class RayHelper {
  42528. /**
  42529. * Defines the ray we are currently tryin to visualize.
  42530. */
  42531. ray: Nullable<Ray>;
  42532. private _renderPoints;
  42533. private _renderLine;
  42534. private _renderFunction;
  42535. private _scene;
  42536. private _updateToMeshFunction;
  42537. private _attachedToMesh;
  42538. private _meshSpaceDirection;
  42539. private _meshSpaceOrigin;
  42540. /**
  42541. * Helper function to create a colored helper in a scene in one line.
  42542. * @param ray Defines the ray we are currently tryin to visualize
  42543. * @param scene Defines the scene the ray is used in
  42544. * @param color Defines the color we want to see the ray in
  42545. * @returns The newly created ray helper.
  42546. */
  42547. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42548. /**
  42549. * Instantiate a new ray helper.
  42550. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42551. * in order to better appreciate the issue one might have.
  42552. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42553. * @param ray Defines the ray we are currently tryin to visualize
  42554. */
  42555. constructor(ray: Ray);
  42556. /**
  42557. * Shows the ray we are willing to debug.
  42558. * @param scene Defines the scene the ray needs to be rendered in
  42559. * @param color Defines the color the ray needs to be rendered in
  42560. */
  42561. show(scene: Scene, color?: Color3): void;
  42562. /**
  42563. * Hides the ray we are debugging.
  42564. */
  42565. hide(): void;
  42566. private _render;
  42567. /**
  42568. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42569. * @param mesh Defines the mesh we want the helper attached to
  42570. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42571. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42572. * @param length Defines the length of the ray
  42573. */
  42574. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42575. /**
  42576. * Detach the ray helper from the mesh it has previously been attached to.
  42577. */
  42578. detachFromMesh(): void;
  42579. private _updateToMesh;
  42580. /**
  42581. * Dispose the helper and release its associated resources.
  42582. */
  42583. dispose(): void;
  42584. }
  42585. }
  42586. declare module "babylonjs/Debug/skeletonViewer" {
  42587. import { Color3 } from "babylonjs/Maths/math";
  42588. import { Scene } from "babylonjs/scene";
  42589. import { Nullable } from "babylonjs/types";
  42590. import { Skeleton } from "babylonjs/Bones/skeleton";
  42591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42592. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42593. /**
  42594. * Class used to render a debug view of a given skeleton
  42595. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42596. */
  42597. export class SkeletonViewer {
  42598. /** defines the skeleton to render */
  42599. skeleton: Skeleton;
  42600. /** defines the mesh attached to the skeleton */
  42601. mesh: AbstractMesh;
  42602. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42603. autoUpdateBonesMatrices: boolean;
  42604. /** defines the rendering group id to use with the viewer */
  42605. renderingGroupId: number;
  42606. /** Gets or sets the color used to render the skeleton */
  42607. color: Color3;
  42608. private _scene;
  42609. private _debugLines;
  42610. private _debugMesh;
  42611. private _isEnabled;
  42612. private _renderFunction;
  42613. private _utilityLayer;
  42614. /**
  42615. * Returns the mesh used to render the bones
  42616. */
  42617. readonly debugMesh: Nullable<LinesMesh>;
  42618. /**
  42619. * Creates a new SkeletonViewer
  42620. * @param skeleton defines the skeleton to render
  42621. * @param mesh defines the mesh attached to the skeleton
  42622. * @param scene defines the hosting scene
  42623. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42624. * @param renderingGroupId defines the rendering group id to use with the viewer
  42625. */
  42626. constructor(
  42627. /** defines the skeleton to render */
  42628. skeleton: Skeleton,
  42629. /** defines the mesh attached to the skeleton */
  42630. mesh: AbstractMesh, scene: Scene,
  42631. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42632. autoUpdateBonesMatrices?: boolean,
  42633. /** defines the rendering group id to use with the viewer */
  42634. renderingGroupId?: number);
  42635. /** Gets or sets a boolean indicating if the viewer is enabled */
  42636. isEnabled: boolean;
  42637. private _getBonePosition;
  42638. private _getLinesForBonesWithLength;
  42639. private _getLinesForBonesNoLength;
  42640. /** Update the viewer to sync with current skeleton state */
  42641. update(): void;
  42642. /** Release associated resources */
  42643. dispose(): void;
  42644. }
  42645. }
  42646. declare module "babylonjs/Debug/index" {
  42647. export * from "babylonjs/Debug/axesViewer";
  42648. export * from "babylonjs/Debug/boneAxesViewer";
  42649. export * from "babylonjs/Debug/debugLayer";
  42650. export * from "babylonjs/Debug/physicsViewer";
  42651. export * from "babylonjs/Debug/rayHelper";
  42652. export * from "babylonjs/Debug/skeletonViewer";
  42653. }
  42654. declare module "babylonjs/Engines/nullEngine" {
  42655. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42656. import { Scene } from "babylonjs/scene";
  42657. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42658. import { Engine } from "babylonjs/Engines/engine";
  42659. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42660. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42661. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42662. import { Effect } from "babylonjs/Materials/effect";
  42663. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  42664. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  42665. /**
  42666. * Options to create the null engine
  42667. */
  42668. export class NullEngineOptions {
  42669. /**
  42670. * Render width (Default: 512)
  42671. */
  42672. renderWidth: number;
  42673. /**
  42674. * Render height (Default: 256)
  42675. */
  42676. renderHeight: number;
  42677. /**
  42678. * Texture size (Default: 512)
  42679. */
  42680. textureSize: number;
  42681. /**
  42682. * If delta time between frames should be constant
  42683. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42684. */
  42685. deterministicLockstep: boolean;
  42686. /**
  42687. * Maximum about of steps between frames (Default: 4)
  42688. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42689. */
  42690. lockstepMaxSteps: number;
  42691. }
  42692. /**
  42693. * The null engine class provides support for headless version of babylon.js.
  42694. * This can be used in server side scenario or for testing purposes
  42695. */
  42696. export class NullEngine extends Engine {
  42697. private _options;
  42698. /**
  42699. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42700. */
  42701. isDeterministicLockStep(): boolean;
  42702. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42703. getLockstepMaxSteps(): number;
  42704. /**
  42705. * Sets hardware scaling, used to save performance if needed
  42706. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42707. */
  42708. getHardwareScalingLevel(): number;
  42709. constructor(options?: NullEngineOptions);
  42710. createVertexBuffer(vertices: FloatArray): DataBuffer;
  42711. createIndexBuffer(indices: IndicesArray): DataBuffer;
  42712. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42713. getRenderWidth(useScreen?: boolean): number;
  42714. getRenderHeight(useScreen?: boolean): number;
  42715. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42716. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42717. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42718. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42719. bindSamplers(effect: Effect): void;
  42720. enableEffect(effect: Effect): void;
  42721. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42722. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42723. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42724. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42725. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42726. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42727. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42728. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42729. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42730. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42731. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42732. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42733. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42734. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42735. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42736. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42737. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42738. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42739. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42740. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42741. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42742. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42743. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42744. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42745. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42746. bindBuffers(vertexBuffers: {
  42747. [key: string]: VertexBuffer;
  42748. }, indexBuffer: DataBuffer, effect: Effect): void;
  42749. wipeCaches(bruteForce?: boolean): void;
  42750. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42751. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42752. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42753. /** @hidden */
  42754. _createTexture(): WebGLTexture;
  42755. /** @hidden */
  42756. _releaseTexture(texture: InternalTexture): void;
  42757. 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;
  42758. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42759. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42760. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42761. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42762. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  42763. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42764. areAllEffectsReady(): boolean;
  42765. /**
  42766. * @hidden
  42767. * Get the current error code of the webGL context
  42768. * @returns the error code
  42769. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42770. */
  42771. getError(): number;
  42772. /** @hidden */
  42773. _getUnpackAlignement(): number;
  42774. /** @hidden */
  42775. _unpackFlipY(value: boolean): void;
  42776. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42777. /**
  42778. * Updates a dynamic vertex buffer.
  42779. * @param vertexBuffer the vertex buffer to update
  42780. * @param data the data used to update the vertex buffer
  42781. * @param byteOffset the byte offset of the data (optional)
  42782. * @param byteLength the byte length of the data (optional)
  42783. */
  42784. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42785. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42786. /** @hidden */
  42787. _bindTexture(channel: number, texture: InternalTexture): void;
  42788. /** @hidden */
  42789. _releaseBuffer(buffer: DataBuffer): boolean;
  42790. releaseEffects(): void;
  42791. displayLoadingUI(): void;
  42792. hideLoadingUI(): void;
  42793. /** @hidden */
  42794. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42795. /** @hidden */
  42796. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42797. /** @hidden */
  42798. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42799. /** @hidden */
  42800. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42801. }
  42802. }
  42803. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42804. import { Nullable, int } from "babylonjs/types";
  42805. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42806. /** @hidden */
  42807. export class _OcclusionDataStorage {
  42808. /** @hidden */
  42809. occlusionInternalRetryCounter: number;
  42810. /** @hidden */
  42811. isOcclusionQueryInProgress: boolean;
  42812. /** @hidden */
  42813. isOccluded: boolean;
  42814. /** @hidden */
  42815. occlusionRetryCount: number;
  42816. /** @hidden */
  42817. occlusionType: number;
  42818. /** @hidden */
  42819. occlusionQueryAlgorithmType: number;
  42820. }
  42821. module "babylonjs/Engines/engine" {
  42822. interface Engine {
  42823. /**
  42824. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42825. * @return the new query
  42826. */
  42827. createQuery(): WebGLQuery;
  42828. /**
  42829. * Delete and release a webGL query
  42830. * @param query defines the query to delete
  42831. * @return the current engine
  42832. */
  42833. deleteQuery(query: WebGLQuery): Engine;
  42834. /**
  42835. * Check if a given query has resolved and got its value
  42836. * @param query defines the query to check
  42837. * @returns true if the query got its value
  42838. */
  42839. isQueryResultAvailable(query: WebGLQuery): boolean;
  42840. /**
  42841. * Gets the value of a given query
  42842. * @param query defines the query to check
  42843. * @returns the value of the query
  42844. */
  42845. getQueryResult(query: WebGLQuery): number;
  42846. /**
  42847. * Initiates an occlusion query
  42848. * @param algorithmType defines the algorithm to use
  42849. * @param query defines the query to use
  42850. * @returns the current engine
  42851. * @see http://doc.babylonjs.com/features/occlusionquery
  42852. */
  42853. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42854. /**
  42855. * Ends an occlusion query
  42856. * @see http://doc.babylonjs.com/features/occlusionquery
  42857. * @param algorithmType defines the algorithm to use
  42858. * @returns the current engine
  42859. */
  42860. endOcclusionQuery(algorithmType: number): Engine;
  42861. /**
  42862. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42863. * Please note that only one query can be issued at a time
  42864. * @returns a time token used to track the time span
  42865. */
  42866. startTimeQuery(): Nullable<_TimeToken>;
  42867. /**
  42868. * Ends a time query
  42869. * @param token defines the token used to measure the time span
  42870. * @returns the time spent (in ns)
  42871. */
  42872. endTimeQuery(token: _TimeToken): int;
  42873. /** @hidden */
  42874. _currentNonTimestampToken: Nullable<_TimeToken>;
  42875. /** @hidden */
  42876. _createTimeQuery(): WebGLQuery;
  42877. /** @hidden */
  42878. _deleteTimeQuery(query: WebGLQuery): void;
  42879. /** @hidden */
  42880. _getGlAlgorithmType(algorithmType: number): number;
  42881. /** @hidden */
  42882. _getTimeQueryResult(query: WebGLQuery): any;
  42883. /** @hidden */
  42884. _getTimeQueryAvailability(query: WebGLQuery): any;
  42885. }
  42886. }
  42887. module "babylonjs/Meshes/abstractMesh" {
  42888. interface AbstractMesh {
  42889. /**
  42890. * Backing filed
  42891. * @hidden
  42892. */
  42893. __occlusionDataStorage: _OcclusionDataStorage;
  42894. /**
  42895. * Access property
  42896. * @hidden
  42897. */
  42898. _occlusionDataStorage: _OcclusionDataStorage;
  42899. /**
  42900. * 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.
  42901. * The default value is -1 which means don't break the query and wait till the result
  42902. * @see http://doc.babylonjs.com/features/occlusionquery
  42903. */
  42904. occlusionRetryCount: number;
  42905. /**
  42906. * 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:
  42907. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42908. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42909. * * 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.
  42910. * @see http://doc.babylonjs.com/features/occlusionquery
  42911. */
  42912. occlusionType: number;
  42913. /**
  42914. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42915. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42916. * * 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.
  42917. * @see http://doc.babylonjs.com/features/occlusionquery
  42918. */
  42919. occlusionQueryAlgorithmType: number;
  42920. /**
  42921. * 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
  42922. * @see http://doc.babylonjs.com/features/occlusionquery
  42923. */
  42924. isOccluded: boolean;
  42925. /**
  42926. * Flag to check the progress status of the query
  42927. * @see http://doc.babylonjs.com/features/occlusionquery
  42928. */
  42929. isOcclusionQueryInProgress: boolean;
  42930. }
  42931. }
  42932. }
  42933. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42934. import { Nullable } from "babylonjs/types";
  42935. /** @hidden */
  42936. export var _forceTransformFeedbackToBundle: boolean;
  42937. module "babylonjs/Engines/engine" {
  42938. interface Engine {
  42939. /**
  42940. * Creates a webGL transform feedback object
  42941. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42942. * @returns the webGL transform feedback object
  42943. */
  42944. createTransformFeedback(): WebGLTransformFeedback;
  42945. /**
  42946. * Delete a webGL transform feedback object
  42947. * @param value defines the webGL transform feedback object to delete
  42948. */
  42949. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42950. /**
  42951. * Bind a webGL transform feedback object to the webgl context
  42952. * @param value defines the webGL transform feedback object to bind
  42953. */
  42954. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42955. /**
  42956. * Begins a transform feedback operation
  42957. * @param usePoints defines if points or triangles must be used
  42958. */
  42959. beginTransformFeedback(usePoints: boolean): void;
  42960. /**
  42961. * Ends a transform feedback operation
  42962. */
  42963. endTransformFeedback(): void;
  42964. /**
  42965. * Specify the varyings to use with transform feedback
  42966. * @param program defines the associated webGL program
  42967. * @param value defines the list of strings representing the varying names
  42968. */
  42969. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42970. /**
  42971. * Bind a webGL buffer for a transform feedback operation
  42972. * @param value defines the webGL buffer to bind
  42973. */
  42974. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42975. }
  42976. }
  42977. }
  42978. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  42979. import { Scene } from "babylonjs/scene";
  42980. import { Engine } from "babylonjs/Engines/engine";
  42981. import { Texture } from "babylonjs/Materials/Textures/texture";
  42982. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42983. import "babylonjs/Engines/Extensions/engine.multiRender";
  42984. /**
  42985. * Creation options of the multi render target texture.
  42986. */
  42987. export interface IMultiRenderTargetOptions {
  42988. /**
  42989. * Define if the texture needs to create mip maps after render.
  42990. */
  42991. generateMipMaps?: boolean;
  42992. /**
  42993. * Define the types of all the draw buffers we want to create
  42994. */
  42995. types?: number[];
  42996. /**
  42997. * Define the sampling modes of all the draw buffers we want to create
  42998. */
  42999. samplingModes?: number[];
  43000. /**
  43001. * Define if a depth buffer is required
  43002. */
  43003. generateDepthBuffer?: boolean;
  43004. /**
  43005. * Define if a stencil buffer is required
  43006. */
  43007. generateStencilBuffer?: boolean;
  43008. /**
  43009. * Define if a depth texture is required instead of a depth buffer
  43010. */
  43011. generateDepthTexture?: boolean;
  43012. /**
  43013. * Define the number of desired draw buffers
  43014. */
  43015. textureCount?: number;
  43016. /**
  43017. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43018. */
  43019. doNotChangeAspectRatio?: boolean;
  43020. /**
  43021. * Define the default type of the buffers we are creating
  43022. */
  43023. defaultType?: number;
  43024. }
  43025. /**
  43026. * A multi render target, like a render target provides the ability to render to a texture.
  43027. * Unlike the render target, it can render to several draw buffers in one draw.
  43028. * This is specially interesting in deferred rendering or for any effects requiring more than
  43029. * just one color from a single pass.
  43030. */
  43031. export class MultiRenderTarget extends RenderTargetTexture {
  43032. private _internalTextures;
  43033. private _textures;
  43034. private _multiRenderTargetOptions;
  43035. /**
  43036. * Get if draw buffers are currently supported by the used hardware and browser.
  43037. */
  43038. readonly isSupported: boolean;
  43039. /**
  43040. * Get the list of textures generated by the multi render target.
  43041. */
  43042. readonly textures: Texture[];
  43043. /**
  43044. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43045. */
  43046. readonly depthTexture: Texture;
  43047. /**
  43048. * Set the wrapping mode on U of all the textures we are rendering to.
  43049. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43050. */
  43051. wrapU: number;
  43052. /**
  43053. * Set the wrapping mode on V of all the textures we are rendering to.
  43054. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43055. */
  43056. wrapV: number;
  43057. /**
  43058. * Instantiate a new multi render target texture.
  43059. * A multi render target, like a render target provides the ability to render to a texture.
  43060. * Unlike the render target, it can render to several draw buffers in one draw.
  43061. * This is specially interesting in deferred rendering or for any effects requiring more than
  43062. * just one color from a single pass.
  43063. * @param name Define the name of the texture
  43064. * @param size Define the size of the buffers to render to
  43065. * @param count Define the number of target we are rendering into
  43066. * @param scene Define the scene the texture belongs to
  43067. * @param options Define the options used to create the multi render target
  43068. */
  43069. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43070. /** @hidden */
  43071. _rebuild(): void;
  43072. private _createInternalTextures;
  43073. private _createTextures;
  43074. /**
  43075. * Define the number of samples used if MSAA is enabled.
  43076. */
  43077. samples: number;
  43078. /**
  43079. * Resize all the textures in the multi render target.
  43080. * Be carrefull as it will recreate all the data in the new texture.
  43081. * @param size Define the new size
  43082. */
  43083. resize(size: any): void;
  43084. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43085. /**
  43086. * Dispose the render targets and their associated resources
  43087. */
  43088. dispose(): void;
  43089. /**
  43090. * Release all the underlying texture used as draw buffers.
  43091. */
  43092. releaseInternalTextures(): void;
  43093. }
  43094. }
  43095. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43096. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43097. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43098. import { Nullable } from "babylonjs/types";
  43099. module "babylonjs/Engines/engine" {
  43100. interface Engine {
  43101. /**
  43102. * Unbind a list of render target textures from the webGL context
  43103. * This is used only when drawBuffer extension or webGL2 are active
  43104. * @param textures defines the render target textures to unbind
  43105. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43106. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43107. */
  43108. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43109. /**
  43110. * Create a multi render target texture
  43111. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43112. * @param size defines the size of the texture
  43113. * @param options defines the creation options
  43114. * @returns the cube texture as an InternalTexture
  43115. */
  43116. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43117. /**
  43118. * Update the sample count for a given multiple render target texture
  43119. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43120. * @param textures defines the textures to update
  43121. * @param samples defines the sample count to set
  43122. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43123. */
  43124. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43125. }
  43126. }
  43127. }
  43128. declare module "babylonjs/Engines/Extensions/index" {
  43129. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  43130. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  43131. export * from "babylonjs/Engines/Extensions/engine.multiview";
  43132. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  43133. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  43134. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  43135. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  43136. }
  43137. declare module "babylonjs/Engines/index" {
  43138. export * from "babylonjs/Engines/constants";
  43139. export * from "babylonjs/Engines/engine";
  43140. export * from "babylonjs/Engines/engineStore";
  43141. export * from "babylonjs/Engines/nullEngine";
  43142. export * from "babylonjs/Engines/Extensions/index";
  43143. export * from "babylonjs/Engines/IPipelineContext";
  43144. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43145. }
  43146. declare module "babylonjs/Events/clipboardEvents" {
  43147. /**
  43148. * Gather the list of clipboard event types as constants.
  43149. */
  43150. export class ClipboardEventTypes {
  43151. /**
  43152. * The clipboard event is fired when a copy command is active (pressed).
  43153. */
  43154. static readonly COPY: number;
  43155. /**
  43156. * The clipboard event is fired when a cut command is active (pressed).
  43157. */
  43158. static readonly CUT: number;
  43159. /**
  43160. * The clipboard event is fired when a paste command is active (pressed).
  43161. */
  43162. static readonly PASTE: number;
  43163. }
  43164. /**
  43165. * This class is used to store clipboard related info for the onClipboardObservable event.
  43166. */
  43167. export class ClipboardInfo {
  43168. /**
  43169. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43170. */
  43171. type: number;
  43172. /**
  43173. * Defines the related dom event
  43174. */
  43175. event: ClipboardEvent;
  43176. /**
  43177. *Creates an instance of ClipboardInfo.
  43178. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43179. * @param event Defines the related dom event
  43180. */
  43181. constructor(
  43182. /**
  43183. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43184. */
  43185. type: number,
  43186. /**
  43187. * Defines the related dom event
  43188. */
  43189. event: ClipboardEvent);
  43190. /**
  43191. * Get the clipboard event's type from the keycode.
  43192. * @param keyCode Defines the keyCode for the current keyboard event.
  43193. * @return {number}
  43194. */
  43195. static GetTypeFromCharacter(keyCode: number): number;
  43196. }
  43197. }
  43198. declare module "babylonjs/Events/index" {
  43199. export * from "babylonjs/Events/keyboardEvents";
  43200. export * from "babylonjs/Events/pointerEvents";
  43201. export * from "babylonjs/Events/clipboardEvents";
  43202. }
  43203. declare module "babylonjs/Loading/sceneLoader" {
  43204. import { Observable } from "babylonjs/Misc/observable";
  43205. import { Nullable } from "babylonjs/types";
  43206. import { Scene } from "babylonjs/scene";
  43207. import { Engine } from "babylonjs/Engines/engine";
  43208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43209. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43210. import { AssetContainer } from "babylonjs/assetContainer";
  43211. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43212. import { Skeleton } from "babylonjs/Bones/skeleton";
  43213. /**
  43214. * Class used to represent data loading progression
  43215. */
  43216. export class SceneLoaderProgressEvent {
  43217. /** defines if data length to load can be evaluated */
  43218. readonly lengthComputable: boolean;
  43219. /** defines the loaded data length */
  43220. readonly loaded: number;
  43221. /** defines the data length to load */
  43222. readonly total: number;
  43223. /**
  43224. * Create a new progress event
  43225. * @param lengthComputable defines if data length to load can be evaluated
  43226. * @param loaded defines the loaded data length
  43227. * @param total defines the data length to load
  43228. */
  43229. constructor(
  43230. /** defines if data length to load can be evaluated */
  43231. lengthComputable: boolean,
  43232. /** defines the loaded data length */
  43233. loaded: number,
  43234. /** defines the data length to load */
  43235. total: number);
  43236. /**
  43237. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43238. * @param event defines the source event
  43239. * @returns a new SceneLoaderProgressEvent
  43240. */
  43241. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43242. }
  43243. /**
  43244. * Interface used by SceneLoader plugins to define supported file extensions
  43245. */
  43246. export interface ISceneLoaderPluginExtensions {
  43247. /**
  43248. * Defines the list of supported extensions
  43249. */
  43250. [extension: string]: {
  43251. isBinary: boolean;
  43252. };
  43253. }
  43254. /**
  43255. * Interface used by SceneLoader plugin factory
  43256. */
  43257. export interface ISceneLoaderPluginFactory {
  43258. /**
  43259. * Defines the name of the factory
  43260. */
  43261. name: string;
  43262. /**
  43263. * Function called to create a new plugin
  43264. * @return the new plugin
  43265. */
  43266. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43267. /**
  43268. * Boolean indicating if the plugin can direct load specific data
  43269. */
  43270. canDirectLoad?: (data: string) => boolean;
  43271. }
  43272. /**
  43273. * Interface used to define a SceneLoader plugin
  43274. */
  43275. export interface ISceneLoaderPlugin {
  43276. /**
  43277. * The friendly name of this plugin.
  43278. */
  43279. name: string;
  43280. /**
  43281. * The file extensions supported by this plugin.
  43282. */
  43283. extensions: string | ISceneLoaderPluginExtensions;
  43284. /**
  43285. * Import meshes into a scene.
  43286. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43287. * @param scene The scene to import into
  43288. * @param data The data to import
  43289. * @param rootUrl The root url for scene and resources
  43290. * @param meshes The meshes array to import into
  43291. * @param particleSystems The particle systems array to import into
  43292. * @param skeletons The skeletons array to import into
  43293. * @param onError The callback when import fails
  43294. * @returns True if successful or false otherwise
  43295. */
  43296. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43297. /**
  43298. * Load into a scene.
  43299. * @param scene The scene to load into
  43300. * @param data The data to import
  43301. * @param rootUrl The root url for scene and resources
  43302. * @param onError The callback when import fails
  43303. * @returns true if successful or false otherwise
  43304. */
  43305. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43306. /**
  43307. * The callback that returns true if the data can be directly loaded.
  43308. */
  43309. canDirectLoad?: (data: string) => boolean;
  43310. /**
  43311. * The callback that allows custom handling of the root url based on the response url.
  43312. */
  43313. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43314. /**
  43315. * Load into an asset container.
  43316. * @param scene The scene to load into
  43317. * @param data The data to import
  43318. * @param rootUrl The root url for scene and resources
  43319. * @param onError The callback when import fails
  43320. * @returns The loaded asset container
  43321. */
  43322. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43323. }
  43324. /**
  43325. * Interface used to define an async SceneLoader plugin
  43326. */
  43327. export interface ISceneLoaderPluginAsync {
  43328. /**
  43329. * The friendly name of this plugin.
  43330. */
  43331. name: string;
  43332. /**
  43333. * The file extensions supported by this plugin.
  43334. */
  43335. extensions: string | ISceneLoaderPluginExtensions;
  43336. /**
  43337. * Import meshes into a scene.
  43338. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43339. * @param scene The scene to import into
  43340. * @param data The data to import
  43341. * @param rootUrl The root url for scene and resources
  43342. * @param onProgress The callback when the load progresses
  43343. * @param fileName Defines the name of the file to load
  43344. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43345. */
  43346. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43347. meshes: AbstractMesh[];
  43348. particleSystems: IParticleSystem[];
  43349. skeletons: Skeleton[];
  43350. animationGroups: AnimationGroup[];
  43351. }>;
  43352. /**
  43353. * Load into a scene.
  43354. * @param scene The scene to load into
  43355. * @param data The data to import
  43356. * @param rootUrl The root url for scene and resources
  43357. * @param onProgress The callback when the load progresses
  43358. * @param fileName Defines the name of the file to load
  43359. * @returns Nothing
  43360. */
  43361. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43362. /**
  43363. * The callback that returns true if the data can be directly loaded.
  43364. */
  43365. canDirectLoad?: (data: string) => boolean;
  43366. /**
  43367. * The callback that allows custom handling of the root url based on the response url.
  43368. */
  43369. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43370. /**
  43371. * Load into an asset container.
  43372. * @param scene The scene to load into
  43373. * @param data The data to import
  43374. * @param rootUrl The root url for scene and resources
  43375. * @param onProgress The callback when the load progresses
  43376. * @param fileName Defines the name of the file to load
  43377. * @returns The loaded asset container
  43378. */
  43379. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43380. }
  43381. /**
  43382. * Class used to load scene from various file formats using registered plugins
  43383. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43384. */
  43385. export class SceneLoader {
  43386. /**
  43387. * No logging while loading
  43388. */
  43389. static readonly NO_LOGGING: number;
  43390. /**
  43391. * Minimal logging while loading
  43392. */
  43393. static readonly MINIMAL_LOGGING: number;
  43394. /**
  43395. * Summary logging while loading
  43396. */
  43397. static readonly SUMMARY_LOGGING: number;
  43398. /**
  43399. * Detailled logging while loading
  43400. */
  43401. static readonly DETAILED_LOGGING: number;
  43402. /**
  43403. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43404. */
  43405. static ForceFullSceneLoadingForIncremental: boolean;
  43406. /**
  43407. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43408. */
  43409. static ShowLoadingScreen: boolean;
  43410. /**
  43411. * Defines the current logging level (while loading the scene)
  43412. * @ignorenaming
  43413. */
  43414. static loggingLevel: number;
  43415. /**
  43416. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43417. */
  43418. static CleanBoneMatrixWeights: boolean;
  43419. /**
  43420. * Event raised when a plugin is used to load a scene
  43421. */
  43422. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43423. private static _registeredPlugins;
  43424. private static _getDefaultPlugin;
  43425. private static _getPluginForExtension;
  43426. private static _getPluginForDirectLoad;
  43427. private static _getPluginForFilename;
  43428. private static _getDirectLoad;
  43429. private static _loadData;
  43430. private static _getFileInfo;
  43431. /**
  43432. * Gets a plugin that can load the given extension
  43433. * @param extension defines the extension to load
  43434. * @returns a plugin or null if none works
  43435. */
  43436. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43437. /**
  43438. * Gets a boolean indicating that the given extension can be loaded
  43439. * @param extension defines the extension to load
  43440. * @returns true if the extension is supported
  43441. */
  43442. static IsPluginForExtensionAvailable(extension: string): boolean;
  43443. /**
  43444. * Adds a new plugin to the list of registered plugins
  43445. * @param plugin defines the plugin to add
  43446. */
  43447. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43448. /**
  43449. * Import meshes into a scene
  43450. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43451. * @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)
  43452. * @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)
  43453. * @param scene the instance of BABYLON.Scene to append to
  43454. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43455. * @param onProgress a callback with a progress event for each file being loaded
  43456. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43457. * @param pluginExtension the extension used to determine the plugin
  43458. * @returns The loaded plugin
  43459. */
  43460. 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>;
  43461. /**
  43462. * Import meshes into a scene
  43463. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43464. * @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)
  43465. * @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)
  43466. * @param scene the instance of BABYLON.Scene to append to
  43467. * @param onProgress a callback with a progress event for each file being loaded
  43468. * @param pluginExtension the extension used to determine the plugin
  43469. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43470. */
  43471. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43472. meshes: AbstractMesh[];
  43473. particleSystems: IParticleSystem[];
  43474. skeletons: Skeleton[];
  43475. animationGroups: AnimationGroup[];
  43476. }>;
  43477. /**
  43478. * Load a scene
  43479. * @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)
  43480. * @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)
  43481. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43482. * @param onSuccess a callback with the scene when import succeeds
  43483. * @param onProgress a callback with a progress event for each file being loaded
  43484. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43485. * @param pluginExtension the extension used to determine the plugin
  43486. * @returns The loaded plugin
  43487. */
  43488. 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>;
  43489. /**
  43490. * Load a scene
  43491. * @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)
  43492. * @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)
  43493. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43494. * @param onProgress a callback with a progress event for each file being loaded
  43495. * @param pluginExtension the extension used to determine the plugin
  43496. * @returns The loaded scene
  43497. */
  43498. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43499. /**
  43500. * Append a scene
  43501. * @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)
  43502. * @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)
  43503. * @param scene is the instance of BABYLON.Scene to append to
  43504. * @param onSuccess a callback with the scene when import succeeds
  43505. * @param onProgress a callback with a progress event for each file being loaded
  43506. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43507. * @param pluginExtension the extension used to determine the plugin
  43508. * @returns The loaded plugin
  43509. */
  43510. 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>;
  43511. /**
  43512. * Append a scene
  43513. * @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)
  43514. * @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)
  43515. * @param scene is the instance of BABYLON.Scene to append to
  43516. * @param onProgress a callback with a progress event for each file being loaded
  43517. * @param pluginExtension the extension used to determine the plugin
  43518. * @returns The given scene
  43519. */
  43520. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43521. /**
  43522. * Load a scene into an asset container
  43523. * @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)
  43524. * @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)
  43525. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43526. * @param onSuccess a callback with the scene when import succeeds
  43527. * @param onProgress a callback with a progress event for each file being loaded
  43528. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43529. * @param pluginExtension the extension used to determine the plugin
  43530. * @returns The loaded plugin
  43531. */
  43532. 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>;
  43533. /**
  43534. * Load a scene into an asset container
  43535. * @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)
  43536. * @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)
  43537. * @param scene is the instance of Scene to append to
  43538. * @param onProgress a callback with a progress event for each file being loaded
  43539. * @param pluginExtension the extension used to determine the plugin
  43540. * @returns The loaded asset container
  43541. */
  43542. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43543. }
  43544. }
  43545. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43546. import { Scene } from "babylonjs/scene";
  43547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43548. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43549. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43550. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43551. /**
  43552. * Google Daydream controller
  43553. */
  43554. export class DaydreamController extends WebVRController {
  43555. /**
  43556. * Base Url for the controller model.
  43557. */
  43558. static MODEL_BASE_URL: string;
  43559. /**
  43560. * File name for the controller model.
  43561. */
  43562. static MODEL_FILENAME: string;
  43563. /**
  43564. * Gamepad Id prefix used to identify Daydream Controller.
  43565. */
  43566. static readonly GAMEPAD_ID_PREFIX: string;
  43567. /**
  43568. * Creates a new DaydreamController from a gamepad
  43569. * @param vrGamepad the gamepad that the controller should be created from
  43570. */
  43571. constructor(vrGamepad: any);
  43572. /**
  43573. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43574. * @param scene scene in which to add meshes
  43575. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43576. */
  43577. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43578. /**
  43579. * Called once for each button that changed state since the last frame
  43580. * @param buttonIdx Which button index changed
  43581. * @param state New state of the button
  43582. * @param changes Which properties on the state changed since last frame
  43583. */
  43584. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43585. }
  43586. }
  43587. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43588. import { Scene } from "babylonjs/scene";
  43589. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43590. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43591. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43592. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43593. /**
  43594. * Gear VR Controller
  43595. */
  43596. export class GearVRController extends WebVRController {
  43597. /**
  43598. * Base Url for the controller model.
  43599. */
  43600. static MODEL_BASE_URL: string;
  43601. /**
  43602. * File name for the controller model.
  43603. */
  43604. static MODEL_FILENAME: string;
  43605. /**
  43606. * Gamepad Id prefix used to identify this controller.
  43607. */
  43608. static readonly GAMEPAD_ID_PREFIX: string;
  43609. private readonly _buttonIndexToObservableNameMap;
  43610. /**
  43611. * Creates a new GearVRController from a gamepad
  43612. * @param vrGamepad the gamepad that the controller should be created from
  43613. */
  43614. constructor(vrGamepad: any);
  43615. /**
  43616. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43617. * @param scene scene in which to add meshes
  43618. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43619. */
  43620. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43621. /**
  43622. * Called once for each button that changed state since the last frame
  43623. * @param buttonIdx Which button index changed
  43624. * @param state New state of the button
  43625. * @param changes Which properties on the state changed since last frame
  43626. */
  43627. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43628. }
  43629. }
  43630. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43631. import { Scene } from "babylonjs/scene";
  43632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43633. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43634. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43635. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43636. /**
  43637. * Generic Controller
  43638. */
  43639. export class GenericController extends WebVRController {
  43640. /**
  43641. * Base Url for the controller model.
  43642. */
  43643. static readonly MODEL_BASE_URL: string;
  43644. /**
  43645. * File name for the controller model.
  43646. */
  43647. static readonly MODEL_FILENAME: string;
  43648. /**
  43649. * Creates a new GenericController from a gamepad
  43650. * @param vrGamepad the gamepad that the controller should be created from
  43651. */
  43652. constructor(vrGamepad: any);
  43653. /**
  43654. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43655. * @param scene scene in which to add meshes
  43656. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43657. */
  43658. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43659. /**
  43660. * Called once for each button that changed state since the last frame
  43661. * @param buttonIdx Which button index changed
  43662. * @param state New state of the button
  43663. * @param changes Which properties on the state changed since last frame
  43664. */
  43665. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43666. }
  43667. }
  43668. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43669. import { Observable } from "babylonjs/Misc/observable";
  43670. import { Scene } from "babylonjs/scene";
  43671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43672. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43673. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43674. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43675. /**
  43676. * Oculus Touch Controller
  43677. */
  43678. export class OculusTouchController extends WebVRController {
  43679. /**
  43680. * Base Url for the controller model.
  43681. */
  43682. static MODEL_BASE_URL: string;
  43683. /**
  43684. * File name for the left controller model.
  43685. */
  43686. static MODEL_LEFT_FILENAME: string;
  43687. /**
  43688. * File name for the right controller model.
  43689. */
  43690. static MODEL_RIGHT_FILENAME: string;
  43691. /**
  43692. * Fired when the secondary trigger on this controller is modified
  43693. */
  43694. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43695. /**
  43696. * Fired when the thumb rest on this controller is modified
  43697. */
  43698. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43699. /**
  43700. * Creates a new OculusTouchController from a gamepad
  43701. * @param vrGamepad the gamepad that the controller should be created from
  43702. */
  43703. constructor(vrGamepad: any);
  43704. /**
  43705. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43706. * @param scene scene in which to add meshes
  43707. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43708. */
  43709. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43710. /**
  43711. * Fired when the A button on this controller is modified
  43712. */
  43713. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43714. /**
  43715. * Fired when the B button on this controller is modified
  43716. */
  43717. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43718. /**
  43719. * Fired when the X button on this controller is modified
  43720. */
  43721. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43722. /**
  43723. * Fired when the Y button on this controller is modified
  43724. */
  43725. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43726. /**
  43727. * Called once for each button that changed state since the last frame
  43728. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43729. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43730. * 2) secondary trigger (same)
  43731. * 3) A (right) X (left), touch, pressed = value
  43732. * 4) B / Y
  43733. * 5) thumb rest
  43734. * @param buttonIdx Which button index changed
  43735. * @param state New state of the button
  43736. * @param changes Which properties on the state changed since last frame
  43737. */
  43738. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43739. }
  43740. }
  43741. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43742. import { Scene } from "babylonjs/scene";
  43743. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43744. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43745. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43746. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43747. import { Observable } from "babylonjs/Misc/observable";
  43748. /**
  43749. * Vive Controller
  43750. */
  43751. export class ViveController extends WebVRController {
  43752. /**
  43753. * Base Url for the controller model.
  43754. */
  43755. static MODEL_BASE_URL: string;
  43756. /**
  43757. * File name for the controller model.
  43758. */
  43759. static MODEL_FILENAME: string;
  43760. /**
  43761. * Creates a new ViveController from a gamepad
  43762. * @param vrGamepad the gamepad that the controller should be created from
  43763. */
  43764. constructor(vrGamepad: any);
  43765. /**
  43766. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43767. * @param scene scene in which to add meshes
  43768. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43769. */
  43770. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43771. /**
  43772. * Fired when the left button on this controller is modified
  43773. */
  43774. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43775. /**
  43776. * Fired when the right button on this controller is modified
  43777. */
  43778. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43779. /**
  43780. * Fired when the menu button on this controller is modified
  43781. */
  43782. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43783. /**
  43784. * Called once for each button that changed state since the last frame
  43785. * Vive mapping:
  43786. * 0: touchpad
  43787. * 1: trigger
  43788. * 2: left AND right buttons
  43789. * 3: menu button
  43790. * @param buttonIdx Which button index changed
  43791. * @param state New state of the button
  43792. * @param changes Which properties on the state changed since last frame
  43793. */
  43794. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43795. }
  43796. }
  43797. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43798. import { Observable } from "babylonjs/Misc/observable";
  43799. import { Scene } from "babylonjs/scene";
  43800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43801. import { Ray } from "babylonjs/Culling/ray";
  43802. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43803. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43804. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43805. /**
  43806. * Defines the WindowsMotionController object that the state of the windows motion controller
  43807. */
  43808. export class WindowsMotionController extends WebVRController {
  43809. /**
  43810. * The base url used to load the left and right controller models
  43811. */
  43812. static MODEL_BASE_URL: string;
  43813. /**
  43814. * The name of the left controller model file
  43815. */
  43816. static MODEL_LEFT_FILENAME: string;
  43817. /**
  43818. * The name of the right controller model file
  43819. */
  43820. static MODEL_RIGHT_FILENAME: string;
  43821. /**
  43822. * The controller name prefix for this controller type
  43823. */
  43824. static readonly GAMEPAD_ID_PREFIX: string;
  43825. /**
  43826. * The controller id pattern for this controller type
  43827. */
  43828. private static readonly GAMEPAD_ID_PATTERN;
  43829. private _loadedMeshInfo;
  43830. private readonly _mapping;
  43831. /**
  43832. * Fired when the trackpad on this controller is clicked
  43833. */
  43834. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43835. /**
  43836. * Fired when the trackpad on this controller is modified
  43837. */
  43838. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43839. /**
  43840. * The current x and y values of this controller's trackpad
  43841. */
  43842. trackpad: StickValues;
  43843. /**
  43844. * Creates a new WindowsMotionController from a gamepad
  43845. * @param vrGamepad the gamepad that the controller should be created from
  43846. */
  43847. constructor(vrGamepad: any);
  43848. /**
  43849. * Fired when the trigger on this controller is modified
  43850. */
  43851. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43852. /**
  43853. * Fired when the menu button on this controller is modified
  43854. */
  43855. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43856. /**
  43857. * Fired when the grip button on this controller is modified
  43858. */
  43859. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43860. /**
  43861. * Fired when the thumbstick button on this controller is modified
  43862. */
  43863. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43864. /**
  43865. * Fired when the touchpad button on this controller is modified
  43866. */
  43867. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43868. /**
  43869. * Fired when the touchpad values on this controller are modified
  43870. */
  43871. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43872. private _updateTrackpad;
  43873. /**
  43874. * Called once per frame by the engine.
  43875. */
  43876. update(): void;
  43877. /**
  43878. * Called once for each button that changed state since the last frame
  43879. * @param buttonIdx Which button index changed
  43880. * @param state New state of the button
  43881. * @param changes Which properties on the state changed since last frame
  43882. */
  43883. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43884. /**
  43885. * Moves the buttons on the controller mesh based on their current state
  43886. * @param buttonName the name of the button to move
  43887. * @param buttonValue the value of the button which determines the buttons new position
  43888. */
  43889. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43890. /**
  43891. * Moves the axis on the controller mesh based on its current state
  43892. * @param axis the index of the axis
  43893. * @param axisValue the value of the axis which determines the meshes new position
  43894. * @hidden
  43895. */
  43896. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43897. /**
  43898. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43899. * @param scene scene in which to add meshes
  43900. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43901. */
  43902. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43903. /**
  43904. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43905. * can be transformed by button presses and axes values, based on this._mapping.
  43906. *
  43907. * @param scene scene in which the meshes exist
  43908. * @param meshes list of meshes that make up the controller model to process
  43909. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43910. */
  43911. private processModel;
  43912. private createMeshInfo;
  43913. /**
  43914. * Gets the ray of the controller in the direction the controller is pointing
  43915. * @param length the length the resulting ray should be
  43916. * @returns a ray in the direction the controller is pointing
  43917. */
  43918. getForwardRay(length?: number): Ray;
  43919. /**
  43920. * Disposes of the controller
  43921. */
  43922. dispose(): void;
  43923. }
  43924. }
  43925. declare module "babylonjs/Gamepads/Controllers/index" {
  43926. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  43927. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  43928. export * from "babylonjs/Gamepads/Controllers/genericController";
  43929. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  43930. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43931. export * from "babylonjs/Gamepads/Controllers/viveController";
  43932. export * from "babylonjs/Gamepads/Controllers/webVRController";
  43933. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  43934. }
  43935. declare module "babylonjs/Gamepads/index" {
  43936. export * from "babylonjs/Gamepads/Controllers/index";
  43937. export * from "babylonjs/Gamepads/gamepad";
  43938. export * from "babylonjs/Gamepads/gamepadManager";
  43939. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  43940. export * from "babylonjs/Gamepads/xboxGamepad";
  43941. }
  43942. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  43943. import { Observable } from "babylonjs/Misc/observable";
  43944. import { Nullable } from "babylonjs/types";
  43945. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43947. import { Mesh } from "babylonjs/Meshes/mesh";
  43948. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43949. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43950. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43951. /**
  43952. * Single axis scale gizmo
  43953. */
  43954. export class AxisScaleGizmo extends Gizmo {
  43955. private _coloredMaterial;
  43956. /**
  43957. * Drag behavior responsible for the gizmos dragging interactions
  43958. */
  43959. dragBehavior: PointerDragBehavior;
  43960. private _pointerObserver;
  43961. /**
  43962. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43963. */
  43964. snapDistance: number;
  43965. /**
  43966. * Event that fires each time the gizmo snaps to a new location.
  43967. * * snapDistance is the the change in distance
  43968. */
  43969. onSnapObservable: Observable<{
  43970. snapDistance: number;
  43971. }>;
  43972. /**
  43973. * If the scaling operation should be done on all axis (default: false)
  43974. */
  43975. uniformScaling: boolean;
  43976. /**
  43977. * Creates an AxisScaleGizmo
  43978. * @param gizmoLayer The utility layer the gizmo will be added to
  43979. * @param dragAxis The axis which the gizmo will be able to scale on
  43980. * @param color The color of the gizmo
  43981. */
  43982. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43983. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43984. /**
  43985. * Disposes of the gizmo
  43986. */
  43987. dispose(): void;
  43988. /**
  43989. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43990. * @param mesh The mesh to replace the default mesh of the gizmo
  43991. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43992. */
  43993. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43994. }
  43995. }
  43996. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43997. import { Observable } from "babylonjs/Misc/observable";
  43998. import { Nullable } from "babylonjs/types";
  43999. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44001. import { Mesh } from "babylonjs/Meshes/mesh";
  44002. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44003. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44004. import "babylonjs/Meshes/Builders/boxBuilder";
  44005. /**
  44006. * Bounding box gizmo
  44007. */
  44008. export class BoundingBoxGizmo extends Gizmo {
  44009. private _lineBoundingBox;
  44010. private _rotateSpheresParent;
  44011. private _scaleBoxesParent;
  44012. private _boundingDimensions;
  44013. private _renderObserver;
  44014. private _pointerObserver;
  44015. private _scaleDragSpeed;
  44016. private _tmpQuaternion;
  44017. private _tmpVector;
  44018. private _tmpRotationMatrix;
  44019. /**
  44020. * 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)
  44021. */
  44022. ignoreChildren: boolean;
  44023. /**
  44024. * 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)
  44025. */
  44026. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44027. /**
  44028. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44029. */
  44030. rotationSphereSize: number;
  44031. /**
  44032. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44033. */
  44034. scaleBoxSize: number;
  44035. /**
  44036. * 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)
  44037. */
  44038. fixedDragMeshScreenSize: boolean;
  44039. /**
  44040. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44041. */
  44042. fixedDragMeshScreenSizeDistanceFactor: number;
  44043. /**
  44044. * Fired when a rotation sphere or scale box is dragged
  44045. */
  44046. onDragStartObservable: Observable<{}>;
  44047. /**
  44048. * Fired when a scale box is dragged
  44049. */
  44050. onScaleBoxDragObservable: Observable<{}>;
  44051. /**
  44052. * Fired when a scale box drag is ended
  44053. */
  44054. onScaleBoxDragEndObservable: Observable<{}>;
  44055. /**
  44056. * Fired when a rotation sphere is dragged
  44057. */
  44058. onRotationSphereDragObservable: Observable<{}>;
  44059. /**
  44060. * Fired when a rotation sphere drag is ended
  44061. */
  44062. onRotationSphereDragEndObservable: Observable<{}>;
  44063. /**
  44064. * 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)
  44065. */
  44066. scalePivot: Nullable<Vector3>;
  44067. /**
  44068. * Mesh used as a pivot to rotate the attached mesh
  44069. */
  44070. private _anchorMesh;
  44071. private _existingMeshScale;
  44072. private _dragMesh;
  44073. private pointerDragBehavior;
  44074. private coloredMaterial;
  44075. private hoverColoredMaterial;
  44076. /**
  44077. * Sets the color of the bounding box gizmo
  44078. * @param color the color to set
  44079. */
  44080. setColor(color: Color3): void;
  44081. /**
  44082. * Creates an BoundingBoxGizmo
  44083. * @param gizmoLayer The utility layer the gizmo will be added to
  44084. * @param color The color of the gizmo
  44085. */
  44086. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44087. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44088. private _selectNode;
  44089. /**
  44090. * Updates the bounding box information for the Gizmo
  44091. */
  44092. updateBoundingBox(): void;
  44093. private _updateRotationSpheres;
  44094. private _updateScaleBoxes;
  44095. /**
  44096. * Enables rotation on the specified axis and disables rotation on the others
  44097. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44098. */
  44099. setEnabledRotationAxis(axis: string): void;
  44100. /**
  44101. * Enables/disables scaling
  44102. * @param enable if scaling should be enabled
  44103. */
  44104. setEnabledScaling(enable: boolean): void;
  44105. private _updateDummy;
  44106. /**
  44107. * Enables a pointer drag behavior on the bounding box of the gizmo
  44108. */
  44109. enableDragBehavior(): void;
  44110. /**
  44111. * Disposes of the gizmo
  44112. */
  44113. dispose(): void;
  44114. /**
  44115. * 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)
  44116. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44117. * @returns the bounding box mesh with the passed in mesh as a child
  44118. */
  44119. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44120. /**
  44121. * CustomMeshes are not supported by this gizmo
  44122. * @param mesh The mesh to replace the default mesh of the gizmo
  44123. */
  44124. setCustomMesh(mesh: Mesh): void;
  44125. }
  44126. }
  44127. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  44128. import { Observable } from "babylonjs/Misc/observable";
  44129. import { Nullable } from "babylonjs/types";
  44130. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44132. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44133. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44134. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44135. import "babylonjs/Meshes/Builders/linesBuilder";
  44136. /**
  44137. * Single plane rotation gizmo
  44138. */
  44139. export class PlaneRotationGizmo extends Gizmo {
  44140. /**
  44141. * Drag behavior responsible for the gizmos dragging interactions
  44142. */
  44143. dragBehavior: PointerDragBehavior;
  44144. private _pointerObserver;
  44145. /**
  44146. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44147. */
  44148. snapDistance: number;
  44149. /**
  44150. * Event that fires each time the gizmo snaps to a new location.
  44151. * * snapDistance is the the change in distance
  44152. */
  44153. onSnapObservable: Observable<{
  44154. snapDistance: number;
  44155. }>;
  44156. /**
  44157. * Creates a PlaneRotationGizmo
  44158. * @param gizmoLayer The utility layer the gizmo will be added to
  44159. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44160. * @param color The color of the gizmo
  44161. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44162. */
  44163. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44164. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44165. /**
  44166. * Disposes of the gizmo
  44167. */
  44168. dispose(): void;
  44169. }
  44170. }
  44171. declare module "babylonjs/Gizmos/rotationGizmo" {
  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 { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  44178. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44179. /**
  44180. * Gizmo that enables rotating a mesh along 3 axis
  44181. */
  44182. export class RotationGizmo extends Gizmo {
  44183. /**
  44184. * Internal gizmo used for interactions on the x axis
  44185. */
  44186. xGizmo: PlaneRotationGizmo;
  44187. /**
  44188. * Internal gizmo used for interactions on the y axis
  44189. */
  44190. yGizmo: PlaneRotationGizmo;
  44191. /**
  44192. * Internal gizmo used for interactions on the z axis
  44193. */
  44194. zGizmo: PlaneRotationGizmo;
  44195. /** Fires an event when any of it's sub gizmos are dragged */
  44196. onDragStartObservable: Observable<{}>;
  44197. /** Fires an event when any of it's sub gizmos are released from dragging */
  44198. onDragEndObservable: Observable<{}>;
  44199. attachedMesh: Nullable<AbstractMesh>;
  44200. /**
  44201. * Creates a RotationGizmo
  44202. * @param gizmoLayer The utility layer the gizmo will be added to
  44203. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44204. */
  44205. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44206. updateGizmoRotationToMatchAttachedMesh: boolean;
  44207. /**
  44208. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44209. */
  44210. snapDistance: number;
  44211. /**
  44212. * Ratio for the scale of the gizmo (Default: 1)
  44213. */
  44214. scaleRatio: number;
  44215. /**
  44216. * Disposes of the gizmo
  44217. */
  44218. dispose(): void;
  44219. /**
  44220. * CustomMeshes are not supported by this gizmo
  44221. * @param mesh The mesh to replace the default mesh of the gizmo
  44222. */
  44223. setCustomMesh(mesh: Mesh): void;
  44224. }
  44225. }
  44226. declare module "babylonjs/Gizmos/positionGizmo" {
  44227. import { Observable } from "babylonjs/Misc/observable";
  44228. import { Nullable } from "babylonjs/types";
  44229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44230. import { Mesh } from "babylonjs/Meshes/mesh";
  44231. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44232. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44233. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44234. /**
  44235. * Gizmo that enables dragging a mesh along 3 axis
  44236. */
  44237. export class PositionGizmo extends Gizmo {
  44238. /**
  44239. * Internal gizmo used for interactions on the x axis
  44240. */
  44241. xGizmo: AxisDragGizmo;
  44242. /**
  44243. * Internal gizmo used for interactions on the y axis
  44244. */
  44245. yGizmo: AxisDragGizmo;
  44246. /**
  44247. * Internal gizmo used for interactions on the z axis
  44248. */
  44249. zGizmo: AxisDragGizmo;
  44250. /** Fires an event when any of it's sub gizmos are dragged */
  44251. onDragStartObservable: Observable<{}>;
  44252. /** Fires an event when any of it's sub gizmos are released from dragging */
  44253. onDragEndObservable: Observable<{}>;
  44254. attachedMesh: Nullable<AbstractMesh>;
  44255. /**
  44256. * Creates a PositionGizmo
  44257. * @param gizmoLayer The utility layer the gizmo will be added to
  44258. */
  44259. constructor(gizmoLayer?: UtilityLayerRenderer);
  44260. updateGizmoRotationToMatchAttachedMesh: boolean;
  44261. /**
  44262. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44263. */
  44264. snapDistance: number;
  44265. /**
  44266. * Ratio for the scale of the gizmo (Default: 1)
  44267. */
  44268. scaleRatio: number;
  44269. /**
  44270. * Disposes of the gizmo
  44271. */
  44272. dispose(): void;
  44273. /**
  44274. * CustomMeshes are not supported by this gizmo
  44275. * @param mesh The mesh to replace the default mesh of the gizmo
  44276. */
  44277. setCustomMesh(mesh: Mesh): void;
  44278. }
  44279. }
  44280. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44281. import { Scene } from "babylonjs/scene";
  44282. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44283. import { Mesh } from "babylonjs/Meshes/mesh";
  44284. import { Nullable } from "babylonjs/types";
  44285. /**
  44286. * Class containing static functions to help procedurally build meshes
  44287. */
  44288. export class PolyhedronBuilder {
  44289. /**
  44290. * Creates a polyhedron mesh
  44291. * * 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
  44292. * * The parameter `size` (positive float, default 1) sets the polygon size
  44293. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44294. * * 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`
  44295. * * 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
  44296. * * 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)`)
  44297. * * 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
  44298. * * 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
  44299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44300. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44302. * @param name defines the name of the mesh
  44303. * @param options defines the options used to create the mesh
  44304. * @param scene defines the hosting scene
  44305. * @returns the polyhedron mesh
  44306. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44307. */
  44308. static CreatePolyhedron(name: string, options: {
  44309. type?: number;
  44310. size?: number;
  44311. sizeX?: number;
  44312. sizeY?: number;
  44313. sizeZ?: number;
  44314. custom?: any;
  44315. faceUV?: Vector4[];
  44316. faceColors?: Color4[];
  44317. flat?: boolean;
  44318. updatable?: boolean;
  44319. sideOrientation?: number;
  44320. frontUVs?: Vector4;
  44321. backUVs?: Vector4;
  44322. }, scene?: Nullable<Scene>): Mesh;
  44323. }
  44324. }
  44325. declare module "babylonjs/Gizmos/scaleGizmo" {
  44326. import { Observable } from "babylonjs/Misc/observable";
  44327. import { Nullable } from "babylonjs/types";
  44328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44329. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44330. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44331. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44332. /**
  44333. * Gizmo that enables scaling a mesh along 3 axis
  44334. */
  44335. export class ScaleGizmo extends Gizmo {
  44336. /**
  44337. * Internal gizmo used for interactions on the x axis
  44338. */
  44339. xGizmo: AxisScaleGizmo;
  44340. /**
  44341. * Internal gizmo used for interactions on the y axis
  44342. */
  44343. yGizmo: AxisScaleGizmo;
  44344. /**
  44345. * Internal gizmo used for interactions on the z axis
  44346. */
  44347. zGizmo: AxisScaleGizmo;
  44348. /**
  44349. * Internal gizmo used to scale all axis equally
  44350. */
  44351. uniformScaleGizmo: AxisScaleGizmo;
  44352. /** Fires an event when any of it's sub gizmos are dragged */
  44353. onDragStartObservable: Observable<{}>;
  44354. /** Fires an event when any of it's sub gizmos are released from dragging */
  44355. onDragEndObservable: Observable<{}>;
  44356. attachedMesh: Nullable<AbstractMesh>;
  44357. /**
  44358. * Creates a ScaleGizmo
  44359. * @param gizmoLayer The utility layer the gizmo will be added to
  44360. */
  44361. constructor(gizmoLayer?: UtilityLayerRenderer);
  44362. updateGizmoRotationToMatchAttachedMesh: boolean;
  44363. /**
  44364. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44365. */
  44366. snapDistance: number;
  44367. /**
  44368. * Ratio for the scale of the gizmo (Default: 1)
  44369. */
  44370. scaleRatio: number;
  44371. /**
  44372. * Disposes of the gizmo
  44373. */
  44374. dispose(): void;
  44375. }
  44376. }
  44377. declare module "babylonjs/Gizmos/gizmoManager" {
  44378. import { Observable } from "babylonjs/Misc/observable";
  44379. import { Nullable } from "babylonjs/types";
  44380. import { Scene, IDisposable } from "babylonjs/scene";
  44381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44382. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44383. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44384. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44385. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44386. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44387. /**
  44388. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44389. */
  44390. export class GizmoManager implements IDisposable {
  44391. private scene;
  44392. /**
  44393. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44394. */
  44395. gizmos: {
  44396. positionGizmo: Nullable<PositionGizmo>;
  44397. rotationGizmo: Nullable<RotationGizmo>;
  44398. scaleGizmo: Nullable<ScaleGizmo>;
  44399. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44400. };
  44401. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44402. clearGizmoOnEmptyPointerEvent: boolean;
  44403. /** Fires an event when the manager is attached to a mesh */
  44404. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44405. private _gizmosEnabled;
  44406. private _pointerObserver;
  44407. private _attachedMesh;
  44408. private _boundingBoxColor;
  44409. private _defaultUtilityLayer;
  44410. private _defaultKeepDepthUtilityLayer;
  44411. /**
  44412. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44413. */
  44414. boundingBoxDragBehavior: SixDofDragBehavior;
  44415. /**
  44416. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44417. */
  44418. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44419. /**
  44420. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44421. */
  44422. usePointerToAttachGizmos: boolean;
  44423. /**
  44424. * Instatiates a gizmo manager
  44425. * @param scene the scene to overlay the gizmos on top of
  44426. */
  44427. constructor(scene: Scene);
  44428. /**
  44429. * Attaches a set of gizmos to the specified mesh
  44430. * @param mesh The mesh the gizmo's should be attached to
  44431. */
  44432. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44433. /**
  44434. * If the position gizmo is enabled
  44435. */
  44436. positionGizmoEnabled: boolean;
  44437. /**
  44438. * If the rotation gizmo is enabled
  44439. */
  44440. rotationGizmoEnabled: boolean;
  44441. /**
  44442. * If the scale gizmo is enabled
  44443. */
  44444. scaleGizmoEnabled: boolean;
  44445. /**
  44446. * If the boundingBox gizmo is enabled
  44447. */
  44448. boundingBoxGizmoEnabled: boolean;
  44449. /**
  44450. * Disposes of the gizmo manager
  44451. */
  44452. dispose(): void;
  44453. }
  44454. }
  44455. declare module "babylonjs/Lights/directionalLight" {
  44456. import { Camera } from "babylonjs/Cameras/camera";
  44457. import { Scene } from "babylonjs/scene";
  44458. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44460. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44461. import { Effect } from "babylonjs/Materials/effect";
  44462. /**
  44463. * A directional light is defined by a direction (what a surprise!).
  44464. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44465. * 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.
  44466. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44467. */
  44468. export class DirectionalLight extends ShadowLight {
  44469. private _shadowFrustumSize;
  44470. /**
  44471. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44472. */
  44473. /**
  44474. * Specifies a fix frustum size for the shadow generation.
  44475. */
  44476. shadowFrustumSize: number;
  44477. private _shadowOrthoScale;
  44478. /**
  44479. * Gets the shadow projection scale against the optimal computed one.
  44480. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44481. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44482. */
  44483. /**
  44484. * Sets the shadow projection scale against the optimal computed one.
  44485. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44486. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44487. */
  44488. shadowOrthoScale: number;
  44489. /**
  44490. * Automatically compute the projection matrix to best fit (including all the casters)
  44491. * on each frame.
  44492. */
  44493. autoUpdateExtends: boolean;
  44494. private _orthoLeft;
  44495. private _orthoRight;
  44496. private _orthoTop;
  44497. private _orthoBottom;
  44498. /**
  44499. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44500. * The directional light is emitted from everywhere in the given direction.
  44501. * It can cast shadows.
  44502. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44503. * @param name The friendly name of the light
  44504. * @param direction The direction of the light
  44505. * @param scene The scene the light belongs to
  44506. */
  44507. constructor(name: string, direction: Vector3, scene: Scene);
  44508. /**
  44509. * Returns the string "DirectionalLight".
  44510. * @return The class name
  44511. */
  44512. getClassName(): string;
  44513. /**
  44514. * Returns the integer 1.
  44515. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44516. */
  44517. getTypeID(): number;
  44518. /**
  44519. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44520. * Returns the DirectionalLight Shadow projection matrix.
  44521. */
  44522. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44523. /**
  44524. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44525. * Returns the DirectionalLight Shadow projection matrix.
  44526. */
  44527. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44528. /**
  44529. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44530. * Returns the DirectionalLight Shadow projection matrix.
  44531. */
  44532. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44533. protected _buildUniformLayout(): void;
  44534. /**
  44535. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44536. * @param effect The effect to update
  44537. * @param lightIndex The index of the light in the effect to update
  44538. * @returns The directional light
  44539. */
  44540. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44541. /**
  44542. * Gets the minZ used for shadow according to both the scene and the light.
  44543. *
  44544. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44545. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44546. * @param activeCamera The camera we are returning the min for
  44547. * @returns the depth min z
  44548. */
  44549. getDepthMinZ(activeCamera: Camera): number;
  44550. /**
  44551. * Gets the maxZ used for shadow according to both the scene and the light.
  44552. *
  44553. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44554. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44555. * @param activeCamera The camera we are returning the max for
  44556. * @returns the depth max z
  44557. */
  44558. getDepthMaxZ(activeCamera: Camera): number;
  44559. /**
  44560. * Prepares the list of defines specific to the light type.
  44561. * @param defines the list of defines
  44562. * @param lightIndex defines the index of the light for the effect
  44563. */
  44564. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44565. }
  44566. }
  44567. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  44568. import { Mesh } from "babylonjs/Meshes/mesh";
  44569. /**
  44570. * Class containing static functions to help procedurally build meshes
  44571. */
  44572. export class HemisphereBuilder {
  44573. /**
  44574. * Creates a hemisphere mesh
  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 hemisphere mesh
  44579. */
  44580. static CreateHemisphere(name: string, options: {
  44581. segments?: number;
  44582. diameter?: number;
  44583. sideOrientation?: number;
  44584. }, scene: any): Mesh;
  44585. }
  44586. }
  44587. declare module "babylonjs/Lights/spotLight" {
  44588. import { Nullable } from "babylonjs/types";
  44589. import { Scene } from "babylonjs/scene";
  44590. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44592. import { Effect } from "babylonjs/Materials/effect";
  44593. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44594. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44595. /**
  44596. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44597. * These values define a cone of light starting from the position, emitting toward the direction.
  44598. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44599. * and the exponent defines the speed of the decay of the light with distance (reach).
  44600. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44601. */
  44602. export class SpotLight extends ShadowLight {
  44603. private _angle;
  44604. private _innerAngle;
  44605. private _cosHalfAngle;
  44606. private _lightAngleScale;
  44607. private _lightAngleOffset;
  44608. /**
  44609. * Gets the cone angle of the spot light in Radians.
  44610. */
  44611. /**
  44612. * Sets the cone angle of the spot light in Radians.
  44613. */
  44614. angle: number;
  44615. /**
  44616. * Only used in gltf falloff mode, this defines the angle where
  44617. * the directional falloff will start before cutting at angle which could be seen
  44618. * as outer angle.
  44619. */
  44620. /**
  44621. * Only used in gltf falloff mode, this defines the angle where
  44622. * the directional falloff will start before cutting at angle which could be seen
  44623. * as outer angle.
  44624. */
  44625. innerAngle: number;
  44626. private _shadowAngleScale;
  44627. /**
  44628. * Allows scaling the angle of the light for shadow generation only.
  44629. */
  44630. /**
  44631. * Allows scaling the angle of the light for shadow generation only.
  44632. */
  44633. shadowAngleScale: number;
  44634. /**
  44635. * The light decay speed with the distance from the emission spot.
  44636. */
  44637. exponent: number;
  44638. private _projectionTextureMatrix;
  44639. /**
  44640. * Allows reading the projecton texture
  44641. */
  44642. readonly projectionTextureMatrix: Matrix;
  44643. protected _projectionTextureLightNear: number;
  44644. /**
  44645. * Gets the near clip of the Spotlight for texture projection.
  44646. */
  44647. /**
  44648. * Sets the near clip of the Spotlight for texture projection.
  44649. */
  44650. projectionTextureLightNear: number;
  44651. protected _projectionTextureLightFar: number;
  44652. /**
  44653. * Gets the far clip of the Spotlight for texture projection.
  44654. */
  44655. /**
  44656. * Sets the far clip of the Spotlight for texture projection.
  44657. */
  44658. projectionTextureLightFar: number;
  44659. protected _projectionTextureUpDirection: Vector3;
  44660. /**
  44661. * Gets the Up vector of the Spotlight for texture projection.
  44662. */
  44663. /**
  44664. * Sets the Up vector of the Spotlight for texture projection.
  44665. */
  44666. projectionTextureUpDirection: Vector3;
  44667. private _projectionTexture;
  44668. /**
  44669. * Gets the projection texture of the light.
  44670. */
  44671. /**
  44672. * Sets the projection texture of the light.
  44673. */
  44674. projectionTexture: Nullable<BaseTexture>;
  44675. private _projectionTextureViewLightDirty;
  44676. private _projectionTextureProjectionLightDirty;
  44677. private _projectionTextureDirty;
  44678. private _projectionTextureViewTargetVector;
  44679. private _projectionTextureViewLightMatrix;
  44680. private _projectionTextureProjectionLightMatrix;
  44681. private _projectionTextureScalingMatrix;
  44682. /**
  44683. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44684. * It can cast shadows.
  44685. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44686. * @param name The light friendly name
  44687. * @param position The position of the spot light in the scene
  44688. * @param direction The direction of the light in the scene
  44689. * @param angle The cone angle of the light in Radians
  44690. * @param exponent The light decay speed with the distance from the emission spot
  44691. * @param scene The scene the lights belongs to
  44692. */
  44693. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44694. /**
  44695. * Returns the string "SpotLight".
  44696. * @returns the class name
  44697. */
  44698. getClassName(): string;
  44699. /**
  44700. * Returns the integer 2.
  44701. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44702. */
  44703. getTypeID(): number;
  44704. /**
  44705. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44706. */
  44707. protected _setDirection(value: Vector3): void;
  44708. /**
  44709. * Overrides the position setter to recompute the projection texture view light Matrix.
  44710. */
  44711. protected _setPosition(value: Vector3): void;
  44712. /**
  44713. * 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.
  44714. * Returns the SpotLight.
  44715. */
  44716. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44717. protected _computeProjectionTextureViewLightMatrix(): void;
  44718. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44719. /**
  44720. * Main function for light texture projection matrix computing.
  44721. */
  44722. protected _computeProjectionTextureMatrix(): void;
  44723. protected _buildUniformLayout(): void;
  44724. private _computeAngleValues;
  44725. /**
  44726. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44727. * @param effect The effect to update
  44728. * @param lightIndex The index of the light in the effect to update
  44729. * @returns The spot light
  44730. */
  44731. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44732. /**
  44733. * Disposes the light and the associated resources.
  44734. */
  44735. dispose(): void;
  44736. /**
  44737. * Prepares the list of defines specific to the light type.
  44738. * @param defines the list of defines
  44739. * @param lightIndex defines the index of the light for the effect
  44740. */
  44741. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44742. }
  44743. }
  44744. declare module "babylonjs/Gizmos/lightGizmo" {
  44745. import { Nullable } from "babylonjs/types";
  44746. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44747. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44748. import { Light } from "babylonjs/Lights/light";
  44749. /**
  44750. * Gizmo that enables viewing a light
  44751. */
  44752. export class LightGizmo extends Gizmo {
  44753. private _lightMesh;
  44754. private _material;
  44755. /**
  44756. * Creates a LightGizmo
  44757. * @param gizmoLayer The utility layer the gizmo will be added to
  44758. */
  44759. constructor(gizmoLayer?: UtilityLayerRenderer);
  44760. private _light;
  44761. /**
  44762. * The light that the gizmo is attached to
  44763. */
  44764. light: Nullable<Light>;
  44765. /**
  44766. * @hidden
  44767. * Updates the gizmo to match the attached mesh's position/rotation
  44768. */
  44769. protected _update(): void;
  44770. private static _Scale;
  44771. /**
  44772. * Creates the lines for a light mesh
  44773. */
  44774. private static _createLightLines;
  44775. private static _CreateHemisphericLightMesh;
  44776. private static _CreatePointLightMesh;
  44777. private static _CreateSpotLightMesh;
  44778. private static _CreateDirectionalLightMesh;
  44779. }
  44780. }
  44781. declare module "babylonjs/Gizmos/index" {
  44782. export * from "babylonjs/Gizmos/axisDragGizmo";
  44783. export * from "babylonjs/Gizmos/axisScaleGizmo";
  44784. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  44785. export * from "babylonjs/Gizmos/gizmo";
  44786. export * from "babylonjs/Gizmos/gizmoManager";
  44787. export * from "babylonjs/Gizmos/planeRotationGizmo";
  44788. export * from "babylonjs/Gizmos/positionGizmo";
  44789. export * from "babylonjs/Gizmos/rotationGizmo";
  44790. export * from "babylonjs/Gizmos/scaleGizmo";
  44791. export * from "babylonjs/Gizmos/lightGizmo";
  44792. }
  44793. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  44794. /** @hidden */
  44795. export var backgroundFragmentDeclaration: {
  44796. name: string;
  44797. shader: string;
  44798. };
  44799. }
  44800. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  44801. /** @hidden */
  44802. export var backgroundUboDeclaration: {
  44803. name: string;
  44804. shader: string;
  44805. };
  44806. }
  44807. declare module "babylonjs/Shaders/background.fragment" {
  44808. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  44809. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44810. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44811. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44812. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44813. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44814. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44815. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  44816. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44817. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44818. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44819. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44820. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44821. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44822. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44823. /** @hidden */
  44824. export var backgroundPixelShader: {
  44825. name: string;
  44826. shader: string;
  44827. };
  44828. }
  44829. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  44830. /** @hidden */
  44831. export var backgroundVertexDeclaration: {
  44832. name: string;
  44833. shader: string;
  44834. };
  44835. }
  44836. declare module "babylonjs/Shaders/background.vertex" {
  44837. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  44838. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44839. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44840. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44841. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44842. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44843. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44844. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44845. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44846. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44847. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44848. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44849. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44850. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44851. /** @hidden */
  44852. export var backgroundVertexShader: {
  44853. name: string;
  44854. shader: string;
  44855. };
  44856. }
  44857. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  44858. import { Nullable, int, float } from "babylonjs/types";
  44859. import { Scene } from "babylonjs/scene";
  44860. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  44861. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44863. import { Mesh } from "babylonjs/Meshes/mesh";
  44864. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44865. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44866. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44867. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44868. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  44869. import "babylonjs/Shaders/background.fragment";
  44870. import "babylonjs/Shaders/background.vertex";
  44871. /**
  44872. * Background material used to create an efficient environement around your scene.
  44873. */
  44874. export class BackgroundMaterial extends PushMaterial {
  44875. /**
  44876. * Standard reflectance value at parallel view angle.
  44877. */
  44878. static StandardReflectance0: number;
  44879. /**
  44880. * Standard reflectance value at grazing angle.
  44881. */
  44882. static StandardReflectance90: number;
  44883. protected _primaryColor: Color3;
  44884. /**
  44885. * Key light Color (multiply against the environement texture)
  44886. */
  44887. primaryColor: Color3;
  44888. protected __perceptualColor: Nullable<Color3>;
  44889. /**
  44890. * Experimental Internal Use Only.
  44891. *
  44892. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44893. * This acts as a helper to set the primary color to a more "human friendly" value.
  44894. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44895. * output color as close as possible from the chosen value.
  44896. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44897. * part of lighting setup.)
  44898. */
  44899. _perceptualColor: Nullable<Color3>;
  44900. protected _primaryColorShadowLevel: float;
  44901. /**
  44902. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44903. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44904. */
  44905. primaryColorShadowLevel: float;
  44906. protected _primaryColorHighlightLevel: float;
  44907. /**
  44908. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44909. * The primary color is used at the level chosen to define what the white area would look.
  44910. */
  44911. primaryColorHighlightLevel: float;
  44912. protected _reflectionTexture: Nullable<BaseTexture>;
  44913. /**
  44914. * Reflection Texture used in the material.
  44915. * Should be author in a specific way for the best result (refer to the documentation).
  44916. */
  44917. reflectionTexture: Nullable<BaseTexture>;
  44918. protected _reflectionBlur: float;
  44919. /**
  44920. * Reflection Texture level of blur.
  44921. *
  44922. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44923. * texture twice.
  44924. */
  44925. reflectionBlur: float;
  44926. protected _diffuseTexture: Nullable<BaseTexture>;
  44927. /**
  44928. * Diffuse Texture used in the material.
  44929. * Should be author in a specific way for the best result (refer to the documentation).
  44930. */
  44931. diffuseTexture: Nullable<BaseTexture>;
  44932. protected _shadowLights: Nullable<IShadowLight[]>;
  44933. /**
  44934. * Specify the list of lights casting shadow on the material.
  44935. * All scene shadow lights will be included if null.
  44936. */
  44937. shadowLights: Nullable<IShadowLight[]>;
  44938. protected _shadowLevel: float;
  44939. /**
  44940. * Helps adjusting the shadow to a softer level if required.
  44941. * 0 means black shadows and 1 means no shadows.
  44942. */
  44943. shadowLevel: float;
  44944. protected _sceneCenter: Vector3;
  44945. /**
  44946. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44947. * It is usually zero but might be interesting to modify according to your setup.
  44948. */
  44949. sceneCenter: Vector3;
  44950. protected _opacityFresnel: boolean;
  44951. /**
  44952. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44953. * This helps ensuring a nice transition when the camera goes under the ground.
  44954. */
  44955. opacityFresnel: boolean;
  44956. protected _reflectionFresnel: boolean;
  44957. /**
  44958. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44959. * This helps adding a mirror texture on the ground.
  44960. */
  44961. reflectionFresnel: boolean;
  44962. protected _reflectionFalloffDistance: number;
  44963. /**
  44964. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44965. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44966. */
  44967. reflectionFalloffDistance: number;
  44968. protected _reflectionAmount: number;
  44969. /**
  44970. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44971. */
  44972. reflectionAmount: number;
  44973. protected _reflectionReflectance0: number;
  44974. /**
  44975. * This specifies the weight of the reflection at grazing angle.
  44976. */
  44977. reflectionReflectance0: number;
  44978. protected _reflectionReflectance90: number;
  44979. /**
  44980. * This specifies the weight of the reflection at a perpendicular point of view.
  44981. */
  44982. reflectionReflectance90: number;
  44983. /**
  44984. * Sets the reflection reflectance fresnel values according to the default standard
  44985. * empirically know to work well :-)
  44986. */
  44987. reflectionStandardFresnelWeight: number;
  44988. protected _useRGBColor: boolean;
  44989. /**
  44990. * Helps to directly use the maps channels instead of their level.
  44991. */
  44992. useRGBColor: boolean;
  44993. protected _enableNoise: boolean;
  44994. /**
  44995. * This helps reducing the banding effect that could occur on the background.
  44996. */
  44997. enableNoise: boolean;
  44998. /**
  44999. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45000. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45001. * Recommended to be keep at 1.0 except for special cases.
  45002. */
  45003. fovMultiplier: number;
  45004. private _fovMultiplier;
  45005. /**
  45006. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45007. */
  45008. useEquirectangularFOV: boolean;
  45009. private _maxSimultaneousLights;
  45010. /**
  45011. * Number of Simultaneous lights allowed on the material.
  45012. */
  45013. maxSimultaneousLights: int;
  45014. /**
  45015. * Default configuration related to image processing available in the Background Material.
  45016. */
  45017. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45018. /**
  45019. * Keep track of the image processing observer to allow dispose and replace.
  45020. */
  45021. private _imageProcessingObserver;
  45022. /**
  45023. * Attaches a new image processing configuration to the PBR Material.
  45024. * @param configuration (if null the scene configuration will be use)
  45025. */
  45026. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45027. /**
  45028. * Gets the image processing configuration used either in this material.
  45029. */
  45030. /**
  45031. * Sets the Default image processing configuration used either in the this material.
  45032. *
  45033. * If sets to null, the scene one is in use.
  45034. */
  45035. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45036. /**
  45037. * Gets wether the color curves effect is enabled.
  45038. */
  45039. /**
  45040. * Sets wether the color curves effect is enabled.
  45041. */
  45042. cameraColorCurvesEnabled: boolean;
  45043. /**
  45044. * Gets wether the color grading effect is enabled.
  45045. */
  45046. /**
  45047. * Gets wether the color grading effect is enabled.
  45048. */
  45049. cameraColorGradingEnabled: boolean;
  45050. /**
  45051. * Gets wether tonemapping is enabled or not.
  45052. */
  45053. /**
  45054. * Sets wether tonemapping is enabled or not
  45055. */
  45056. cameraToneMappingEnabled: boolean;
  45057. /**
  45058. * The camera exposure used on this material.
  45059. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45060. * This corresponds to a photographic exposure.
  45061. */
  45062. /**
  45063. * The camera exposure used on this material.
  45064. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45065. * This corresponds to a photographic exposure.
  45066. */
  45067. cameraExposure: float;
  45068. /**
  45069. * Gets The camera contrast used on this material.
  45070. */
  45071. /**
  45072. * Sets The camera contrast used on this material.
  45073. */
  45074. cameraContrast: float;
  45075. /**
  45076. * Gets the Color Grading 2D Lookup Texture.
  45077. */
  45078. /**
  45079. * Sets the Color Grading 2D Lookup Texture.
  45080. */
  45081. cameraColorGradingTexture: Nullable<BaseTexture>;
  45082. /**
  45083. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45084. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45085. * 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;
  45086. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45087. */
  45088. /**
  45089. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45090. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45091. * 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;
  45092. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45093. */
  45094. cameraColorCurves: Nullable<ColorCurves>;
  45095. /**
  45096. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45097. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45098. */
  45099. switchToBGR: boolean;
  45100. private _renderTargets;
  45101. private _reflectionControls;
  45102. private _white;
  45103. private _primaryShadowColor;
  45104. private _primaryHighlightColor;
  45105. /**
  45106. * Instantiates a Background Material in the given scene
  45107. * @param name The friendly name of the material
  45108. * @param scene The scene to add the material to
  45109. */
  45110. constructor(name: string, scene: Scene);
  45111. /**
  45112. * Gets a boolean indicating that current material needs to register RTT
  45113. */
  45114. readonly hasRenderTargetTextures: boolean;
  45115. /**
  45116. * The entire material has been created in order to prevent overdraw.
  45117. * @returns false
  45118. */
  45119. needAlphaTesting(): boolean;
  45120. /**
  45121. * The entire material has been created in order to prevent overdraw.
  45122. * @returns true if blending is enable
  45123. */
  45124. needAlphaBlending(): boolean;
  45125. /**
  45126. * Checks wether the material is ready to be rendered for a given mesh.
  45127. * @param mesh The mesh to render
  45128. * @param subMesh The submesh to check against
  45129. * @param useInstances Specify wether or not the material is used with instances
  45130. * @returns true if all the dependencies are ready (Textures, Effects...)
  45131. */
  45132. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45133. /**
  45134. * Compute the primary color according to the chosen perceptual color.
  45135. */
  45136. private _computePrimaryColorFromPerceptualColor;
  45137. /**
  45138. * Compute the highlights and shadow colors according to their chosen levels.
  45139. */
  45140. private _computePrimaryColors;
  45141. /**
  45142. * Build the uniform buffer used in the material.
  45143. */
  45144. buildUniformLayout(): void;
  45145. /**
  45146. * Unbind the material.
  45147. */
  45148. unbind(): void;
  45149. /**
  45150. * Bind only the world matrix to the material.
  45151. * @param world The world matrix to bind.
  45152. */
  45153. bindOnlyWorldMatrix(world: Matrix): void;
  45154. /**
  45155. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45156. * @param world The world matrix to bind.
  45157. * @param subMesh The submesh to bind for.
  45158. */
  45159. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45160. /**
  45161. * Dispose the material.
  45162. * @param forceDisposeEffect Force disposal of the associated effect.
  45163. * @param forceDisposeTextures Force disposal of the associated textures.
  45164. */
  45165. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45166. /**
  45167. * Clones the material.
  45168. * @param name The cloned name.
  45169. * @returns The cloned material.
  45170. */
  45171. clone(name: string): BackgroundMaterial;
  45172. /**
  45173. * Serializes the current material to its JSON representation.
  45174. * @returns The JSON representation.
  45175. */
  45176. serialize(): any;
  45177. /**
  45178. * Gets the class name of the material
  45179. * @returns "BackgroundMaterial"
  45180. */
  45181. getClassName(): string;
  45182. /**
  45183. * Parse a JSON input to create back a background material.
  45184. * @param source The JSON data to parse
  45185. * @param scene The scene to create the parsed material in
  45186. * @param rootUrl The root url of the assets the material depends upon
  45187. * @returns the instantiated BackgroundMaterial.
  45188. */
  45189. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45190. }
  45191. }
  45192. declare module "babylonjs/Helpers/environmentHelper" {
  45193. import { Observable } from "babylonjs/Misc/observable";
  45194. import { Nullable } from "babylonjs/types";
  45195. import { Scene } from "babylonjs/scene";
  45196. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45198. import { Mesh } from "babylonjs/Meshes/mesh";
  45199. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45200. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  45201. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45202. import "babylonjs/Meshes/Builders/planeBuilder";
  45203. import "babylonjs/Meshes/Builders/boxBuilder";
  45204. /**
  45205. * Represents the different options available during the creation of
  45206. * a Environment helper.
  45207. *
  45208. * This can control the default ground, skybox and image processing setup of your scene.
  45209. */
  45210. export interface IEnvironmentHelperOptions {
  45211. /**
  45212. * Specifies wether or not to create a ground.
  45213. * True by default.
  45214. */
  45215. createGround: boolean;
  45216. /**
  45217. * Specifies the ground size.
  45218. * 15 by default.
  45219. */
  45220. groundSize: number;
  45221. /**
  45222. * The texture used on the ground for the main color.
  45223. * Comes from the BabylonJS CDN by default.
  45224. *
  45225. * Remarks: Can be either a texture or a url.
  45226. */
  45227. groundTexture: string | BaseTexture;
  45228. /**
  45229. * The color mixed in the ground texture by default.
  45230. * BabylonJS clearColor by default.
  45231. */
  45232. groundColor: Color3;
  45233. /**
  45234. * Specifies the ground opacity.
  45235. * 1 by default.
  45236. */
  45237. groundOpacity: number;
  45238. /**
  45239. * Enables the ground to receive shadows.
  45240. * True by default.
  45241. */
  45242. enableGroundShadow: boolean;
  45243. /**
  45244. * Helps preventing the shadow to be fully black on the ground.
  45245. * 0.5 by default.
  45246. */
  45247. groundShadowLevel: number;
  45248. /**
  45249. * Creates a mirror texture attach to the ground.
  45250. * false by default.
  45251. */
  45252. enableGroundMirror: boolean;
  45253. /**
  45254. * Specifies the ground mirror size ratio.
  45255. * 0.3 by default as the default kernel is 64.
  45256. */
  45257. groundMirrorSizeRatio: number;
  45258. /**
  45259. * Specifies the ground mirror blur kernel size.
  45260. * 64 by default.
  45261. */
  45262. groundMirrorBlurKernel: number;
  45263. /**
  45264. * Specifies the ground mirror visibility amount.
  45265. * 1 by default
  45266. */
  45267. groundMirrorAmount: number;
  45268. /**
  45269. * Specifies the ground mirror reflectance weight.
  45270. * This uses the standard weight of the background material to setup the fresnel effect
  45271. * of the mirror.
  45272. * 1 by default.
  45273. */
  45274. groundMirrorFresnelWeight: number;
  45275. /**
  45276. * Specifies the ground mirror Falloff distance.
  45277. * This can helps reducing the size of the reflection.
  45278. * 0 by Default.
  45279. */
  45280. groundMirrorFallOffDistance: number;
  45281. /**
  45282. * Specifies the ground mirror texture type.
  45283. * Unsigned Int by Default.
  45284. */
  45285. groundMirrorTextureType: number;
  45286. /**
  45287. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45288. * the shown objects.
  45289. */
  45290. groundYBias: number;
  45291. /**
  45292. * Specifies wether or not to create a skybox.
  45293. * True by default.
  45294. */
  45295. createSkybox: boolean;
  45296. /**
  45297. * Specifies the skybox size.
  45298. * 20 by default.
  45299. */
  45300. skyboxSize: number;
  45301. /**
  45302. * The texture used on the skybox for the main color.
  45303. * Comes from the BabylonJS CDN by default.
  45304. *
  45305. * Remarks: Can be either a texture or a url.
  45306. */
  45307. skyboxTexture: string | BaseTexture;
  45308. /**
  45309. * The color mixed in the skybox texture by default.
  45310. * BabylonJS clearColor by default.
  45311. */
  45312. skyboxColor: Color3;
  45313. /**
  45314. * The background rotation around the Y axis of the scene.
  45315. * This helps aligning the key lights of your scene with the background.
  45316. * 0 by default.
  45317. */
  45318. backgroundYRotation: number;
  45319. /**
  45320. * Compute automatically the size of the elements to best fit with the scene.
  45321. */
  45322. sizeAuto: boolean;
  45323. /**
  45324. * Default position of the rootMesh if autoSize is not true.
  45325. */
  45326. rootPosition: Vector3;
  45327. /**
  45328. * Sets up the image processing in the scene.
  45329. * true by default.
  45330. */
  45331. setupImageProcessing: boolean;
  45332. /**
  45333. * The texture used as your environment texture in the scene.
  45334. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45335. *
  45336. * Remarks: Can be either a texture or a url.
  45337. */
  45338. environmentTexture: string | BaseTexture;
  45339. /**
  45340. * The value of the exposure to apply to the scene.
  45341. * 0.6 by default if setupImageProcessing is true.
  45342. */
  45343. cameraExposure: number;
  45344. /**
  45345. * The value of the contrast to apply to the scene.
  45346. * 1.6 by default if setupImageProcessing is true.
  45347. */
  45348. cameraContrast: number;
  45349. /**
  45350. * Specifies wether or not tonemapping should be enabled in the scene.
  45351. * true by default if setupImageProcessing is true.
  45352. */
  45353. toneMappingEnabled: boolean;
  45354. }
  45355. /**
  45356. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45357. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45358. * It also helps with the default setup of your imageProcessing configuration.
  45359. */
  45360. export class EnvironmentHelper {
  45361. /**
  45362. * Default ground texture URL.
  45363. */
  45364. private static _groundTextureCDNUrl;
  45365. /**
  45366. * Default skybox texture URL.
  45367. */
  45368. private static _skyboxTextureCDNUrl;
  45369. /**
  45370. * Default environment texture URL.
  45371. */
  45372. private static _environmentTextureCDNUrl;
  45373. /**
  45374. * Creates the default options for the helper.
  45375. */
  45376. private static _getDefaultOptions;
  45377. private _rootMesh;
  45378. /**
  45379. * Gets the root mesh created by the helper.
  45380. */
  45381. readonly rootMesh: Mesh;
  45382. private _skybox;
  45383. /**
  45384. * Gets the skybox created by the helper.
  45385. */
  45386. readonly skybox: Nullable<Mesh>;
  45387. private _skyboxTexture;
  45388. /**
  45389. * Gets the skybox texture created by the helper.
  45390. */
  45391. readonly skyboxTexture: Nullable<BaseTexture>;
  45392. private _skyboxMaterial;
  45393. /**
  45394. * Gets the skybox material created by the helper.
  45395. */
  45396. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45397. private _ground;
  45398. /**
  45399. * Gets the ground mesh created by the helper.
  45400. */
  45401. readonly ground: Nullable<Mesh>;
  45402. private _groundTexture;
  45403. /**
  45404. * Gets the ground texture created by the helper.
  45405. */
  45406. readonly groundTexture: Nullable<BaseTexture>;
  45407. private _groundMirror;
  45408. /**
  45409. * Gets the ground mirror created by the helper.
  45410. */
  45411. readonly groundMirror: Nullable<MirrorTexture>;
  45412. /**
  45413. * Gets the ground mirror render list to helps pushing the meshes
  45414. * you wish in the ground reflection.
  45415. */
  45416. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45417. private _groundMaterial;
  45418. /**
  45419. * Gets the ground material created by the helper.
  45420. */
  45421. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45422. /**
  45423. * Stores the creation options.
  45424. */
  45425. private readonly _scene;
  45426. private _options;
  45427. /**
  45428. * This observable will be notified with any error during the creation of the environment,
  45429. * mainly texture creation errors.
  45430. */
  45431. onErrorObservable: Observable<{
  45432. message?: string;
  45433. exception?: any;
  45434. }>;
  45435. /**
  45436. * constructor
  45437. * @param options Defines the options we want to customize the helper
  45438. * @param scene The scene to add the material to
  45439. */
  45440. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45441. /**
  45442. * Updates the background according to the new options
  45443. * @param options
  45444. */
  45445. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45446. /**
  45447. * Sets the primary color of all the available elements.
  45448. * @param color the main color to affect to the ground and the background
  45449. */
  45450. setMainColor(color: Color3): void;
  45451. /**
  45452. * Setup the image processing according to the specified options.
  45453. */
  45454. private _setupImageProcessing;
  45455. /**
  45456. * Setup the environment texture according to the specified options.
  45457. */
  45458. private _setupEnvironmentTexture;
  45459. /**
  45460. * Setup the background according to the specified options.
  45461. */
  45462. private _setupBackground;
  45463. /**
  45464. * Get the scene sizes according to the setup.
  45465. */
  45466. private _getSceneSize;
  45467. /**
  45468. * Setup the ground according to the specified options.
  45469. */
  45470. private _setupGround;
  45471. /**
  45472. * Setup the ground material according to the specified options.
  45473. */
  45474. private _setupGroundMaterial;
  45475. /**
  45476. * Setup the ground diffuse texture according to the specified options.
  45477. */
  45478. private _setupGroundDiffuseTexture;
  45479. /**
  45480. * Setup the ground mirror texture according to the specified options.
  45481. */
  45482. private _setupGroundMirrorTexture;
  45483. /**
  45484. * Setup the ground to receive the mirror texture.
  45485. */
  45486. private _setupMirrorInGroundMaterial;
  45487. /**
  45488. * Setup the skybox according to the specified options.
  45489. */
  45490. private _setupSkybox;
  45491. /**
  45492. * Setup the skybox material according to the specified options.
  45493. */
  45494. private _setupSkyboxMaterial;
  45495. /**
  45496. * Setup the skybox reflection texture according to the specified options.
  45497. */
  45498. private _setupSkyboxReflectionTexture;
  45499. private _errorHandler;
  45500. /**
  45501. * Dispose all the elements created by the Helper.
  45502. */
  45503. dispose(): void;
  45504. }
  45505. }
  45506. declare module "babylonjs/Helpers/photoDome" {
  45507. import { Observable } from "babylonjs/Misc/observable";
  45508. import { Nullable } from "babylonjs/types";
  45509. import { Scene } from "babylonjs/scene";
  45510. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45511. import { Mesh } from "babylonjs/Meshes/mesh";
  45512. import { Texture } from "babylonjs/Materials/Textures/texture";
  45513. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45514. import "babylonjs/Meshes/Builders/sphereBuilder";
  45515. /**
  45516. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45517. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45518. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45519. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45520. */
  45521. export class PhotoDome extends TransformNode {
  45522. private _useDirectMapping;
  45523. /**
  45524. * The texture being displayed on the sphere
  45525. */
  45526. protected _photoTexture: Texture;
  45527. /**
  45528. * Gets or sets the texture being displayed on the sphere
  45529. */
  45530. photoTexture: Texture;
  45531. /**
  45532. * Observable raised when an error occured while loading the 360 image
  45533. */
  45534. onLoadErrorObservable: Observable<string>;
  45535. /**
  45536. * The skybox material
  45537. */
  45538. protected _material: BackgroundMaterial;
  45539. /**
  45540. * The surface used for the skybox
  45541. */
  45542. protected _mesh: Mesh;
  45543. /**
  45544. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45545. * Also see the options.resolution property.
  45546. */
  45547. fovMultiplier: number;
  45548. /**
  45549. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45550. * @param name Element's name, child elements will append suffixes for their own names.
  45551. * @param urlsOfPhoto defines the url of the photo to display
  45552. * @param options defines an object containing optional or exposed sub element properties
  45553. * @param onError defines a callback called when an error occured while loading the texture
  45554. */
  45555. constructor(name: string, urlOfPhoto: string, options: {
  45556. resolution?: number;
  45557. size?: number;
  45558. useDirectMapping?: boolean;
  45559. faceForward?: boolean;
  45560. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45561. /**
  45562. * Releases resources associated with this node.
  45563. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45564. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45565. */
  45566. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45567. }
  45568. }
  45569. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45570. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45571. /** @hidden */
  45572. export var rgbdDecodePixelShader: {
  45573. name: string;
  45574. shader: string;
  45575. };
  45576. }
  45577. declare module "babylonjs/Misc/brdfTextureTools" {
  45578. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45579. import { Scene } from "babylonjs/scene";
  45580. import "babylonjs/Shaders/rgbdDecode.fragment";
  45581. /**
  45582. * Class used to host texture specific utilities
  45583. */
  45584. export class BRDFTextureTools {
  45585. /**
  45586. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45587. * @param texture the texture to expand.
  45588. */
  45589. private static _ExpandDefaultBRDFTexture;
  45590. /**
  45591. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45592. * @param scene defines the hosting scene
  45593. * @returns the environment BRDF texture
  45594. */
  45595. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45596. private static _environmentBRDFBase64Texture;
  45597. }
  45598. }
  45599. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  45600. import { Nullable } from "babylonjs/types";
  45601. import { IAnimatable } from "babylonjs/Misc/tools";
  45602. import { Color3 } from "babylonjs/Maths/math";
  45603. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45604. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45605. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45606. import { Engine } from "babylonjs/Engines/engine";
  45607. import { Scene } from "babylonjs/scene";
  45608. /**
  45609. * @hidden
  45610. */
  45611. export interface IMaterialClearCoatDefines {
  45612. CLEARCOAT: boolean;
  45613. CLEARCOAT_DEFAULTIOR: boolean;
  45614. CLEARCOAT_TEXTURE: boolean;
  45615. CLEARCOAT_TEXTUREDIRECTUV: number;
  45616. CLEARCOAT_BUMP: boolean;
  45617. CLEARCOAT_BUMPDIRECTUV: number;
  45618. CLEARCOAT_TINT: boolean;
  45619. CLEARCOAT_TINT_TEXTURE: boolean;
  45620. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45621. /** @hidden */
  45622. _areTexturesDirty: boolean;
  45623. }
  45624. /**
  45625. * Define the code related to the clear coat parameters of the pbr material.
  45626. */
  45627. export class PBRClearCoatConfiguration {
  45628. /**
  45629. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45630. * The default fits with a polyurethane material.
  45631. */
  45632. private static readonly _DefaultIndiceOfRefraction;
  45633. private _isEnabled;
  45634. /**
  45635. * Defines if the clear coat is enabled in the material.
  45636. */
  45637. isEnabled: boolean;
  45638. /**
  45639. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45640. */
  45641. intensity: number;
  45642. /**
  45643. * Defines the clear coat layer roughness.
  45644. */
  45645. roughness: number;
  45646. private _indiceOfRefraction;
  45647. /**
  45648. * Defines the indice of refraction of the clear coat.
  45649. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45650. * The default fits with a polyurethane material.
  45651. * Changing the default value is more performance intensive.
  45652. */
  45653. indiceOfRefraction: number;
  45654. private _texture;
  45655. /**
  45656. * Stores the clear coat values in a texture.
  45657. */
  45658. texture: Nullable<BaseTexture>;
  45659. private _bumpTexture;
  45660. /**
  45661. * Define the clear coat specific bump texture.
  45662. */
  45663. bumpTexture: Nullable<BaseTexture>;
  45664. private _isTintEnabled;
  45665. /**
  45666. * Defines if the clear coat tint is enabled in the material.
  45667. */
  45668. isTintEnabled: boolean;
  45669. /**
  45670. * Defines the clear coat tint of the material.
  45671. * This is only use if tint is enabled
  45672. */
  45673. tintColor: Color3;
  45674. /**
  45675. * Defines the distance at which the tint color should be found in the
  45676. * clear coat media.
  45677. * This is only use if tint is enabled
  45678. */
  45679. tintColorAtDistance: number;
  45680. /**
  45681. * Defines the clear coat layer thickness.
  45682. * This is only use if tint is enabled
  45683. */
  45684. tintThickness: number;
  45685. private _tintTexture;
  45686. /**
  45687. * Stores the clear tint values in a texture.
  45688. * rgb is tint
  45689. * a is a thickness factor
  45690. */
  45691. tintTexture: Nullable<BaseTexture>;
  45692. /** @hidden */
  45693. private _internalMarkAllSubMeshesAsTexturesDirty;
  45694. /** @hidden */
  45695. _markAllSubMeshesAsTexturesDirty(): void;
  45696. /**
  45697. * Instantiate a new istance of clear coat configuration.
  45698. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45699. */
  45700. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45701. /**
  45702. * Gets wehter the submesh is ready to be used or not.
  45703. * @param defines the list of "defines" to update.
  45704. * @param scene defines the scene the material belongs to.
  45705. * @param engine defines the engine the material belongs to.
  45706. * @param disableBumpMap defines wether the material disables bump or not.
  45707. * @returns - boolean indicating that the submesh is ready or not.
  45708. */
  45709. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45710. /**
  45711. * Checks to see if a texture is used in the material.
  45712. * @param defines the list of "defines" to update.
  45713. * @param scene defines the scene to the material belongs to.
  45714. */
  45715. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45716. /**
  45717. * Binds the material data.
  45718. * @param uniformBuffer defines the Uniform buffer to fill in.
  45719. * @param scene defines the scene the material belongs to.
  45720. * @param engine defines the engine the material belongs to.
  45721. * @param disableBumpMap defines wether the material disables bump or not.
  45722. * @param isFrozen defines wether the material is frozen or not.
  45723. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45724. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45725. */
  45726. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45727. /**
  45728. * Checks to see if a texture is used in the material.
  45729. * @param texture - Base texture to use.
  45730. * @returns - Boolean specifying if a texture is used in the material.
  45731. */
  45732. hasTexture(texture: BaseTexture): boolean;
  45733. /**
  45734. * Returns an array of the actively used textures.
  45735. * @param activeTextures Array of BaseTextures
  45736. */
  45737. getActiveTextures(activeTextures: BaseTexture[]): void;
  45738. /**
  45739. * Returns the animatable textures.
  45740. * @param animatables Array of animatable textures.
  45741. */
  45742. getAnimatables(animatables: IAnimatable[]): void;
  45743. /**
  45744. * Disposes the resources of the material.
  45745. * @param forceDisposeTextures - Forces the disposal of all textures.
  45746. */
  45747. dispose(forceDisposeTextures?: boolean): void;
  45748. /**
  45749. * Get the current class name of the texture useful for serialization or dynamic coding.
  45750. * @returns "PBRClearCoatConfiguration"
  45751. */
  45752. getClassName(): string;
  45753. /**
  45754. * Add fallbacks to the effect fallbacks list.
  45755. * @param defines defines the Base texture to use.
  45756. * @param fallbacks defines the current fallback list.
  45757. * @param currentRank defines the current fallback rank.
  45758. * @returns the new fallback rank.
  45759. */
  45760. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45761. /**
  45762. * Add the required uniforms to the current list.
  45763. * @param uniforms defines the current uniform list.
  45764. */
  45765. static AddUniforms(uniforms: string[]): void;
  45766. /**
  45767. * Add the required samplers to the current list.
  45768. * @param samplers defines the current sampler list.
  45769. */
  45770. static AddSamplers(samplers: string[]): void;
  45771. /**
  45772. * Add the required uniforms to the current buffer.
  45773. * @param uniformBuffer defines the current uniform buffer.
  45774. */
  45775. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45776. /**
  45777. * Makes a duplicate of the current configuration into another one.
  45778. * @param clearCoatConfiguration define the config where to copy the info
  45779. */
  45780. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45781. /**
  45782. * Serializes this clear coat configuration.
  45783. * @returns - An object with the serialized config.
  45784. */
  45785. serialize(): any;
  45786. /**
  45787. * Parses a Clear Coat Configuration from a serialized object.
  45788. * @param source - Serialized object.
  45789. */
  45790. parse(source: any): void;
  45791. }
  45792. }
  45793. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  45794. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45795. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45796. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45797. import { Vector2 } from "babylonjs/Maths/math";
  45798. import { Scene } from "babylonjs/scene";
  45799. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45800. import { IAnimatable } from "babylonjs/Misc/tools";
  45801. import { Nullable } from "babylonjs/types";
  45802. /**
  45803. * @hidden
  45804. */
  45805. export interface IMaterialAnisotropicDefines {
  45806. ANISOTROPIC: boolean;
  45807. ANISOTROPIC_TEXTURE: boolean;
  45808. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45809. MAINUV1: boolean;
  45810. _areTexturesDirty: boolean;
  45811. _needUVs: boolean;
  45812. }
  45813. /**
  45814. * Define the code related to the anisotropic parameters of the pbr material.
  45815. */
  45816. export class PBRAnisotropicConfiguration {
  45817. private _isEnabled;
  45818. /**
  45819. * Defines if the anisotropy is enabled in the material.
  45820. */
  45821. isEnabled: boolean;
  45822. /**
  45823. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45824. */
  45825. intensity: number;
  45826. /**
  45827. * Defines if the effect is along the tangents, bitangents or in between.
  45828. * By default, the effect is "strectching" the highlights along the tangents.
  45829. */
  45830. direction: Vector2;
  45831. private _texture;
  45832. /**
  45833. * Stores the anisotropy values in a texture.
  45834. * rg is direction (like normal from -1 to 1)
  45835. * b is a intensity
  45836. */
  45837. texture: Nullable<BaseTexture>;
  45838. /** @hidden */
  45839. private _internalMarkAllSubMeshesAsTexturesDirty;
  45840. /** @hidden */
  45841. _markAllSubMeshesAsTexturesDirty(): void;
  45842. /**
  45843. * Instantiate a new istance of anisotropy configuration.
  45844. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45845. */
  45846. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45847. /**
  45848. * Specifies that the submesh is ready to be used.
  45849. * @param defines the list of "defines" to update.
  45850. * @param scene defines the scene the material belongs to.
  45851. * @returns - boolean indicating that the submesh is ready or not.
  45852. */
  45853. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45854. /**
  45855. * Checks to see if a texture is used in the material.
  45856. * @param defines the list of "defines" to update.
  45857. * @param mesh the mesh we are preparing the defines for.
  45858. * @param scene defines the scene the material belongs to.
  45859. */
  45860. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45861. /**
  45862. * Binds the material data.
  45863. * @param uniformBuffer defines the Uniform buffer to fill in.
  45864. * @param scene defines the scene the material belongs to.
  45865. * @param isFrozen defines wether the material is frozen or not.
  45866. */
  45867. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45868. /**
  45869. * Checks to see if a texture is used in the material.
  45870. * @param texture - Base texture to use.
  45871. * @returns - Boolean specifying if a texture is used in the material.
  45872. */
  45873. hasTexture(texture: BaseTexture): boolean;
  45874. /**
  45875. * Returns an array of the actively used textures.
  45876. * @param activeTextures Array of BaseTextures
  45877. */
  45878. getActiveTextures(activeTextures: BaseTexture[]): void;
  45879. /**
  45880. * Returns the animatable textures.
  45881. * @param animatables Array of animatable textures.
  45882. */
  45883. getAnimatables(animatables: IAnimatable[]): void;
  45884. /**
  45885. * Disposes the resources of the material.
  45886. * @param forceDisposeTextures - Forces the disposal of all textures.
  45887. */
  45888. dispose(forceDisposeTextures?: boolean): void;
  45889. /**
  45890. * Get the current class name of the texture useful for serialization or dynamic coding.
  45891. * @returns "PBRAnisotropicConfiguration"
  45892. */
  45893. getClassName(): string;
  45894. /**
  45895. * Add fallbacks to the effect fallbacks list.
  45896. * @param defines defines the Base texture to use.
  45897. * @param fallbacks defines the current fallback list.
  45898. * @param currentRank defines the current fallback rank.
  45899. * @returns the new fallback rank.
  45900. */
  45901. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45902. /**
  45903. * Add the required uniforms to the current list.
  45904. * @param uniforms defines the current uniform list.
  45905. */
  45906. static AddUniforms(uniforms: string[]): void;
  45907. /**
  45908. * Add the required uniforms to the current buffer.
  45909. * @param uniformBuffer defines the current uniform buffer.
  45910. */
  45911. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45912. /**
  45913. * Add the required samplers to the current list.
  45914. * @param samplers defines the current sampler list.
  45915. */
  45916. static AddSamplers(samplers: string[]): void;
  45917. /**
  45918. * Makes a duplicate of the current configuration into another one.
  45919. * @param anisotropicConfiguration define the config where to copy the info
  45920. */
  45921. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45922. /**
  45923. * Serializes this anisotropy configuration.
  45924. * @returns - An object with the serialized config.
  45925. */
  45926. serialize(): any;
  45927. /**
  45928. * Parses a anisotropy Configuration from a serialized object.
  45929. * @param source - Serialized object.
  45930. */
  45931. parse(source: any): void;
  45932. }
  45933. }
  45934. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  45935. /**
  45936. * @hidden
  45937. */
  45938. export interface IMaterialBRDFDefines {
  45939. BRDF_V_HEIGHT_CORRELATED: boolean;
  45940. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45941. /** @hidden */
  45942. _areMiscDirty: boolean;
  45943. }
  45944. /**
  45945. * Define the code related to the BRDF parameters of the pbr material.
  45946. */
  45947. export class PBRBRDFConfiguration {
  45948. /**
  45949. * Default value used for the energy conservation.
  45950. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45951. */
  45952. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45953. /**
  45954. * Default value used for the Smith Visibility Height Correlated mode.
  45955. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45956. */
  45957. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45958. private _useEnergyConservation;
  45959. /**
  45960. * Defines if the material uses energy conservation.
  45961. */
  45962. useEnergyConservation: boolean;
  45963. private _useSmithVisibilityHeightCorrelated;
  45964. /**
  45965. * LEGACY Mode set to false
  45966. * Defines if the material uses height smith correlated visibility term.
  45967. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45968. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45969. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45970. * Not relying on height correlated will also disable energy conservation.
  45971. */
  45972. useSmithVisibilityHeightCorrelated: boolean;
  45973. /** @hidden */
  45974. private _internalMarkAllSubMeshesAsMiscDirty;
  45975. /** @hidden */
  45976. _markAllSubMeshesAsMiscDirty(): void;
  45977. /**
  45978. * Instantiate a new istance of clear coat configuration.
  45979. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45980. */
  45981. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45982. /**
  45983. * Checks to see if a texture is used in the material.
  45984. * @param defines the list of "defines" to update.
  45985. */
  45986. prepareDefines(defines: IMaterialBRDFDefines): void;
  45987. /**
  45988. * Get the current class name of the texture useful for serialization or dynamic coding.
  45989. * @returns "PBRClearCoatConfiguration"
  45990. */
  45991. getClassName(): string;
  45992. /**
  45993. * Makes a duplicate of the current configuration into another one.
  45994. * @param brdfConfiguration define the config where to copy the info
  45995. */
  45996. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45997. /**
  45998. * Serializes this BRDF configuration.
  45999. * @returns - An object with the serialized config.
  46000. */
  46001. serialize(): any;
  46002. /**
  46003. * Parses a BRDF Configuration from a serialized object.
  46004. * @param source - Serialized object.
  46005. */
  46006. parse(source: any): void;
  46007. }
  46008. }
  46009. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46010. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46011. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46012. import { Color3 } from "babylonjs/Maths/math";
  46013. import { Scene } from "babylonjs/scene";
  46014. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46015. import { IAnimatable } from "babylonjs/Misc/tools";
  46016. import { Nullable } from "babylonjs/types";
  46017. /**
  46018. * @hidden
  46019. */
  46020. export interface IMaterialSheenDefines {
  46021. SHEEN: boolean;
  46022. SHEEN_TEXTURE: boolean;
  46023. SHEEN_TEXTUREDIRECTUV: number;
  46024. SHEEN_LINKWITHALBEDO: boolean;
  46025. /** @hidden */
  46026. _areTexturesDirty: boolean;
  46027. }
  46028. /**
  46029. * Define the code related to the Sheen parameters of the pbr material.
  46030. */
  46031. export class PBRSheenConfiguration {
  46032. private _isEnabled;
  46033. /**
  46034. * Defines if the material uses sheen.
  46035. */
  46036. isEnabled: boolean;
  46037. private _linkSheenWithAlbedo;
  46038. /**
  46039. * Defines if the sheen is linked to the sheen color.
  46040. */
  46041. linkSheenWithAlbedo: boolean;
  46042. /**
  46043. * Defines the sheen intensity.
  46044. */
  46045. intensity: number;
  46046. /**
  46047. * Defines the sheen color.
  46048. */
  46049. color: Color3;
  46050. private _texture;
  46051. /**
  46052. * Stores the sheen tint values in a texture.
  46053. * rgb is tint
  46054. * a is a intensity
  46055. */
  46056. texture: Nullable<BaseTexture>;
  46057. /** @hidden */
  46058. private _internalMarkAllSubMeshesAsTexturesDirty;
  46059. /** @hidden */
  46060. _markAllSubMeshesAsTexturesDirty(): void;
  46061. /**
  46062. * Instantiate a new istance of clear coat configuration.
  46063. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46064. */
  46065. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46066. /**
  46067. * Specifies that the submesh is ready to be used.
  46068. * @param defines the list of "defines" to update.
  46069. * @param scene defines the scene the material belongs to.
  46070. * @returns - boolean indicating that the submesh is ready or not.
  46071. */
  46072. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46073. /**
  46074. * Checks to see if a texture is used in the material.
  46075. * @param defines the list of "defines" to update.
  46076. * @param scene defines the scene the material belongs to.
  46077. */
  46078. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46079. /**
  46080. * Binds the material data.
  46081. * @param uniformBuffer defines the Uniform buffer to fill in.
  46082. * @param scene defines the scene the material belongs to.
  46083. * @param isFrozen defines wether the material is frozen or not.
  46084. */
  46085. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46086. /**
  46087. * Checks to see if a texture is used in the material.
  46088. * @param texture - Base texture to use.
  46089. * @returns - Boolean specifying if a texture is used in the material.
  46090. */
  46091. hasTexture(texture: BaseTexture): boolean;
  46092. /**
  46093. * Returns an array of the actively used textures.
  46094. * @param activeTextures Array of BaseTextures
  46095. */
  46096. getActiveTextures(activeTextures: BaseTexture[]): void;
  46097. /**
  46098. * Returns the animatable textures.
  46099. * @param animatables Array of animatable textures.
  46100. */
  46101. getAnimatables(animatables: IAnimatable[]): void;
  46102. /**
  46103. * Disposes the resources of the material.
  46104. * @param forceDisposeTextures - Forces the disposal of all textures.
  46105. */
  46106. dispose(forceDisposeTextures?: boolean): void;
  46107. /**
  46108. * Get the current class name of the texture useful for serialization or dynamic coding.
  46109. * @returns "PBRSheenConfiguration"
  46110. */
  46111. getClassName(): string;
  46112. /**
  46113. * Add fallbacks to the effect fallbacks list.
  46114. * @param defines defines the Base texture to use.
  46115. * @param fallbacks defines the current fallback list.
  46116. * @param currentRank defines the current fallback rank.
  46117. * @returns the new fallback rank.
  46118. */
  46119. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46120. /**
  46121. * Add the required uniforms to the current list.
  46122. * @param uniforms defines the current uniform list.
  46123. */
  46124. static AddUniforms(uniforms: string[]): void;
  46125. /**
  46126. * Add the required uniforms to the current buffer.
  46127. * @param uniformBuffer defines the current uniform buffer.
  46128. */
  46129. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46130. /**
  46131. * Add the required samplers to the current list.
  46132. * @param samplers defines the current sampler list.
  46133. */
  46134. static AddSamplers(samplers: string[]): void;
  46135. /**
  46136. * Makes a duplicate of the current configuration into another one.
  46137. * @param sheenConfiguration define the config where to copy the info
  46138. */
  46139. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46140. /**
  46141. * Serializes this BRDF configuration.
  46142. * @returns - An object with the serialized config.
  46143. */
  46144. serialize(): any;
  46145. /**
  46146. * Parses a Sheen Configuration from a serialized object.
  46147. * @param source - Serialized object.
  46148. */
  46149. parse(source: any): void;
  46150. }
  46151. }
  46152. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  46153. import { Nullable } from "babylonjs/types";
  46154. import { IAnimatable } from "babylonjs/Misc/tools";
  46155. import { Color3 } from "babylonjs/Maths/math";
  46156. import { SmartArray } from "babylonjs/Misc/smartArray";
  46157. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46158. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46159. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  46160. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46161. import { Engine } from "babylonjs/Engines/engine";
  46162. import { Scene } from "babylonjs/scene";
  46163. /**
  46164. * @hidden
  46165. */
  46166. export interface IMaterialSubSurfaceDefines {
  46167. SUBSURFACE: boolean;
  46168. SS_REFRACTION: boolean;
  46169. SS_TRANSLUCENCY: boolean;
  46170. SS_SCATERRING: boolean;
  46171. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46172. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46173. SS_REFRACTIONMAP_3D: boolean;
  46174. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46175. SS_LODINREFRACTIONALPHA: boolean;
  46176. SS_GAMMAREFRACTION: boolean;
  46177. SS_RGBDREFRACTION: boolean;
  46178. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46179. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46180. /** @hidden */
  46181. _areTexturesDirty: boolean;
  46182. }
  46183. /**
  46184. * Define the code related to the sub surface parameters of the pbr material.
  46185. */
  46186. export class PBRSubSurfaceConfiguration {
  46187. private _isRefractionEnabled;
  46188. /**
  46189. * Defines if the refraction is enabled in the material.
  46190. */
  46191. isRefractionEnabled: boolean;
  46192. private _isTranslucencyEnabled;
  46193. /**
  46194. * Defines if the translucency is enabled in the material.
  46195. */
  46196. isTranslucencyEnabled: boolean;
  46197. private _isScatteringEnabled;
  46198. /**
  46199. * Defines the refraction intensity of the material.
  46200. * The refraction when enabled replaces the Diffuse part of the material.
  46201. * The intensity helps transitionning between diffuse and refraction.
  46202. */
  46203. refractionIntensity: number;
  46204. /**
  46205. * Defines the translucency intensity of the material.
  46206. * When translucency has been enabled, this defines how much of the "translucency"
  46207. * is addded to the diffuse part of the material.
  46208. */
  46209. translucencyIntensity: number;
  46210. /**
  46211. * Defines the scattering intensity of the material.
  46212. * When scattering has been enabled, this defines how much of the "scattered light"
  46213. * is addded to the diffuse part of the material.
  46214. */
  46215. scatteringIntensity: number;
  46216. private _thicknessTexture;
  46217. /**
  46218. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46219. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46220. * 0 would mean minimumThickness
  46221. * 1 would mean maximumThickness
  46222. * The other channels might be use as a mask to vary the different effects intensity.
  46223. */
  46224. thicknessTexture: Nullable<BaseTexture>;
  46225. private _refractionTexture;
  46226. /**
  46227. * Defines the texture to use for refraction.
  46228. */
  46229. refractionTexture: Nullable<BaseTexture>;
  46230. private _indexOfRefraction;
  46231. /**
  46232. * Defines the indice of refraction used in the material.
  46233. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46234. */
  46235. indexOfRefraction: number;
  46236. private _invertRefractionY;
  46237. /**
  46238. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46239. */
  46240. invertRefractionY: boolean;
  46241. private _linkRefractionWithTransparency;
  46242. /**
  46243. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46244. * Materials half opaque for instance using refraction could benefit from this control.
  46245. */
  46246. linkRefractionWithTransparency: boolean;
  46247. /**
  46248. * Defines the minimum thickness stored in the thickness map.
  46249. * If no thickness map is defined, this value will be used to simulate thickness.
  46250. */
  46251. minimumThickness: number;
  46252. /**
  46253. * Defines the maximum thickness stored in the thickness map.
  46254. */
  46255. maximumThickness: number;
  46256. /**
  46257. * Defines the volume tint of the material.
  46258. * This is used for both translucency and scattering.
  46259. */
  46260. tintColor: Color3;
  46261. /**
  46262. * Defines the distance at which the tint color should be found in the media.
  46263. * This is used for refraction only.
  46264. */
  46265. tintColorAtDistance: number;
  46266. /**
  46267. * Defines how far each channel transmit through the media.
  46268. * It is defined as a color to simplify it selection.
  46269. */
  46270. diffusionDistance: Color3;
  46271. private _useMaskFromThicknessTexture;
  46272. /**
  46273. * Stores the intensity of the different subsurface effects in the thickness texture.
  46274. * * the green channel is the translucency intensity.
  46275. * * the blue channel is the scattering intensity.
  46276. * * the alpha channel is the refraction intensity.
  46277. */
  46278. useMaskFromThicknessTexture: boolean;
  46279. /** @hidden */
  46280. private _internalMarkAllSubMeshesAsTexturesDirty;
  46281. /** @hidden */
  46282. _markAllSubMeshesAsTexturesDirty(): void;
  46283. /**
  46284. * Instantiate a new istance of sub surface configuration.
  46285. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46286. */
  46287. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46288. /**
  46289. * Gets wehter the submesh is ready to be used or not.
  46290. * @param defines the list of "defines" to update.
  46291. * @param scene defines the scene the material belongs to.
  46292. * @returns - boolean indicating that the submesh is ready or not.
  46293. */
  46294. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46295. /**
  46296. * Checks to see if a texture is used in the material.
  46297. * @param defines the list of "defines" to update.
  46298. * @param scene defines the scene to the material belongs to.
  46299. */
  46300. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46301. /**
  46302. * Binds the material data.
  46303. * @param uniformBuffer defines the Uniform buffer to fill in.
  46304. * @param scene defines the scene the material belongs to.
  46305. * @param engine defines the engine the material belongs to.
  46306. * @param isFrozen defines wether the material is frozen or not.
  46307. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46308. */
  46309. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46310. /**
  46311. * Unbinds the material from the mesh.
  46312. * @param activeEffect defines the effect that should be unbound from.
  46313. * @returns true if unbound, otherwise false
  46314. */
  46315. unbind(activeEffect: Effect): boolean;
  46316. /**
  46317. * Returns the texture used for refraction or null if none is used.
  46318. * @param scene defines the scene the material belongs to.
  46319. * @returns - Refraction texture if present. If no refraction texture and refraction
  46320. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46321. */
  46322. private _getRefractionTexture;
  46323. /**
  46324. * Returns true if alpha blending should be disabled.
  46325. */
  46326. readonly disableAlphaBlending: boolean;
  46327. /**
  46328. * Fills the list of render target textures.
  46329. * @param renderTargets the list of render targets to update
  46330. */
  46331. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46332. /**
  46333. * Checks to see if a texture is used in the material.
  46334. * @param texture - Base texture to use.
  46335. * @returns - Boolean specifying if a texture is used in the material.
  46336. */
  46337. hasTexture(texture: BaseTexture): boolean;
  46338. /**
  46339. * Gets a boolean indicating that current material needs to register RTT
  46340. * @returns true if this uses a render target otherwise false.
  46341. */
  46342. hasRenderTargetTextures(): boolean;
  46343. /**
  46344. * Returns an array of the actively used textures.
  46345. * @param activeTextures Array of BaseTextures
  46346. */
  46347. getActiveTextures(activeTextures: BaseTexture[]): void;
  46348. /**
  46349. * Returns the animatable textures.
  46350. * @param animatables Array of animatable textures.
  46351. */
  46352. getAnimatables(animatables: IAnimatable[]): void;
  46353. /**
  46354. * Disposes the resources of the material.
  46355. * @param forceDisposeTextures - Forces the disposal of all textures.
  46356. */
  46357. dispose(forceDisposeTextures?: boolean): void;
  46358. /**
  46359. * Get the current class name of the texture useful for serialization or dynamic coding.
  46360. * @returns "PBRSubSurfaceConfiguration"
  46361. */
  46362. getClassName(): string;
  46363. /**
  46364. * Add fallbacks to the effect fallbacks list.
  46365. * @param defines defines the Base texture to use.
  46366. * @param fallbacks defines the current fallback list.
  46367. * @param currentRank defines the current fallback rank.
  46368. * @returns the new fallback rank.
  46369. */
  46370. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46371. /**
  46372. * Add the required uniforms to the current list.
  46373. * @param uniforms defines the current uniform list.
  46374. */
  46375. static AddUniforms(uniforms: string[]): void;
  46376. /**
  46377. * Add the required samplers to the current list.
  46378. * @param samplers defines the current sampler list.
  46379. */
  46380. static AddSamplers(samplers: string[]): void;
  46381. /**
  46382. * Add the required uniforms to the current buffer.
  46383. * @param uniformBuffer defines the current uniform buffer.
  46384. */
  46385. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46386. /**
  46387. * Makes a duplicate of the current configuration into another one.
  46388. * @param configuration define the config where to copy the info
  46389. */
  46390. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46391. /**
  46392. * Serializes this Sub Surface configuration.
  46393. * @returns - An object with the serialized config.
  46394. */
  46395. serialize(): any;
  46396. /**
  46397. * Parses a Sub Surface Configuration from a serialized object.
  46398. * @param source - Serialized object.
  46399. */
  46400. parse(source: any): void;
  46401. }
  46402. }
  46403. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  46404. /** @hidden */
  46405. export var pbrFragmentDeclaration: {
  46406. name: string;
  46407. shader: string;
  46408. };
  46409. }
  46410. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  46411. /** @hidden */
  46412. export var pbrUboDeclaration: {
  46413. name: string;
  46414. shader: string;
  46415. };
  46416. }
  46417. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  46418. /** @hidden */
  46419. export var pbrFragmentExtraDeclaration: {
  46420. name: string;
  46421. shader: string;
  46422. };
  46423. }
  46424. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  46425. /** @hidden */
  46426. export var pbrFragmentSamplersDeclaration: {
  46427. name: string;
  46428. shader: string;
  46429. };
  46430. }
  46431. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  46432. /** @hidden */
  46433. export var pbrHelperFunctions: {
  46434. name: string;
  46435. shader: string;
  46436. };
  46437. }
  46438. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  46439. /** @hidden */
  46440. export var harmonicsFunctions: {
  46441. name: string;
  46442. shader: string;
  46443. };
  46444. }
  46445. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  46446. /** @hidden */
  46447. export var pbrDirectLightingSetupFunctions: {
  46448. name: string;
  46449. shader: string;
  46450. };
  46451. }
  46452. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  46453. /** @hidden */
  46454. export var pbrDirectLightingFalloffFunctions: {
  46455. name: string;
  46456. shader: string;
  46457. };
  46458. }
  46459. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  46460. /** @hidden */
  46461. export var pbrBRDFFunctions: {
  46462. name: string;
  46463. shader: string;
  46464. };
  46465. }
  46466. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  46467. /** @hidden */
  46468. export var pbrDirectLightingFunctions: {
  46469. name: string;
  46470. shader: string;
  46471. };
  46472. }
  46473. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  46474. /** @hidden */
  46475. export var pbrIBLFunctions: {
  46476. name: string;
  46477. shader: string;
  46478. };
  46479. }
  46480. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  46481. /** @hidden */
  46482. export var pbrDebug: {
  46483. name: string;
  46484. shader: string;
  46485. };
  46486. }
  46487. declare module "babylonjs/Shaders/pbr.fragment" {
  46488. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  46489. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46490. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  46491. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46492. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46493. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  46494. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46495. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46496. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46497. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46498. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46499. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  46500. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46501. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46502. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46503. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  46504. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  46505. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  46506. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  46507. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  46508. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  46509. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46510. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46511. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  46512. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  46513. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46514. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  46515. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46516. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  46517. /** @hidden */
  46518. export var pbrPixelShader: {
  46519. name: string;
  46520. shader: string;
  46521. };
  46522. }
  46523. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  46524. /** @hidden */
  46525. export var pbrVertexDeclaration: {
  46526. name: string;
  46527. shader: string;
  46528. };
  46529. }
  46530. declare module "babylonjs/Shaders/pbr.vertex" {
  46531. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  46532. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46533. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46534. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46535. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46536. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46537. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  46538. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46539. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46540. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46541. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46542. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46543. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46544. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46545. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46546. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46547. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46548. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  46549. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46550. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46551. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46552. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  46553. /** @hidden */
  46554. export var pbrVertexShader: {
  46555. name: string;
  46556. shader: string;
  46557. };
  46558. }
  46559. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  46560. import { IAnimatable } from "babylonjs/Misc/tools";
  46561. import { Nullable } from "babylonjs/types";
  46562. import { Scene } from "babylonjs/scene";
  46563. import { Matrix, Color3 } from "babylonjs/Maths/math";
  46564. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46566. import { Mesh } from "babylonjs/Meshes/mesh";
  46567. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  46568. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  46569. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  46570. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  46571. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  46572. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  46573. import { Material } from "babylonjs/Materials/material";
  46574. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  46575. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46576. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46577. import "babylonjs/Shaders/pbr.fragment";
  46578. import "babylonjs/Shaders/pbr.vertex";
  46579. /**
  46580. * Manages the defines for the PBR Material.
  46581. * @hidden
  46582. */
  46583. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46584. PBR: boolean;
  46585. MAINUV1: boolean;
  46586. MAINUV2: boolean;
  46587. UV1: boolean;
  46588. UV2: boolean;
  46589. ALBEDO: boolean;
  46590. ALBEDODIRECTUV: number;
  46591. VERTEXCOLOR: boolean;
  46592. AMBIENT: boolean;
  46593. AMBIENTDIRECTUV: number;
  46594. AMBIENTINGRAYSCALE: boolean;
  46595. OPACITY: boolean;
  46596. VERTEXALPHA: boolean;
  46597. OPACITYDIRECTUV: number;
  46598. OPACITYRGB: boolean;
  46599. ALPHATEST: boolean;
  46600. DEPTHPREPASS: boolean;
  46601. ALPHABLEND: boolean;
  46602. ALPHAFROMALBEDO: boolean;
  46603. ALPHATESTVALUE: string;
  46604. SPECULAROVERALPHA: boolean;
  46605. RADIANCEOVERALPHA: boolean;
  46606. ALPHAFRESNEL: boolean;
  46607. LINEARALPHAFRESNEL: boolean;
  46608. PREMULTIPLYALPHA: boolean;
  46609. EMISSIVE: boolean;
  46610. EMISSIVEDIRECTUV: number;
  46611. REFLECTIVITY: boolean;
  46612. REFLECTIVITYDIRECTUV: number;
  46613. SPECULARTERM: boolean;
  46614. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46615. MICROSURFACEAUTOMATIC: boolean;
  46616. LODBASEDMICROSFURACE: boolean;
  46617. MICROSURFACEMAP: boolean;
  46618. MICROSURFACEMAPDIRECTUV: number;
  46619. METALLICWORKFLOW: boolean;
  46620. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46621. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46622. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46623. AOSTOREINMETALMAPRED: boolean;
  46624. ENVIRONMENTBRDF: boolean;
  46625. ENVIRONMENTBRDF_RGBD: boolean;
  46626. NORMAL: boolean;
  46627. TANGENT: boolean;
  46628. BUMP: boolean;
  46629. BUMPDIRECTUV: number;
  46630. OBJECTSPACE_NORMALMAP: boolean;
  46631. PARALLAX: boolean;
  46632. PARALLAXOCCLUSION: boolean;
  46633. NORMALXYSCALE: boolean;
  46634. LIGHTMAP: boolean;
  46635. LIGHTMAPDIRECTUV: number;
  46636. USELIGHTMAPASSHADOWMAP: boolean;
  46637. GAMMALIGHTMAP: boolean;
  46638. REFLECTION: boolean;
  46639. REFLECTIONMAP_3D: boolean;
  46640. REFLECTIONMAP_SPHERICAL: boolean;
  46641. REFLECTIONMAP_PLANAR: boolean;
  46642. REFLECTIONMAP_CUBIC: boolean;
  46643. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46644. REFLECTIONMAP_PROJECTION: boolean;
  46645. REFLECTIONMAP_SKYBOX: boolean;
  46646. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46647. REFLECTIONMAP_EXPLICIT: boolean;
  46648. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46649. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46650. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46651. INVERTCUBICMAP: boolean;
  46652. USESPHERICALFROMREFLECTIONMAP: boolean;
  46653. USESPHERICALINVERTEX: boolean;
  46654. REFLECTIONMAP_OPPOSITEZ: boolean;
  46655. LODINREFLECTIONALPHA: boolean;
  46656. GAMMAREFLECTION: boolean;
  46657. RGBDREFLECTION: boolean;
  46658. RADIANCEOCCLUSION: boolean;
  46659. HORIZONOCCLUSION: boolean;
  46660. INSTANCES: boolean;
  46661. NUM_BONE_INFLUENCERS: number;
  46662. BonesPerMesh: number;
  46663. BONETEXTURE: boolean;
  46664. NONUNIFORMSCALING: boolean;
  46665. MORPHTARGETS: boolean;
  46666. MORPHTARGETS_NORMAL: boolean;
  46667. MORPHTARGETS_TANGENT: boolean;
  46668. NUM_MORPH_INFLUENCERS: number;
  46669. IMAGEPROCESSING: boolean;
  46670. VIGNETTE: boolean;
  46671. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46672. VIGNETTEBLENDMODEOPAQUE: boolean;
  46673. TONEMAPPING: boolean;
  46674. TONEMAPPING_ACES: boolean;
  46675. CONTRAST: boolean;
  46676. COLORCURVES: boolean;
  46677. COLORGRADING: boolean;
  46678. COLORGRADING3D: boolean;
  46679. SAMPLER3DGREENDEPTH: boolean;
  46680. SAMPLER3DBGRMAP: boolean;
  46681. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46682. EXPOSURE: boolean;
  46683. MULTIVIEW: boolean;
  46684. USEPHYSICALLIGHTFALLOFF: boolean;
  46685. USEGLTFLIGHTFALLOFF: boolean;
  46686. TWOSIDEDLIGHTING: boolean;
  46687. SHADOWFLOAT: boolean;
  46688. CLIPPLANE: boolean;
  46689. CLIPPLANE2: boolean;
  46690. CLIPPLANE3: boolean;
  46691. CLIPPLANE4: boolean;
  46692. POINTSIZE: boolean;
  46693. FOG: boolean;
  46694. LOGARITHMICDEPTH: boolean;
  46695. FORCENORMALFORWARD: boolean;
  46696. SPECULARAA: boolean;
  46697. CLEARCOAT: boolean;
  46698. CLEARCOAT_DEFAULTIOR: boolean;
  46699. CLEARCOAT_TEXTURE: boolean;
  46700. CLEARCOAT_TEXTUREDIRECTUV: number;
  46701. CLEARCOAT_BUMP: boolean;
  46702. CLEARCOAT_BUMPDIRECTUV: number;
  46703. CLEARCOAT_TINT: boolean;
  46704. CLEARCOAT_TINT_TEXTURE: boolean;
  46705. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46706. ANISOTROPIC: boolean;
  46707. ANISOTROPIC_TEXTURE: boolean;
  46708. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46709. BRDF_V_HEIGHT_CORRELATED: boolean;
  46710. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46711. SHEEN: boolean;
  46712. SHEEN_TEXTURE: boolean;
  46713. SHEEN_TEXTUREDIRECTUV: number;
  46714. SHEEN_LINKWITHALBEDO: boolean;
  46715. SUBSURFACE: boolean;
  46716. SS_REFRACTION: boolean;
  46717. SS_TRANSLUCENCY: boolean;
  46718. SS_SCATERRING: boolean;
  46719. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46720. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46721. SS_REFRACTIONMAP_3D: boolean;
  46722. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46723. SS_LODINREFRACTIONALPHA: boolean;
  46724. SS_GAMMAREFRACTION: boolean;
  46725. SS_RGBDREFRACTION: boolean;
  46726. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46727. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46728. UNLIT: boolean;
  46729. DEBUGMODE: number;
  46730. /**
  46731. * Initializes the PBR Material defines.
  46732. */
  46733. constructor();
  46734. /**
  46735. * Resets the PBR Material defines.
  46736. */
  46737. reset(): void;
  46738. }
  46739. /**
  46740. * The Physically based material base class of BJS.
  46741. *
  46742. * This offers the main features of a standard PBR material.
  46743. * For more information, please refer to the documentation :
  46744. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46745. */
  46746. export abstract class PBRBaseMaterial extends PushMaterial {
  46747. /**
  46748. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46749. */
  46750. static readonly PBRMATERIAL_OPAQUE: number;
  46751. /**
  46752. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46753. */
  46754. static readonly PBRMATERIAL_ALPHATEST: number;
  46755. /**
  46756. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46757. */
  46758. static readonly PBRMATERIAL_ALPHABLEND: number;
  46759. /**
  46760. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46761. * They are also discarded below the alpha cutoff threshold to improve performances.
  46762. */
  46763. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46764. /**
  46765. * Defines the default value of how much AO map is occluding the analytical lights
  46766. * (point spot...).
  46767. */
  46768. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46769. /**
  46770. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46771. */
  46772. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46773. /**
  46774. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46775. * to enhance interoperability with other engines.
  46776. */
  46777. static readonly LIGHTFALLOFF_GLTF: number;
  46778. /**
  46779. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46780. * to enhance interoperability with other materials.
  46781. */
  46782. static readonly LIGHTFALLOFF_STANDARD: number;
  46783. /**
  46784. * Intensity of the direct lights e.g. the four lights available in your scene.
  46785. * This impacts both the direct diffuse and specular highlights.
  46786. */
  46787. protected _directIntensity: number;
  46788. /**
  46789. * Intensity of the emissive part of the material.
  46790. * This helps controlling the emissive effect without modifying the emissive color.
  46791. */
  46792. protected _emissiveIntensity: number;
  46793. /**
  46794. * Intensity of the environment e.g. how much the environment will light the object
  46795. * either through harmonics for rough material or through the refelction for shiny ones.
  46796. */
  46797. protected _environmentIntensity: number;
  46798. /**
  46799. * This is a special control allowing the reduction of the specular highlights coming from the
  46800. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46801. */
  46802. protected _specularIntensity: number;
  46803. /**
  46804. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46805. */
  46806. private _lightingInfos;
  46807. /**
  46808. * Debug Control allowing disabling the bump map on this material.
  46809. */
  46810. protected _disableBumpMap: boolean;
  46811. /**
  46812. * AKA Diffuse Texture in standard nomenclature.
  46813. */
  46814. protected _albedoTexture: Nullable<BaseTexture>;
  46815. /**
  46816. * AKA Occlusion Texture in other nomenclature.
  46817. */
  46818. protected _ambientTexture: Nullable<BaseTexture>;
  46819. /**
  46820. * AKA Occlusion Texture Intensity in other nomenclature.
  46821. */
  46822. protected _ambientTextureStrength: number;
  46823. /**
  46824. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46825. * 1 means it completely occludes it
  46826. * 0 mean it has no impact
  46827. */
  46828. protected _ambientTextureImpactOnAnalyticalLights: number;
  46829. /**
  46830. * Stores the alpha values in a texture.
  46831. */
  46832. protected _opacityTexture: Nullable<BaseTexture>;
  46833. /**
  46834. * Stores the reflection values in a texture.
  46835. */
  46836. protected _reflectionTexture: Nullable<BaseTexture>;
  46837. /**
  46838. * Stores the emissive values in a texture.
  46839. */
  46840. protected _emissiveTexture: Nullable<BaseTexture>;
  46841. /**
  46842. * AKA Specular texture in other nomenclature.
  46843. */
  46844. protected _reflectivityTexture: Nullable<BaseTexture>;
  46845. /**
  46846. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46847. */
  46848. protected _metallicTexture: Nullable<BaseTexture>;
  46849. /**
  46850. * Specifies the metallic scalar of the metallic/roughness workflow.
  46851. * Can also be used to scale the metalness values of the metallic texture.
  46852. */
  46853. protected _metallic: Nullable<number>;
  46854. /**
  46855. * Specifies the roughness scalar of the metallic/roughness workflow.
  46856. * Can also be used to scale the roughness values of the metallic texture.
  46857. */
  46858. protected _roughness: Nullable<number>;
  46859. /**
  46860. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46861. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46862. */
  46863. protected _microSurfaceTexture: Nullable<BaseTexture>;
  46864. /**
  46865. * Stores surface normal data used to displace a mesh in a texture.
  46866. */
  46867. protected _bumpTexture: Nullable<BaseTexture>;
  46868. /**
  46869. * Stores the pre-calculated light information of a mesh in a texture.
  46870. */
  46871. protected _lightmapTexture: Nullable<BaseTexture>;
  46872. /**
  46873. * The color of a material in ambient lighting.
  46874. */
  46875. protected _ambientColor: Color3;
  46876. /**
  46877. * AKA Diffuse Color in other nomenclature.
  46878. */
  46879. protected _albedoColor: Color3;
  46880. /**
  46881. * AKA Specular Color in other nomenclature.
  46882. */
  46883. protected _reflectivityColor: Color3;
  46884. /**
  46885. * The color applied when light is reflected from a material.
  46886. */
  46887. protected _reflectionColor: Color3;
  46888. /**
  46889. * The color applied when light is emitted from a material.
  46890. */
  46891. protected _emissiveColor: Color3;
  46892. /**
  46893. * AKA Glossiness in other nomenclature.
  46894. */
  46895. protected _microSurface: number;
  46896. /**
  46897. * Specifies that the material will use the light map as a show map.
  46898. */
  46899. protected _useLightmapAsShadowmap: boolean;
  46900. /**
  46901. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46902. * makes the reflect vector face the model (under horizon).
  46903. */
  46904. protected _useHorizonOcclusion: boolean;
  46905. /**
  46906. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46907. * too much the area relying on ambient texture to define their ambient occlusion.
  46908. */
  46909. protected _useRadianceOcclusion: boolean;
  46910. /**
  46911. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46912. */
  46913. protected _useAlphaFromAlbedoTexture: boolean;
  46914. /**
  46915. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46916. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46917. */
  46918. protected _useSpecularOverAlpha: boolean;
  46919. /**
  46920. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46921. */
  46922. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46923. /**
  46924. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46925. */
  46926. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46927. /**
  46928. * Specifies if the metallic texture contains the roughness information in its green channel.
  46929. */
  46930. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46931. /**
  46932. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46933. */
  46934. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46935. /**
  46936. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46937. */
  46938. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46939. /**
  46940. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46941. */
  46942. protected _useAmbientInGrayScale: boolean;
  46943. /**
  46944. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46945. * The material will try to infer what glossiness each pixel should be.
  46946. */
  46947. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46948. /**
  46949. * Defines the falloff type used in this material.
  46950. * It by default is Physical.
  46951. */
  46952. protected _lightFalloff: number;
  46953. /**
  46954. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46955. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46956. */
  46957. protected _useRadianceOverAlpha: boolean;
  46958. /**
  46959. * Allows using an object space normal map (instead of tangent space).
  46960. */
  46961. protected _useObjectSpaceNormalMap: boolean;
  46962. /**
  46963. * Allows using the bump map in parallax mode.
  46964. */
  46965. protected _useParallax: boolean;
  46966. /**
  46967. * Allows using the bump map in parallax occlusion mode.
  46968. */
  46969. protected _useParallaxOcclusion: boolean;
  46970. /**
  46971. * Controls the scale bias of the parallax mode.
  46972. */
  46973. protected _parallaxScaleBias: number;
  46974. /**
  46975. * If sets to true, disables all the lights affecting the material.
  46976. */
  46977. protected _disableLighting: boolean;
  46978. /**
  46979. * Number of Simultaneous lights allowed on the material.
  46980. */
  46981. protected _maxSimultaneousLights: number;
  46982. /**
  46983. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46984. */
  46985. protected _invertNormalMapX: boolean;
  46986. /**
  46987. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46988. */
  46989. protected _invertNormalMapY: boolean;
  46990. /**
  46991. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46992. */
  46993. protected _twoSidedLighting: boolean;
  46994. /**
  46995. * Defines the alpha limits in alpha test mode.
  46996. */
  46997. protected _alphaCutOff: number;
  46998. /**
  46999. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47000. */
  47001. protected _forceAlphaTest: boolean;
  47002. /**
  47003. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47004. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47005. */
  47006. protected _useAlphaFresnel: boolean;
  47007. /**
  47008. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47009. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47010. */
  47011. protected _useLinearAlphaFresnel: boolean;
  47012. /**
  47013. * The transparency mode of the material.
  47014. */
  47015. protected _transparencyMode: Nullable<number>;
  47016. /**
  47017. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47018. * from cos thetav and roughness:
  47019. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47020. */
  47021. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47022. /**
  47023. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47024. */
  47025. protected _forceIrradianceInFragment: boolean;
  47026. /**
  47027. * Force normal to face away from face.
  47028. */
  47029. protected _forceNormalForward: boolean;
  47030. /**
  47031. * Enables specular anti aliasing in the PBR shader.
  47032. * It will both interacts on the Geometry for analytical and IBL lighting.
  47033. * It also prefilter the roughness map based on the bump values.
  47034. */
  47035. protected _enableSpecularAntiAliasing: boolean;
  47036. /**
  47037. * Default configuration related to image processing available in the PBR Material.
  47038. */
  47039. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47040. /**
  47041. * Keep track of the image processing observer to allow dispose and replace.
  47042. */
  47043. private _imageProcessingObserver;
  47044. /**
  47045. * Attaches a new image processing configuration to the PBR Material.
  47046. * @param configuration
  47047. */
  47048. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47049. /**
  47050. * Stores the available render targets.
  47051. */
  47052. private _renderTargets;
  47053. /**
  47054. * Sets the global ambient color for the material used in lighting calculations.
  47055. */
  47056. private _globalAmbientColor;
  47057. /**
  47058. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47059. */
  47060. private _useLogarithmicDepth;
  47061. /**
  47062. * If set to true, no lighting calculations will be applied.
  47063. */
  47064. private _unlit;
  47065. private _debugMode;
  47066. /**
  47067. * @hidden
  47068. * This is reserved for the inspector.
  47069. * Defines the material debug mode.
  47070. * It helps seeing only some components of the material while troubleshooting.
  47071. */
  47072. debugMode: number;
  47073. /**
  47074. * @hidden
  47075. * This is reserved for the inspector.
  47076. * Specify from where on screen the debug mode should start.
  47077. * The value goes from -1 (full screen) to 1 (not visible)
  47078. * It helps with side by side comparison against the final render
  47079. * This defaults to -1
  47080. */
  47081. private debugLimit;
  47082. /**
  47083. * @hidden
  47084. * This is reserved for the inspector.
  47085. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47086. * You can use the factor to better multiply the final value.
  47087. */
  47088. private debugFactor;
  47089. /**
  47090. * Defines the clear coat layer parameters for the material.
  47091. */
  47092. readonly clearCoat: PBRClearCoatConfiguration;
  47093. /**
  47094. * Defines the anisotropic parameters for the material.
  47095. */
  47096. readonly anisotropy: PBRAnisotropicConfiguration;
  47097. /**
  47098. * Defines the BRDF parameters for the material.
  47099. */
  47100. readonly brdf: PBRBRDFConfiguration;
  47101. /**
  47102. * Defines the Sheen parameters for the material.
  47103. */
  47104. readonly sheen: PBRSheenConfiguration;
  47105. /**
  47106. * Defines the SubSurface parameters for the material.
  47107. */
  47108. readonly subSurface: PBRSubSurfaceConfiguration;
  47109. /**
  47110. * Custom callback helping to override the default shader used in the material.
  47111. */
  47112. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47113. /**
  47114. * Instantiates a new PBRMaterial instance.
  47115. *
  47116. * @param name The material name
  47117. * @param scene The scene the material will be use in.
  47118. */
  47119. constructor(name: string, scene: Scene);
  47120. /**
  47121. * Gets a boolean indicating that current material needs to register RTT
  47122. */
  47123. readonly hasRenderTargetTextures: boolean;
  47124. /**
  47125. * Gets the name of the material class.
  47126. */
  47127. getClassName(): string;
  47128. /**
  47129. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47130. */
  47131. /**
  47132. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47133. */
  47134. useLogarithmicDepth: boolean;
  47135. /**
  47136. * Gets the current transparency mode.
  47137. */
  47138. /**
  47139. * Sets the transparency mode of the material.
  47140. *
  47141. * | Value | Type | Description |
  47142. * | ----- | ----------------------------------- | ----------- |
  47143. * | 0 | OPAQUE | |
  47144. * | 1 | ALPHATEST | |
  47145. * | 2 | ALPHABLEND | |
  47146. * | 3 | ALPHATESTANDBLEND | |
  47147. *
  47148. */
  47149. transparencyMode: Nullable<number>;
  47150. /**
  47151. * Returns true if alpha blending should be disabled.
  47152. */
  47153. private readonly _disableAlphaBlending;
  47154. /**
  47155. * Specifies whether or not this material should be rendered in alpha blend mode.
  47156. */
  47157. needAlphaBlending(): boolean;
  47158. /**
  47159. * Specifies if the mesh will require alpha blending.
  47160. * @param mesh - BJS mesh.
  47161. */
  47162. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47163. /**
  47164. * Specifies whether or not this material should be rendered in alpha test mode.
  47165. */
  47166. needAlphaTesting(): boolean;
  47167. /**
  47168. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47169. */
  47170. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47171. /**
  47172. * Gets the texture used for the alpha test.
  47173. */
  47174. getAlphaTestTexture(): Nullable<BaseTexture>;
  47175. /**
  47176. * Specifies that the submesh is ready to be used.
  47177. * @param mesh - BJS mesh.
  47178. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47179. * @param useInstances - Specifies that instances should be used.
  47180. * @returns - boolean indicating that the submesh is ready or not.
  47181. */
  47182. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47183. /**
  47184. * Specifies if the material uses metallic roughness workflow.
  47185. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47186. */
  47187. isMetallicWorkflow(): boolean;
  47188. private _prepareEffect;
  47189. private _prepareDefines;
  47190. /**
  47191. * Force shader compilation
  47192. */
  47193. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47194. clipPlane: boolean;
  47195. }>): void;
  47196. /**
  47197. * Initializes the uniform buffer layout for the shader.
  47198. */
  47199. buildUniformLayout(): void;
  47200. /**
  47201. * Unbinds the material from the mesh
  47202. */
  47203. unbind(): void;
  47204. /**
  47205. * Binds the submesh data.
  47206. * @param world - The world matrix.
  47207. * @param mesh - The BJS mesh.
  47208. * @param subMesh - A submesh of the BJS mesh.
  47209. */
  47210. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47211. /**
  47212. * Returns the animatable textures.
  47213. * @returns - Array of animatable textures.
  47214. */
  47215. getAnimatables(): IAnimatable[];
  47216. /**
  47217. * Returns the texture used for reflections.
  47218. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47219. */
  47220. private _getReflectionTexture;
  47221. /**
  47222. * Returns an array of the actively used textures.
  47223. * @returns - Array of BaseTextures
  47224. */
  47225. getActiveTextures(): BaseTexture[];
  47226. /**
  47227. * Checks to see if a texture is used in the material.
  47228. * @param texture - Base texture to use.
  47229. * @returns - Boolean specifying if a texture is used in the material.
  47230. */
  47231. hasTexture(texture: BaseTexture): boolean;
  47232. /**
  47233. * Disposes the resources of the material.
  47234. * @param forceDisposeEffect - Forces the disposal of effects.
  47235. * @param forceDisposeTextures - Forces the disposal of all textures.
  47236. */
  47237. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47238. }
  47239. }
  47240. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  47241. import { Nullable } from "babylonjs/types";
  47242. import { Scene } from "babylonjs/scene";
  47243. import { Color3 } from "babylonjs/Maths/math";
  47244. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47245. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47246. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47247. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47248. /**
  47249. * The Physically based material of BJS.
  47250. *
  47251. * This offers the main features of a standard PBR material.
  47252. * For more information, please refer to the documentation :
  47253. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  47254. */
  47255. export class PBRMaterial extends PBRBaseMaterial {
  47256. /**
  47257. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47258. */
  47259. static readonly PBRMATERIAL_OPAQUE: number;
  47260. /**
  47261. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47262. */
  47263. static readonly PBRMATERIAL_ALPHATEST: number;
  47264. /**
  47265. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47266. */
  47267. static readonly PBRMATERIAL_ALPHABLEND: number;
  47268. /**
  47269. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47270. * They are also discarded below the alpha cutoff threshold to improve performances.
  47271. */
  47272. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47273. /**
  47274. * Defines the default value of how much AO map is occluding the analytical lights
  47275. * (point spot...).
  47276. */
  47277. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47278. /**
  47279. * Intensity of the direct lights e.g. the four lights available in your scene.
  47280. * This impacts both the direct diffuse and specular highlights.
  47281. */
  47282. directIntensity: number;
  47283. /**
  47284. * Intensity of the emissive part of the material.
  47285. * This helps controlling the emissive effect without modifying the emissive color.
  47286. */
  47287. emissiveIntensity: number;
  47288. /**
  47289. * Intensity of the environment e.g. how much the environment will light the object
  47290. * either through harmonics for rough material or through the refelction for shiny ones.
  47291. */
  47292. environmentIntensity: number;
  47293. /**
  47294. * This is a special control allowing the reduction of the specular highlights coming from the
  47295. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47296. */
  47297. specularIntensity: number;
  47298. /**
  47299. * Debug Control allowing disabling the bump map on this material.
  47300. */
  47301. disableBumpMap: boolean;
  47302. /**
  47303. * AKA Diffuse Texture in standard nomenclature.
  47304. */
  47305. albedoTexture: BaseTexture;
  47306. /**
  47307. * AKA Occlusion Texture in other nomenclature.
  47308. */
  47309. ambientTexture: BaseTexture;
  47310. /**
  47311. * AKA Occlusion Texture Intensity in other nomenclature.
  47312. */
  47313. ambientTextureStrength: number;
  47314. /**
  47315. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47316. * 1 means it completely occludes it
  47317. * 0 mean it has no impact
  47318. */
  47319. ambientTextureImpactOnAnalyticalLights: number;
  47320. /**
  47321. * Stores the alpha values in a texture.
  47322. */
  47323. opacityTexture: BaseTexture;
  47324. /**
  47325. * Stores the reflection values in a texture.
  47326. */
  47327. reflectionTexture: Nullable<BaseTexture>;
  47328. /**
  47329. * Stores the emissive values in a texture.
  47330. */
  47331. emissiveTexture: BaseTexture;
  47332. /**
  47333. * AKA Specular texture in other nomenclature.
  47334. */
  47335. reflectivityTexture: BaseTexture;
  47336. /**
  47337. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47338. */
  47339. metallicTexture: BaseTexture;
  47340. /**
  47341. * Specifies the metallic scalar of the metallic/roughness workflow.
  47342. * Can also be used to scale the metalness values of the metallic texture.
  47343. */
  47344. metallic: Nullable<number>;
  47345. /**
  47346. * Specifies the roughness scalar of the metallic/roughness workflow.
  47347. * Can also be used to scale the roughness values of the metallic texture.
  47348. */
  47349. roughness: Nullable<number>;
  47350. /**
  47351. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47352. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47353. */
  47354. microSurfaceTexture: BaseTexture;
  47355. /**
  47356. * Stores surface normal data used to displace a mesh in a texture.
  47357. */
  47358. bumpTexture: BaseTexture;
  47359. /**
  47360. * Stores the pre-calculated light information of a mesh in a texture.
  47361. */
  47362. lightmapTexture: BaseTexture;
  47363. /**
  47364. * Stores the refracted light information in a texture.
  47365. */
  47366. refractionTexture: Nullable<BaseTexture>;
  47367. /**
  47368. * The color of a material in ambient lighting.
  47369. */
  47370. ambientColor: Color3;
  47371. /**
  47372. * AKA Diffuse Color in other nomenclature.
  47373. */
  47374. albedoColor: Color3;
  47375. /**
  47376. * AKA Specular Color in other nomenclature.
  47377. */
  47378. reflectivityColor: Color3;
  47379. /**
  47380. * The color reflected from the material.
  47381. */
  47382. reflectionColor: Color3;
  47383. /**
  47384. * The color emitted from the material.
  47385. */
  47386. emissiveColor: Color3;
  47387. /**
  47388. * AKA Glossiness in other nomenclature.
  47389. */
  47390. microSurface: number;
  47391. /**
  47392. * source material index of refraction (IOR)' / 'destination material IOR.
  47393. */
  47394. indexOfRefraction: number;
  47395. /**
  47396. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47397. */
  47398. invertRefractionY: boolean;
  47399. /**
  47400. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47401. * Materials half opaque for instance using refraction could benefit from this control.
  47402. */
  47403. linkRefractionWithTransparency: boolean;
  47404. /**
  47405. * If true, the light map contains occlusion information instead of lighting info.
  47406. */
  47407. useLightmapAsShadowmap: boolean;
  47408. /**
  47409. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47410. */
  47411. useAlphaFromAlbedoTexture: boolean;
  47412. /**
  47413. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47414. */
  47415. forceAlphaTest: boolean;
  47416. /**
  47417. * Defines the alpha limits in alpha test mode.
  47418. */
  47419. alphaCutOff: number;
  47420. /**
  47421. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47422. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47423. */
  47424. useSpecularOverAlpha: boolean;
  47425. /**
  47426. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47427. */
  47428. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47429. /**
  47430. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47431. */
  47432. useRoughnessFromMetallicTextureAlpha: boolean;
  47433. /**
  47434. * Specifies if the metallic texture contains the roughness information in its green channel.
  47435. */
  47436. useRoughnessFromMetallicTextureGreen: boolean;
  47437. /**
  47438. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47439. */
  47440. useMetallnessFromMetallicTextureBlue: boolean;
  47441. /**
  47442. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47443. */
  47444. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47445. /**
  47446. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47447. */
  47448. useAmbientInGrayScale: boolean;
  47449. /**
  47450. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47451. * The material will try to infer what glossiness each pixel should be.
  47452. */
  47453. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47454. /**
  47455. * BJS is using an harcoded light falloff based on a manually sets up range.
  47456. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47457. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47458. */
  47459. /**
  47460. * BJS is using an harcoded light falloff based on a manually sets up range.
  47461. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47462. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47463. */
  47464. usePhysicalLightFalloff: boolean;
  47465. /**
  47466. * In order to support the falloff compatibility with gltf, a special mode has been added
  47467. * to reproduce the gltf light falloff.
  47468. */
  47469. /**
  47470. * In order to support the falloff compatibility with gltf, a special mode has been added
  47471. * to reproduce the gltf light falloff.
  47472. */
  47473. useGLTFLightFalloff: boolean;
  47474. /**
  47475. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47476. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47477. */
  47478. useRadianceOverAlpha: boolean;
  47479. /**
  47480. * Allows using an object space normal map (instead of tangent space).
  47481. */
  47482. useObjectSpaceNormalMap: boolean;
  47483. /**
  47484. * Allows using the bump map in parallax mode.
  47485. */
  47486. useParallax: boolean;
  47487. /**
  47488. * Allows using the bump map in parallax occlusion mode.
  47489. */
  47490. useParallaxOcclusion: boolean;
  47491. /**
  47492. * Controls the scale bias of the parallax mode.
  47493. */
  47494. parallaxScaleBias: number;
  47495. /**
  47496. * If sets to true, disables all the lights affecting the material.
  47497. */
  47498. disableLighting: boolean;
  47499. /**
  47500. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47501. */
  47502. forceIrradianceInFragment: boolean;
  47503. /**
  47504. * Number of Simultaneous lights allowed on the material.
  47505. */
  47506. maxSimultaneousLights: number;
  47507. /**
  47508. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47509. */
  47510. invertNormalMapX: boolean;
  47511. /**
  47512. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47513. */
  47514. invertNormalMapY: boolean;
  47515. /**
  47516. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47517. */
  47518. twoSidedLighting: boolean;
  47519. /**
  47520. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47521. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47522. */
  47523. useAlphaFresnel: boolean;
  47524. /**
  47525. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47526. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47527. */
  47528. useLinearAlphaFresnel: boolean;
  47529. /**
  47530. * Let user defines the brdf lookup texture used for IBL.
  47531. * A default 8bit version is embedded but you could point at :
  47532. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  47533. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47534. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47535. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47536. */
  47537. environmentBRDFTexture: Nullable<BaseTexture>;
  47538. /**
  47539. * Force normal to face away from face.
  47540. */
  47541. forceNormalForward: boolean;
  47542. /**
  47543. * Enables specular anti aliasing in the PBR shader.
  47544. * It will both interacts on the Geometry for analytical and IBL lighting.
  47545. * It also prefilter the roughness map based on the bump values.
  47546. */
  47547. enableSpecularAntiAliasing: boolean;
  47548. /**
  47549. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47550. * makes the reflect vector face the model (under horizon).
  47551. */
  47552. useHorizonOcclusion: boolean;
  47553. /**
  47554. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47555. * too much the area relying on ambient texture to define their ambient occlusion.
  47556. */
  47557. useRadianceOcclusion: boolean;
  47558. /**
  47559. * If set to true, no lighting calculations will be applied.
  47560. */
  47561. unlit: boolean;
  47562. /**
  47563. * Gets the image processing configuration used either in this material.
  47564. */
  47565. /**
  47566. * Sets the Default image processing configuration used either in the this material.
  47567. *
  47568. * If sets to null, the scene one is in use.
  47569. */
  47570. imageProcessingConfiguration: ImageProcessingConfiguration;
  47571. /**
  47572. * Gets wether the color curves effect is enabled.
  47573. */
  47574. /**
  47575. * Sets wether the color curves effect is enabled.
  47576. */
  47577. cameraColorCurvesEnabled: boolean;
  47578. /**
  47579. * Gets wether the color grading effect is enabled.
  47580. */
  47581. /**
  47582. * Gets wether the color grading effect is enabled.
  47583. */
  47584. cameraColorGradingEnabled: boolean;
  47585. /**
  47586. * Gets wether tonemapping is enabled or not.
  47587. */
  47588. /**
  47589. * Sets wether tonemapping is enabled or not
  47590. */
  47591. cameraToneMappingEnabled: boolean;
  47592. /**
  47593. * The camera exposure used on this material.
  47594. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47595. * This corresponds to a photographic exposure.
  47596. */
  47597. /**
  47598. * The camera exposure used on this material.
  47599. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47600. * This corresponds to a photographic exposure.
  47601. */
  47602. cameraExposure: number;
  47603. /**
  47604. * Gets The camera contrast used on this material.
  47605. */
  47606. /**
  47607. * Sets The camera contrast used on this material.
  47608. */
  47609. cameraContrast: number;
  47610. /**
  47611. * Gets the Color Grading 2D Lookup Texture.
  47612. */
  47613. /**
  47614. * Sets the Color Grading 2D Lookup Texture.
  47615. */
  47616. cameraColorGradingTexture: Nullable<BaseTexture>;
  47617. /**
  47618. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47619. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47620. * 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;
  47621. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47622. */
  47623. /**
  47624. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47625. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47626. * 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;
  47627. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47628. */
  47629. cameraColorCurves: Nullable<ColorCurves>;
  47630. /**
  47631. * Instantiates a new PBRMaterial instance.
  47632. *
  47633. * @param name The material name
  47634. * @param scene The scene the material will be use in.
  47635. */
  47636. constructor(name: string, scene: Scene);
  47637. /**
  47638. * Returns the name of this material class.
  47639. */
  47640. getClassName(): string;
  47641. /**
  47642. * Makes a duplicate of the current material.
  47643. * @param name - name to use for the new material.
  47644. */
  47645. clone(name: string): PBRMaterial;
  47646. /**
  47647. * Serializes this PBR Material.
  47648. * @returns - An object with the serialized material.
  47649. */
  47650. serialize(): any;
  47651. /**
  47652. * Parses a PBR Material from a serialized object.
  47653. * @param source - Serialized object.
  47654. * @param scene - BJS scene instance.
  47655. * @param rootUrl - url for the scene object
  47656. * @returns - PBRMaterial
  47657. */
  47658. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47659. }
  47660. }
  47661. declare module "babylonjs/Misc/dds" {
  47662. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47663. import { Engine } from "babylonjs/Engines/engine";
  47664. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47665. import { Nullable } from "babylonjs/types";
  47666. import { Scene } from "babylonjs/scene";
  47667. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  47668. /**
  47669. * Direct draw surface info
  47670. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47671. */
  47672. export interface DDSInfo {
  47673. /**
  47674. * Width of the texture
  47675. */
  47676. width: number;
  47677. /**
  47678. * Width of the texture
  47679. */
  47680. height: number;
  47681. /**
  47682. * Number of Mipmaps for the texture
  47683. * @see https://en.wikipedia.org/wiki/Mipmap
  47684. */
  47685. mipmapCount: number;
  47686. /**
  47687. * If the textures format is a known fourCC format
  47688. * @see https://www.fourcc.org/
  47689. */
  47690. isFourCC: boolean;
  47691. /**
  47692. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47693. */
  47694. isRGB: boolean;
  47695. /**
  47696. * If the texture is a lumincance format
  47697. */
  47698. isLuminance: boolean;
  47699. /**
  47700. * If this is a cube texture
  47701. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47702. */
  47703. isCube: boolean;
  47704. /**
  47705. * If the texture is a compressed format eg. FOURCC_DXT1
  47706. */
  47707. isCompressed: boolean;
  47708. /**
  47709. * The dxgiFormat of the texture
  47710. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47711. */
  47712. dxgiFormat: number;
  47713. /**
  47714. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47715. */
  47716. textureType: number;
  47717. /**
  47718. * Sphericle polynomial created for the dds texture
  47719. */
  47720. sphericalPolynomial?: SphericalPolynomial;
  47721. }
  47722. /**
  47723. * Class used to provide DDS decompression tools
  47724. */
  47725. export class DDSTools {
  47726. /**
  47727. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47728. */
  47729. static StoreLODInAlphaChannel: boolean;
  47730. /**
  47731. * Gets DDS information from an array buffer
  47732. * @param arrayBuffer defines the array buffer to read data from
  47733. * @returns the DDS information
  47734. */
  47735. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47736. private static _FloatView;
  47737. private static _Int32View;
  47738. private static _ToHalfFloat;
  47739. private static _FromHalfFloat;
  47740. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47741. private static _GetHalfFloatRGBAArrayBuffer;
  47742. private static _GetFloatRGBAArrayBuffer;
  47743. private static _GetFloatAsUIntRGBAArrayBuffer;
  47744. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47745. private static _GetRGBAArrayBuffer;
  47746. private static _ExtractLongWordOrder;
  47747. private static _GetRGBArrayBuffer;
  47748. private static _GetLuminanceArrayBuffer;
  47749. /**
  47750. * Uploads DDS Levels to a Babylon Texture
  47751. * @hidden
  47752. */
  47753. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47754. }
  47755. module "babylonjs/Engines/engine" {
  47756. interface Engine {
  47757. /**
  47758. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47759. * @param rootUrl defines the url where the file to load is located
  47760. * @param scene defines the current scene
  47761. * @param lodScale defines scale to apply to the mip map selection
  47762. * @param lodOffset defines offset to apply to the mip map selection
  47763. * @param onLoad defines an optional callback raised when the texture is loaded
  47764. * @param onError defines an optional callback raised if there is an issue to load the texture
  47765. * @param format defines the format of the data
  47766. * @param forcedExtension defines the extension to use to pick the right loader
  47767. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47768. * @returns the cube texture as an InternalTexture
  47769. */
  47770. 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;
  47771. }
  47772. }
  47773. }
  47774. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47775. import { Nullable } from "babylonjs/types";
  47776. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47777. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47778. /**
  47779. * Implementation of the DDS Texture Loader.
  47780. * @hidden
  47781. */
  47782. export class _DDSTextureLoader implements IInternalTextureLoader {
  47783. /**
  47784. * Defines wether the loader supports cascade loading the different faces.
  47785. */
  47786. readonly supportCascades: boolean;
  47787. /**
  47788. * This returns if the loader support the current file information.
  47789. * @param extension defines the file extension of the file being loaded
  47790. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47791. * @param fallback defines the fallback internal texture if any
  47792. * @param isBase64 defines whether the texture is encoded as a base64
  47793. * @param isBuffer defines whether the texture data are stored as a buffer
  47794. * @returns true if the loader can load the specified file
  47795. */
  47796. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47797. /**
  47798. * Transform the url before loading if required.
  47799. * @param rootUrl the url of the texture
  47800. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47801. * @returns the transformed texture
  47802. */
  47803. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47804. /**
  47805. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47806. * @param rootUrl the url of the texture
  47807. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47808. * @returns the fallback texture
  47809. */
  47810. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47811. /**
  47812. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47813. * @param data contains the texture data
  47814. * @param texture defines the BabylonJS internal texture
  47815. * @param createPolynomials will be true if polynomials have been requested
  47816. * @param onLoad defines the callback to trigger once the texture is ready
  47817. * @param onError defines the callback to trigger in case of error
  47818. */
  47819. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47820. /**
  47821. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47822. * @param data contains the texture data
  47823. * @param texture defines the BabylonJS internal texture
  47824. * @param callback defines the method to call once ready to upload
  47825. */
  47826. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47827. }
  47828. }
  47829. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47830. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47831. /** @hidden */
  47832. export var rgbdEncodePixelShader: {
  47833. name: string;
  47834. shader: string;
  47835. };
  47836. }
  47837. declare module "babylonjs/Misc/environmentTextureTools" {
  47838. import { Nullable } from "babylonjs/types";
  47839. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47840. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47841. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47842. import "babylonjs/Engines/Extensions/engine.renderTarget";
  47843. import "babylonjs/Shaders/rgbdEncode.fragment";
  47844. import "babylonjs/Shaders/rgbdDecode.fragment";
  47845. /**
  47846. * Raw texture data and descriptor sufficient for WebGL texture upload
  47847. */
  47848. export interface EnvironmentTextureInfo {
  47849. /**
  47850. * Version of the environment map
  47851. */
  47852. version: number;
  47853. /**
  47854. * Width of image
  47855. */
  47856. width: number;
  47857. /**
  47858. * Irradiance information stored in the file.
  47859. */
  47860. irradiance: any;
  47861. /**
  47862. * Specular information stored in the file.
  47863. */
  47864. specular: any;
  47865. }
  47866. /**
  47867. * Sets of helpers addressing the serialization and deserialization of environment texture
  47868. * stored in a BabylonJS env file.
  47869. * Those files are usually stored as .env files.
  47870. */
  47871. export class EnvironmentTextureTools {
  47872. /**
  47873. * Magic number identifying the env file.
  47874. */
  47875. private static _MagicBytes;
  47876. /**
  47877. * Gets the environment info from an env file.
  47878. * @param data The array buffer containing the .env bytes.
  47879. * @returns the environment file info (the json header) if successfully parsed.
  47880. */
  47881. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47882. /**
  47883. * Creates an environment texture from a loaded cube texture.
  47884. * @param texture defines the cube texture to convert in env file
  47885. * @return a promise containing the environment data if succesfull.
  47886. */
  47887. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47888. /**
  47889. * Creates a JSON representation of the spherical data.
  47890. * @param texture defines the texture containing the polynomials
  47891. * @return the JSON representation of the spherical info
  47892. */
  47893. private static _CreateEnvTextureIrradiance;
  47894. /**
  47895. * Uploads the texture info contained in the env file to the GPU.
  47896. * @param texture defines the internal texture to upload to
  47897. * @param arrayBuffer defines the buffer cotaining the data to load
  47898. * @param info defines the texture info retrieved through the GetEnvInfo method
  47899. * @returns a promise
  47900. */
  47901. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47902. /**
  47903. * Uploads the levels of image data to the GPU.
  47904. * @param texture defines the internal texture to upload to
  47905. * @param imageData defines the array buffer views of image data [mipmap][face]
  47906. * @returns a promise
  47907. */
  47908. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47909. /**
  47910. * Uploads spherical polynomials information to the texture.
  47911. * @param texture defines the texture we are trying to upload the information to
  47912. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47913. */
  47914. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47915. /** @hidden */
  47916. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47917. }
  47918. }
  47919. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  47920. import { Nullable } from "babylonjs/types";
  47921. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47922. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47923. /**
  47924. * Implementation of the ENV Texture Loader.
  47925. * @hidden
  47926. */
  47927. export class _ENVTextureLoader implements IInternalTextureLoader {
  47928. /**
  47929. * Defines wether the loader supports cascade loading the different faces.
  47930. */
  47931. readonly supportCascades: boolean;
  47932. /**
  47933. * This returns if the loader support the current file information.
  47934. * @param extension defines the file extension of the file being loaded
  47935. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47936. * @param fallback defines the fallback internal texture if any
  47937. * @param isBase64 defines whether the texture is encoded as a base64
  47938. * @param isBuffer defines whether the texture data are stored as a buffer
  47939. * @returns true if the loader can load the specified file
  47940. */
  47941. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47942. /**
  47943. * Transform the url before loading if required.
  47944. * @param rootUrl the url of the texture
  47945. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47946. * @returns the transformed texture
  47947. */
  47948. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47949. /**
  47950. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47951. * @param rootUrl the url of the texture
  47952. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47953. * @returns the fallback texture
  47954. */
  47955. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47956. /**
  47957. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47958. * @param data contains the texture data
  47959. * @param texture defines the BabylonJS internal texture
  47960. * @param createPolynomials will be true if polynomials have been requested
  47961. * @param onLoad defines the callback to trigger once the texture is ready
  47962. * @param onError defines the callback to trigger in case of error
  47963. */
  47964. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47965. /**
  47966. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47967. * @param data contains the texture data
  47968. * @param texture defines the BabylonJS internal texture
  47969. * @param callback defines the method to call once ready to upload
  47970. */
  47971. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47972. }
  47973. }
  47974. declare module "babylonjs/Misc/khronosTextureContainer" {
  47975. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47976. /**
  47977. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47978. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47979. */
  47980. export class KhronosTextureContainer {
  47981. /** contents of the KTX container file */
  47982. arrayBuffer: any;
  47983. private static HEADER_LEN;
  47984. private static COMPRESSED_2D;
  47985. private static COMPRESSED_3D;
  47986. private static TEX_2D;
  47987. private static TEX_3D;
  47988. /**
  47989. * Gets the openGL type
  47990. */
  47991. glType: number;
  47992. /**
  47993. * Gets the openGL type size
  47994. */
  47995. glTypeSize: number;
  47996. /**
  47997. * Gets the openGL format
  47998. */
  47999. glFormat: number;
  48000. /**
  48001. * Gets the openGL internal format
  48002. */
  48003. glInternalFormat: number;
  48004. /**
  48005. * Gets the base internal format
  48006. */
  48007. glBaseInternalFormat: number;
  48008. /**
  48009. * Gets image width in pixel
  48010. */
  48011. pixelWidth: number;
  48012. /**
  48013. * Gets image height in pixel
  48014. */
  48015. pixelHeight: number;
  48016. /**
  48017. * Gets image depth in pixels
  48018. */
  48019. pixelDepth: number;
  48020. /**
  48021. * Gets the number of array elements
  48022. */
  48023. numberOfArrayElements: number;
  48024. /**
  48025. * Gets the number of faces
  48026. */
  48027. numberOfFaces: number;
  48028. /**
  48029. * Gets the number of mipmap levels
  48030. */
  48031. numberOfMipmapLevels: number;
  48032. /**
  48033. * Gets the bytes of key value data
  48034. */
  48035. bytesOfKeyValueData: number;
  48036. /**
  48037. * Gets the load type
  48038. */
  48039. loadType: number;
  48040. /**
  48041. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48042. */
  48043. isInvalid: boolean;
  48044. /**
  48045. * Creates a new KhronosTextureContainer
  48046. * @param arrayBuffer contents of the KTX container file
  48047. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48048. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48049. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48050. */
  48051. constructor(
  48052. /** contents of the KTX container file */
  48053. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48054. /**
  48055. * Uploads KTX content to a Babylon Texture.
  48056. * It is assumed that the texture has already been created & is currently bound
  48057. * @hidden
  48058. */
  48059. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48060. private _upload2DCompressedLevels;
  48061. }
  48062. }
  48063. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48064. import { Nullable } from "babylonjs/types";
  48065. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48066. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48067. /**
  48068. * Implementation of the KTX Texture Loader.
  48069. * @hidden
  48070. */
  48071. export class _KTXTextureLoader implements IInternalTextureLoader {
  48072. /**
  48073. * Defines wether the loader supports cascade loading the different faces.
  48074. */
  48075. readonly supportCascades: boolean;
  48076. /**
  48077. * This returns if the loader support the current file information.
  48078. * @param extension defines the file extension of the file being loaded
  48079. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48080. * @param fallback defines the fallback internal texture if any
  48081. * @param isBase64 defines whether the texture is encoded as a base64
  48082. * @param isBuffer defines whether the texture data are stored as a buffer
  48083. * @returns true if the loader can load the specified file
  48084. */
  48085. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48086. /**
  48087. * Transform the url before loading if required.
  48088. * @param rootUrl the url of the texture
  48089. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48090. * @returns the transformed texture
  48091. */
  48092. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48093. /**
  48094. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48095. * @param rootUrl the url of the texture
  48096. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48097. * @returns the fallback texture
  48098. */
  48099. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48100. /**
  48101. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48102. * @param data contains the texture data
  48103. * @param texture defines the BabylonJS internal texture
  48104. * @param createPolynomials will be true if polynomials have been requested
  48105. * @param onLoad defines the callback to trigger once the texture is ready
  48106. * @param onError defines the callback to trigger in case of error
  48107. */
  48108. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48109. /**
  48110. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48111. * @param data contains the texture data
  48112. * @param texture defines the BabylonJS internal texture
  48113. * @param callback defines the method to call once ready to upload
  48114. */
  48115. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48116. }
  48117. }
  48118. declare module "babylonjs/Helpers/sceneHelpers" {
  48119. import { Nullable } from "babylonjs/types";
  48120. import { Mesh } from "babylonjs/Meshes/mesh";
  48121. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48122. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  48123. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  48124. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  48125. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48126. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48127. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48128. import "babylonjs/Meshes/Builders/boxBuilder";
  48129. /** @hidden */
  48130. export var _forceSceneHelpersToBundle: boolean;
  48131. module "babylonjs/scene" {
  48132. interface Scene {
  48133. /**
  48134. * Creates a default light for the scene.
  48135. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48136. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48137. */
  48138. createDefaultLight(replace?: boolean): void;
  48139. /**
  48140. * Creates a default camera for the scene.
  48141. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48142. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48143. * @param replace has default false, when true replaces the active camera in the scene
  48144. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48145. */
  48146. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48147. /**
  48148. * Creates a default camera and a default light.
  48149. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48150. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48151. * @param replace has the default false, when true replaces the active camera/light in the scene
  48152. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48153. */
  48154. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48155. /**
  48156. * Creates a new sky box
  48157. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48158. * @param environmentTexture defines the texture to use as environment texture
  48159. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48160. * @param scale defines the overall scale of the skybox
  48161. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48162. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48163. * @returns a new mesh holding the sky box
  48164. */
  48165. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48166. /**
  48167. * Creates a new environment
  48168. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48169. * @param options defines the options you can use to configure the environment
  48170. * @returns the new EnvironmentHelper
  48171. */
  48172. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48173. /**
  48174. * Creates a new VREXperienceHelper
  48175. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48176. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48177. * @returns a new VREXperienceHelper
  48178. */
  48179. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48180. /**
  48181. * Creates a new XREXperienceHelper
  48182. * @see http://doc.babylonjs.com/how_to/webxr
  48183. * @returns a promise for a new XREXperienceHelper
  48184. */
  48185. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  48186. }
  48187. }
  48188. }
  48189. declare module "babylonjs/Helpers/videoDome" {
  48190. import { Scene } from "babylonjs/scene";
  48191. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48192. import { Mesh } from "babylonjs/Meshes/mesh";
  48193. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  48194. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48195. import "babylonjs/Meshes/Builders/sphereBuilder";
  48196. /**
  48197. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48198. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48199. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48200. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48201. */
  48202. export class VideoDome extends TransformNode {
  48203. /**
  48204. * Define the video source as a Monoscopic panoramic 360 video.
  48205. */
  48206. static readonly MODE_MONOSCOPIC: number;
  48207. /**
  48208. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48209. */
  48210. static readonly MODE_TOPBOTTOM: number;
  48211. /**
  48212. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48213. */
  48214. static readonly MODE_SIDEBYSIDE: number;
  48215. private _useDirectMapping;
  48216. /**
  48217. * The video texture being displayed on the sphere
  48218. */
  48219. protected _videoTexture: VideoTexture;
  48220. /**
  48221. * Gets the video texture being displayed on the sphere
  48222. */
  48223. readonly videoTexture: VideoTexture;
  48224. /**
  48225. * The skybox material
  48226. */
  48227. protected _material: BackgroundMaterial;
  48228. /**
  48229. * The surface used for the skybox
  48230. */
  48231. protected _mesh: Mesh;
  48232. /**
  48233. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48234. * Also see the options.resolution property.
  48235. */
  48236. fovMultiplier: number;
  48237. private _videoMode;
  48238. /**
  48239. * Gets or set the current video mode for the video. It can be:
  48240. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48241. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48242. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48243. */
  48244. videoMode: number;
  48245. /**
  48246. * Oberserver used in Stereoscopic VR Mode.
  48247. */
  48248. private _onBeforeCameraRenderObserver;
  48249. /**
  48250. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48251. * @param name Element's name, child elements will append suffixes for their own names.
  48252. * @param urlsOrVideo defines the url(s) or the video element to use
  48253. * @param options An object containing optional or exposed sub element properties
  48254. */
  48255. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48256. resolution?: number;
  48257. clickToPlay?: boolean;
  48258. autoPlay?: boolean;
  48259. loop?: boolean;
  48260. size?: number;
  48261. poster?: string;
  48262. faceForward?: boolean;
  48263. useDirectMapping?: boolean;
  48264. }, scene: Scene);
  48265. private _changeVideoMode;
  48266. /**
  48267. * Releases resources associated with this node.
  48268. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48269. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48270. */
  48271. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48272. }
  48273. }
  48274. declare module "babylonjs/Helpers/index" {
  48275. export * from "babylonjs/Helpers/environmentHelper";
  48276. export * from "babylonjs/Helpers/photoDome";
  48277. export * from "babylonjs/Helpers/sceneHelpers";
  48278. export * from "babylonjs/Helpers/videoDome";
  48279. }
  48280. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  48281. import { PerfCounter } from "babylonjs/Misc/tools";
  48282. import { IDisposable } from "babylonjs/scene";
  48283. import { Engine } from "babylonjs/Engines/engine";
  48284. /**
  48285. * This class can be used to get instrumentation data from a Babylon engine
  48286. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48287. */
  48288. export class EngineInstrumentation implements IDisposable {
  48289. /**
  48290. * Define the instrumented engine.
  48291. */
  48292. engine: Engine;
  48293. private _captureGPUFrameTime;
  48294. private _gpuFrameTimeToken;
  48295. private _gpuFrameTime;
  48296. private _captureShaderCompilationTime;
  48297. private _shaderCompilationTime;
  48298. private _onBeginFrameObserver;
  48299. private _onEndFrameObserver;
  48300. private _onBeforeShaderCompilationObserver;
  48301. private _onAfterShaderCompilationObserver;
  48302. /**
  48303. * Gets the perf counter used for GPU frame time
  48304. */
  48305. readonly gpuFrameTimeCounter: PerfCounter;
  48306. /**
  48307. * Gets the GPU frame time capture status
  48308. */
  48309. /**
  48310. * Enable or disable the GPU frame time capture
  48311. */
  48312. captureGPUFrameTime: boolean;
  48313. /**
  48314. * Gets the perf counter used for shader compilation time
  48315. */
  48316. readonly shaderCompilationTimeCounter: PerfCounter;
  48317. /**
  48318. * Gets the shader compilation time capture status
  48319. */
  48320. /**
  48321. * Enable or disable the shader compilation time capture
  48322. */
  48323. captureShaderCompilationTime: boolean;
  48324. /**
  48325. * Instantiates a new engine instrumentation.
  48326. * This class can be used to get instrumentation data from a Babylon engine
  48327. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48328. * @param engine Defines the engine to instrument
  48329. */
  48330. constructor(
  48331. /**
  48332. * Define the instrumented engine.
  48333. */
  48334. engine: Engine);
  48335. /**
  48336. * Dispose and release associated resources.
  48337. */
  48338. dispose(): void;
  48339. }
  48340. }
  48341. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  48342. import { PerfCounter } from "babylonjs/Misc/tools";
  48343. import { Scene, IDisposable } from "babylonjs/scene";
  48344. /**
  48345. * This class can be used to get instrumentation data from a Babylon engine
  48346. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48347. */
  48348. export class SceneInstrumentation implements IDisposable {
  48349. /**
  48350. * Defines the scene to instrument
  48351. */
  48352. scene: Scene;
  48353. private _captureActiveMeshesEvaluationTime;
  48354. private _activeMeshesEvaluationTime;
  48355. private _captureRenderTargetsRenderTime;
  48356. private _renderTargetsRenderTime;
  48357. private _captureFrameTime;
  48358. private _frameTime;
  48359. private _captureRenderTime;
  48360. private _renderTime;
  48361. private _captureInterFrameTime;
  48362. private _interFrameTime;
  48363. private _captureParticlesRenderTime;
  48364. private _particlesRenderTime;
  48365. private _captureSpritesRenderTime;
  48366. private _spritesRenderTime;
  48367. private _capturePhysicsTime;
  48368. private _physicsTime;
  48369. private _captureAnimationsTime;
  48370. private _animationsTime;
  48371. private _captureCameraRenderTime;
  48372. private _cameraRenderTime;
  48373. private _onBeforeActiveMeshesEvaluationObserver;
  48374. private _onAfterActiveMeshesEvaluationObserver;
  48375. private _onBeforeRenderTargetsRenderObserver;
  48376. private _onAfterRenderTargetsRenderObserver;
  48377. private _onAfterRenderObserver;
  48378. private _onBeforeDrawPhaseObserver;
  48379. private _onAfterDrawPhaseObserver;
  48380. private _onBeforeAnimationsObserver;
  48381. private _onBeforeParticlesRenderingObserver;
  48382. private _onAfterParticlesRenderingObserver;
  48383. private _onBeforeSpritesRenderingObserver;
  48384. private _onAfterSpritesRenderingObserver;
  48385. private _onBeforePhysicsObserver;
  48386. private _onAfterPhysicsObserver;
  48387. private _onAfterAnimationsObserver;
  48388. private _onBeforeCameraRenderObserver;
  48389. private _onAfterCameraRenderObserver;
  48390. /**
  48391. * Gets the perf counter used for active meshes evaluation time
  48392. */
  48393. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48394. /**
  48395. * Gets the active meshes evaluation time capture status
  48396. */
  48397. /**
  48398. * Enable or disable the active meshes evaluation time capture
  48399. */
  48400. captureActiveMeshesEvaluationTime: boolean;
  48401. /**
  48402. * Gets the perf counter used for render targets render time
  48403. */
  48404. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48405. /**
  48406. * Gets the render targets render time capture status
  48407. */
  48408. /**
  48409. * Enable or disable the render targets render time capture
  48410. */
  48411. captureRenderTargetsRenderTime: boolean;
  48412. /**
  48413. * Gets the perf counter used for particles render time
  48414. */
  48415. readonly particlesRenderTimeCounter: PerfCounter;
  48416. /**
  48417. * Gets the particles render time capture status
  48418. */
  48419. /**
  48420. * Enable or disable the particles render time capture
  48421. */
  48422. captureParticlesRenderTime: boolean;
  48423. /**
  48424. * Gets the perf counter used for sprites render time
  48425. */
  48426. readonly spritesRenderTimeCounter: PerfCounter;
  48427. /**
  48428. * Gets the sprites render time capture status
  48429. */
  48430. /**
  48431. * Enable or disable the sprites render time capture
  48432. */
  48433. captureSpritesRenderTime: boolean;
  48434. /**
  48435. * Gets the perf counter used for physics time
  48436. */
  48437. readonly physicsTimeCounter: PerfCounter;
  48438. /**
  48439. * Gets the physics time capture status
  48440. */
  48441. /**
  48442. * Enable or disable the physics time capture
  48443. */
  48444. capturePhysicsTime: boolean;
  48445. /**
  48446. * Gets the perf counter used for animations time
  48447. */
  48448. readonly animationsTimeCounter: PerfCounter;
  48449. /**
  48450. * Gets the animations time capture status
  48451. */
  48452. /**
  48453. * Enable or disable the animations time capture
  48454. */
  48455. captureAnimationsTime: boolean;
  48456. /**
  48457. * Gets the perf counter used for frame time capture
  48458. */
  48459. readonly frameTimeCounter: PerfCounter;
  48460. /**
  48461. * Gets the frame time capture status
  48462. */
  48463. /**
  48464. * Enable or disable the frame time capture
  48465. */
  48466. captureFrameTime: boolean;
  48467. /**
  48468. * Gets the perf counter used for inter-frames time capture
  48469. */
  48470. readonly interFrameTimeCounter: PerfCounter;
  48471. /**
  48472. * Gets the inter-frames time capture status
  48473. */
  48474. /**
  48475. * Enable or disable the inter-frames time capture
  48476. */
  48477. captureInterFrameTime: boolean;
  48478. /**
  48479. * Gets the perf counter used for render time capture
  48480. */
  48481. readonly renderTimeCounter: PerfCounter;
  48482. /**
  48483. * Gets the render time capture status
  48484. */
  48485. /**
  48486. * Enable or disable the render time capture
  48487. */
  48488. captureRenderTime: boolean;
  48489. /**
  48490. * Gets the perf counter used for camera render time capture
  48491. */
  48492. readonly cameraRenderTimeCounter: PerfCounter;
  48493. /**
  48494. * Gets the camera render time capture status
  48495. */
  48496. /**
  48497. * Enable or disable the camera render time capture
  48498. */
  48499. captureCameraRenderTime: boolean;
  48500. /**
  48501. * Gets the perf counter used for draw calls
  48502. */
  48503. readonly drawCallsCounter: PerfCounter;
  48504. /**
  48505. * Instantiates a new scene instrumentation.
  48506. * This class can be used to get instrumentation data from a Babylon engine
  48507. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48508. * @param scene Defines the scene to instrument
  48509. */
  48510. constructor(
  48511. /**
  48512. * Defines the scene to instrument
  48513. */
  48514. scene: Scene);
  48515. /**
  48516. * Dispose and release associated resources.
  48517. */
  48518. dispose(): void;
  48519. }
  48520. }
  48521. declare module "babylonjs/Instrumentation/index" {
  48522. export * from "babylonjs/Instrumentation/engineInstrumentation";
  48523. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  48524. export * from "babylonjs/Instrumentation/timeToken";
  48525. }
  48526. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  48527. /** @hidden */
  48528. export var glowMapGenerationPixelShader: {
  48529. name: string;
  48530. shader: string;
  48531. };
  48532. }
  48533. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  48534. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48535. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48536. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48537. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48538. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48539. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48540. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48541. /** @hidden */
  48542. export var glowMapGenerationVertexShader: {
  48543. name: string;
  48544. shader: string;
  48545. };
  48546. }
  48547. declare module "babylonjs/Layers/effectLayer" {
  48548. import { Observable } from "babylonjs/Misc/observable";
  48549. import { Nullable } from "babylonjs/types";
  48550. import { Camera } from "babylonjs/Cameras/camera";
  48551. import { Scene } from "babylonjs/scene";
  48552. import { Color4, ISize } from "babylonjs/Maths/math";
  48553. import { Engine } from "babylonjs/Engines/engine";
  48554. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48555. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48556. import { Mesh } from "babylonjs/Meshes/mesh";
  48557. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48558. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48559. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48560. import { Effect } from "babylonjs/Materials/effect";
  48561. import { Material } from "babylonjs/Materials/material";
  48562. import "babylonjs/Shaders/glowMapGeneration.fragment";
  48563. import "babylonjs/Shaders/glowMapGeneration.vertex";
  48564. /**
  48565. * Effect layer options. This helps customizing the behaviour
  48566. * of the effect layer.
  48567. */
  48568. export interface IEffectLayerOptions {
  48569. /**
  48570. * Multiplication factor apply to the canvas size to compute the render target size
  48571. * used to generated the objects (the smaller the faster).
  48572. */
  48573. mainTextureRatio: number;
  48574. /**
  48575. * Enforces a fixed size texture to ensure effect stability across devices.
  48576. */
  48577. mainTextureFixedSize?: number;
  48578. /**
  48579. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48580. */
  48581. alphaBlendingMode: number;
  48582. /**
  48583. * The camera attached to the layer.
  48584. */
  48585. camera: Nullable<Camera>;
  48586. /**
  48587. * The rendering group to draw the layer in.
  48588. */
  48589. renderingGroupId: number;
  48590. }
  48591. /**
  48592. * The effect layer Helps adding post process effect blended with the main pass.
  48593. *
  48594. * This can be for instance use to generate glow or higlight effects on the scene.
  48595. *
  48596. * The effect layer class can not be used directly and is intented to inherited from to be
  48597. * customized per effects.
  48598. */
  48599. export abstract class EffectLayer {
  48600. private _vertexBuffers;
  48601. private _indexBuffer;
  48602. private _cachedDefines;
  48603. private _effectLayerMapGenerationEffect;
  48604. private _effectLayerOptions;
  48605. private _mergeEffect;
  48606. protected _scene: Scene;
  48607. protected _engine: Engine;
  48608. protected _maxSize: number;
  48609. protected _mainTextureDesiredSize: ISize;
  48610. protected _mainTexture: RenderTargetTexture;
  48611. protected _shouldRender: boolean;
  48612. protected _postProcesses: PostProcess[];
  48613. protected _textures: BaseTexture[];
  48614. protected _emissiveTextureAndColor: {
  48615. texture: Nullable<BaseTexture>;
  48616. color: Color4;
  48617. };
  48618. /**
  48619. * The name of the layer
  48620. */
  48621. name: string;
  48622. /**
  48623. * The clear color of the texture used to generate the glow map.
  48624. */
  48625. neutralColor: Color4;
  48626. /**
  48627. * Specifies wether the highlight layer is enabled or not.
  48628. */
  48629. isEnabled: boolean;
  48630. /**
  48631. * Gets the camera attached to the layer.
  48632. */
  48633. readonly camera: Nullable<Camera>;
  48634. /**
  48635. * Gets the rendering group id the layer should render in.
  48636. */
  48637. readonly renderingGroupId: number;
  48638. /**
  48639. * An event triggered when the effect layer has been disposed.
  48640. */
  48641. onDisposeObservable: Observable<EffectLayer>;
  48642. /**
  48643. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48644. */
  48645. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48646. /**
  48647. * An event triggered when the generated texture is being merged in the scene.
  48648. */
  48649. onBeforeComposeObservable: Observable<EffectLayer>;
  48650. /**
  48651. * An event triggered when the generated texture has been merged in the scene.
  48652. */
  48653. onAfterComposeObservable: Observable<EffectLayer>;
  48654. /**
  48655. * An event triggered when the efffect layer changes its size.
  48656. */
  48657. onSizeChangedObservable: Observable<EffectLayer>;
  48658. /** @hidden */
  48659. static _SceneComponentInitialization: (scene: Scene) => void;
  48660. /**
  48661. * Instantiates a new effect Layer and references it in the scene.
  48662. * @param name The name of the layer
  48663. * @param scene The scene to use the layer in
  48664. */
  48665. constructor(
  48666. /** The Friendly of the effect in the scene */
  48667. name: string, scene: Scene);
  48668. /**
  48669. * Get the effect name of the layer.
  48670. * @return The effect name
  48671. */
  48672. abstract getEffectName(): string;
  48673. /**
  48674. * Checks for the readiness of the element composing the layer.
  48675. * @param subMesh the mesh to check for
  48676. * @param useInstances specify wether or not to use instances to render the mesh
  48677. * @return true if ready otherwise, false
  48678. */
  48679. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48680. /**
  48681. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48682. * @returns true if the effect requires stencil during the main canvas render pass.
  48683. */
  48684. abstract needStencil(): boolean;
  48685. /**
  48686. * Create the merge effect. This is the shader use to blit the information back
  48687. * to the main canvas at the end of the scene rendering.
  48688. * @returns The effect containing the shader used to merge the effect on the main canvas
  48689. */
  48690. protected abstract _createMergeEffect(): Effect;
  48691. /**
  48692. * Creates the render target textures and post processes used in the effect layer.
  48693. */
  48694. protected abstract _createTextureAndPostProcesses(): void;
  48695. /**
  48696. * Implementation specific of rendering the generating effect on the main canvas.
  48697. * @param effect The effect used to render through
  48698. */
  48699. protected abstract _internalRender(effect: Effect): void;
  48700. /**
  48701. * Sets the required values for both the emissive texture and and the main color.
  48702. */
  48703. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48704. /**
  48705. * Free any resources and references associated to a mesh.
  48706. * Internal use
  48707. * @param mesh The mesh to free.
  48708. */
  48709. abstract _disposeMesh(mesh: Mesh): void;
  48710. /**
  48711. * Serializes this layer (Glow or Highlight for example)
  48712. * @returns a serialized layer object
  48713. */
  48714. abstract serialize?(): any;
  48715. /**
  48716. * Initializes the effect layer with the required options.
  48717. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48718. */
  48719. protected _init(options: Partial<IEffectLayerOptions>): void;
  48720. /**
  48721. * Generates the index buffer of the full screen quad blending to the main canvas.
  48722. */
  48723. private _generateIndexBuffer;
  48724. /**
  48725. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48726. */
  48727. private _genrateVertexBuffer;
  48728. /**
  48729. * Sets the main texture desired size which is the closest power of two
  48730. * of the engine canvas size.
  48731. */
  48732. private _setMainTextureSize;
  48733. /**
  48734. * Creates the main texture for the effect layer.
  48735. */
  48736. protected _createMainTexture(): void;
  48737. /**
  48738. * Adds specific effects defines.
  48739. * @param defines The defines to add specifics to.
  48740. */
  48741. protected _addCustomEffectDefines(defines: string[]): void;
  48742. /**
  48743. * Checks for the readiness of the element composing the layer.
  48744. * @param subMesh the mesh to check for
  48745. * @param useInstances specify wether or not to use instances to render the mesh
  48746. * @param emissiveTexture the associated emissive texture used to generate the glow
  48747. * @return true if ready otherwise, false
  48748. */
  48749. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48750. /**
  48751. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48752. */
  48753. render(): void;
  48754. /**
  48755. * Determine if a given mesh will be used in the current effect.
  48756. * @param mesh mesh to test
  48757. * @returns true if the mesh will be used
  48758. */
  48759. hasMesh(mesh: AbstractMesh): boolean;
  48760. /**
  48761. * Returns true if the layer contains information to display, otherwise false.
  48762. * @returns true if the glow layer should be rendered
  48763. */
  48764. shouldRender(): boolean;
  48765. /**
  48766. * Returns true if the mesh should render, otherwise false.
  48767. * @param mesh The mesh to render
  48768. * @returns true if it should render otherwise false
  48769. */
  48770. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48771. /**
  48772. * Returns true if the mesh can be rendered, otherwise false.
  48773. * @param mesh The mesh to render
  48774. * @param material The material used on the mesh
  48775. * @returns true if it can be rendered otherwise false
  48776. */
  48777. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48778. /**
  48779. * Returns true if the mesh should render, otherwise false.
  48780. * @param mesh The mesh to render
  48781. * @returns true if it should render otherwise false
  48782. */
  48783. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48784. /**
  48785. * Renders the submesh passed in parameter to the generation map.
  48786. */
  48787. protected _renderSubMesh(subMesh: SubMesh): void;
  48788. /**
  48789. * Rebuild the required buffers.
  48790. * @hidden Internal use only.
  48791. */
  48792. _rebuild(): void;
  48793. /**
  48794. * Dispose only the render target textures and post process.
  48795. */
  48796. private _disposeTextureAndPostProcesses;
  48797. /**
  48798. * Dispose the highlight layer and free resources.
  48799. */
  48800. dispose(): void;
  48801. /**
  48802. * Gets the class name of the effect layer
  48803. * @returns the string with the class name of the effect layer
  48804. */
  48805. getClassName(): string;
  48806. /**
  48807. * Creates an effect layer from parsed effect layer data
  48808. * @param parsedEffectLayer defines effect layer data
  48809. * @param scene defines the current scene
  48810. * @param rootUrl defines the root URL containing the effect layer information
  48811. * @returns a parsed effect Layer
  48812. */
  48813. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48814. }
  48815. }
  48816. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  48817. import { Scene } from "babylonjs/scene";
  48818. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48819. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48820. import { AbstractScene } from "babylonjs/abstractScene";
  48821. module "babylonjs/abstractScene" {
  48822. interface AbstractScene {
  48823. /**
  48824. * The list of effect layers (highlights/glow) added to the scene
  48825. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48826. * @see http://doc.babylonjs.com/how_to/glow_layer
  48827. */
  48828. effectLayers: Array<EffectLayer>;
  48829. /**
  48830. * Removes the given effect layer from this scene.
  48831. * @param toRemove defines the effect layer to remove
  48832. * @returns the index of the removed effect layer
  48833. */
  48834. removeEffectLayer(toRemove: EffectLayer): number;
  48835. /**
  48836. * Adds the given effect layer to this scene
  48837. * @param newEffectLayer defines the effect layer to add
  48838. */
  48839. addEffectLayer(newEffectLayer: EffectLayer): void;
  48840. }
  48841. }
  48842. /**
  48843. * Defines the layer scene component responsible to manage any effect layers
  48844. * in a given scene.
  48845. */
  48846. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48847. /**
  48848. * The component name helpfull to identify the component in the list of scene components.
  48849. */
  48850. readonly name: string;
  48851. /**
  48852. * The scene the component belongs to.
  48853. */
  48854. scene: Scene;
  48855. private _engine;
  48856. private _renderEffects;
  48857. private _needStencil;
  48858. private _previousStencilState;
  48859. /**
  48860. * Creates a new instance of the component for the given scene
  48861. * @param scene Defines the scene to register the component in
  48862. */
  48863. constructor(scene: Scene);
  48864. /**
  48865. * Registers the component in a given scene
  48866. */
  48867. register(): void;
  48868. /**
  48869. * Rebuilds the elements related to this component in case of
  48870. * context lost for instance.
  48871. */
  48872. rebuild(): void;
  48873. /**
  48874. * Serializes the component data to the specified json object
  48875. * @param serializationObject The object to serialize to
  48876. */
  48877. serialize(serializationObject: any): void;
  48878. /**
  48879. * Adds all the element from the container to the scene
  48880. * @param container the container holding the elements
  48881. */
  48882. addFromContainer(container: AbstractScene): void;
  48883. /**
  48884. * Removes all the elements in the container from the scene
  48885. * @param container contains the elements to remove
  48886. * @param dispose if the removed element should be disposed (default: false)
  48887. */
  48888. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48889. /**
  48890. * Disposes the component and the associated ressources.
  48891. */
  48892. dispose(): void;
  48893. private _isReadyForMesh;
  48894. private _renderMainTexture;
  48895. private _setStencil;
  48896. private _setStencilBack;
  48897. private _draw;
  48898. private _drawCamera;
  48899. private _drawRenderingGroup;
  48900. }
  48901. }
  48902. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  48903. /** @hidden */
  48904. export var glowMapMergePixelShader: {
  48905. name: string;
  48906. shader: string;
  48907. };
  48908. }
  48909. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  48910. /** @hidden */
  48911. export var glowMapMergeVertexShader: {
  48912. name: string;
  48913. shader: string;
  48914. };
  48915. }
  48916. declare module "babylonjs/Layers/glowLayer" {
  48917. import { Nullable } from "babylonjs/types";
  48918. import { Camera } from "babylonjs/Cameras/camera";
  48919. import { Scene } from "babylonjs/scene";
  48920. import { Color4 } from "babylonjs/Maths/math";
  48921. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48923. import { Mesh } from "babylonjs/Meshes/mesh";
  48924. import { Texture } from "babylonjs/Materials/Textures/texture";
  48925. import { Effect } from "babylonjs/Materials/effect";
  48926. import { Material } from "babylonjs/Materials/material";
  48927. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48928. import "babylonjs/Shaders/glowMapMerge.fragment";
  48929. import "babylonjs/Shaders/glowMapMerge.vertex";
  48930. import "babylonjs/Layers/effectLayerSceneComponent";
  48931. module "babylonjs/abstractScene" {
  48932. interface AbstractScene {
  48933. /**
  48934. * Return a the first highlight layer of the scene with a given name.
  48935. * @param name The name of the highlight layer to look for.
  48936. * @return The highlight layer if found otherwise null.
  48937. */
  48938. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48939. }
  48940. }
  48941. /**
  48942. * Glow layer options. This helps customizing the behaviour
  48943. * of the glow layer.
  48944. */
  48945. export interface IGlowLayerOptions {
  48946. /**
  48947. * Multiplication factor apply to the canvas size to compute the render target size
  48948. * used to generated the glowing objects (the smaller the faster).
  48949. */
  48950. mainTextureRatio: number;
  48951. /**
  48952. * Enforces a fixed size texture to ensure resize independant blur.
  48953. */
  48954. mainTextureFixedSize?: number;
  48955. /**
  48956. * How big is the kernel of the blur texture.
  48957. */
  48958. blurKernelSize: number;
  48959. /**
  48960. * The camera attached to the layer.
  48961. */
  48962. camera: Nullable<Camera>;
  48963. /**
  48964. * Enable MSAA by chosing the number of samples.
  48965. */
  48966. mainTextureSamples?: number;
  48967. /**
  48968. * The rendering group to draw the layer in.
  48969. */
  48970. renderingGroupId: number;
  48971. }
  48972. /**
  48973. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48974. *
  48975. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48976. * glowy meshes to your scene.
  48977. *
  48978. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48979. */
  48980. export class GlowLayer extends EffectLayer {
  48981. /**
  48982. * Effect Name of the layer.
  48983. */
  48984. static readonly EffectName: string;
  48985. /**
  48986. * The default blur kernel size used for the glow.
  48987. */
  48988. static DefaultBlurKernelSize: number;
  48989. /**
  48990. * The default texture size ratio used for the glow.
  48991. */
  48992. static DefaultTextureRatio: number;
  48993. /**
  48994. * Sets the kernel size of the blur.
  48995. */
  48996. /**
  48997. * Gets the kernel size of the blur.
  48998. */
  48999. blurKernelSize: number;
  49000. /**
  49001. * Sets the glow intensity.
  49002. */
  49003. /**
  49004. * Gets the glow intensity.
  49005. */
  49006. intensity: number;
  49007. private _options;
  49008. private _intensity;
  49009. private _horizontalBlurPostprocess1;
  49010. private _verticalBlurPostprocess1;
  49011. private _horizontalBlurPostprocess2;
  49012. private _verticalBlurPostprocess2;
  49013. private _blurTexture1;
  49014. private _blurTexture2;
  49015. private _postProcesses1;
  49016. private _postProcesses2;
  49017. private _includedOnlyMeshes;
  49018. private _excludedMeshes;
  49019. /**
  49020. * Callback used to let the user override the color selection on a per mesh basis
  49021. */
  49022. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49023. /**
  49024. * Callback used to let the user override the texture selection on a per mesh basis
  49025. */
  49026. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49027. /**
  49028. * Instantiates a new glow Layer and references it to the scene.
  49029. * @param name The name of the layer
  49030. * @param scene The scene to use the layer in
  49031. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49032. */
  49033. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49034. /**
  49035. * Get the effect name of the layer.
  49036. * @return The effect name
  49037. */
  49038. getEffectName(): string;
  49039. /**
  49040. * Create the merge effect. This is the shader use to blit the information back
  49041. * to the main canvas at the end of the scene rendering.
  49042. */
  49043. protected _createMergeEffect(): Effect;
  49044. /**
  49045. * Creates the render target textures and post processes used in the glow layer.
  49046. */
  49047. protected _createTextureAndPostProcesses(): void;
  49048. /**
  49049. * Checks for the readiness of the element composing the layer.
  49050. * @param subMesh the mesh to check for
  49051. * @param useInstances specify wether or not to use instances to render the mesh
  49052. * @param emissiveTexture the associated emissive texture used to generate the glow
  49053. * @return true if ready otherwise, false
  49054. */
  49055. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49056. /**
  49057. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49058. */
  49059. needStencil(): boolean;
  49060. /**
  49061. * Returns true if the mesh can be rendered, otherwise false.
  49062. * @param mesh The mesh to render
  49063. * @param material The material used on the mesh
  49064. * @returns true if it can be rendered otherwise false
  49065. */
  49066. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49067. /**
  49068. * Implementation specific of rendering the generating effect on the main canvas.
  49069. * @param effect The effect used to render through
  49070. */
  49071. protected _internalRender(effect: Effect): void;
  49072. /**
  49073. * Sets the required values for both the emissive texture and and the main color.
  49074. */
  49075. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49076. /**
  49077. * Returns true if the mesh should render, otherwise false.
  49078. * @param mesh The mesh to render
  49079. * @returns true if it should render otherwise false
  49080. */
  49081. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49082. /**
  49083. * Adds specific effects defines.
  49084. * @param defines The defines to add specifics to.
  49085. */
  49086. protected _addCustomEffectDefines(defines: string[]): void;
  49087. /**
  49088. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49089. * @param mesh The mesh to exclude from the glow layer
  49090. */
  49091. addExcludedMesh(mesh: Mesh): void;
  49092. /**
  49093. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49094. * @param mesh The mesh to remove
  49095. */
  49096. removeExcludedMesh(mesh: Mesh): void;
  49097. /**
  49098. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49099. * @param mesh The mesh to include in the glow layer
  49100. */
  49101. addIncludedOnlyMesh(mesh: Mesh): void;
  49102. /**
  49103. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49104. * @param mesh The mesh to remove
  49105. */
  49106. removeIncludedOnlyMesh(mesh: Mesh): void;
  49107. /**
  49108. * Determine if a given mesh will be used in the glow layer
  49109. * @param mesh The mesh to test
  49110. * @returns true if the mesh will be highlighted by the current glow layer
  49111. */
  49112. hasMesh(mesh: AbstractMesh): boolean;
  49113. /**
  49114. * Free any resources and references associated to a mesh.
  49115. * Internal use
  49116. * @param mesh The mesh to free.
  49117. * @hidden
  49118. */
  49119. _disposeMesh(mesh: Mesh): void;
  49120. /**
  49121. * Gets the class name of the effect layer
  49122. * @returns the string with the class name of the effect layer
  49123. */
  49124. getClassName(): string;
  49125. /**
  49126. * Serializes this glow layer
  49127. * @returns a serialized glow layer object
  49128. */
  49129. serialize(): any;
  49130. /**
  49131. * Creates a Glow Layer from parsed glow layer data
  49132. * @param parsedGlowLayer defines glow layer data
  49133. * @param scene defines the current scene
  49134. * @param rootUrl defines the root URL containing the glow layer information
  49135. * @returns a parsed Glow Layer
  49136. */
  49137. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49138. }
  49139. }
  49140. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  49141. /** @hidden */
  49142. export var glowBlurPostProcessPixelShader: {
  49143. name: string;
  49144. shader: string;
  49145. };
  49146. }
  49147. declare module "babylonjs/Layers/highlightLayer" {
  49148. import { Observable } from "babylonjs/Misc/observable";
  49149. import { Nullable } from "babylonjs/types";
  49150. import { Camera } from "babylonjs/Cameras/camera";
  49151. import { Scene } from "babylonjs/scene";
  49152. import { Color3, Color4 } from "babylonjs/Maths/math";
  49153. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49154. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49155. import { Mesh } from "babylonjs/Meshes/mesh";
  49156. import { Effect } from "babylonjs/Materials/effect";
  49157. import { Material } from "babylonjs/Materials/material";
  49158. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49159. import "babylonjs/Shaders/glowMapMerge.fragment";
  49160. import "babylonjs/Shaders/glowMapMerge.vertex";
  49161. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  49162. module "babylonjs/abstractScene" {
  49163. interface AbstractScene {
  49164. /**
  49165. * Return a the first highlight layer of the scene with a given name.
  49166. * @param name The name of the highlight layer to look for.
  49167. * @return The highlight layer if found otherwise null.
  49168. */
  49169. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49170. }
  49171. }
  49172. /**
  49173. * Highlight layer options. This helps customizing the behaviour
  49174. * of the highlight layer.
  49175. */
  49176. export interface IHighlightLayerOptions {
  49177. /**
  49178. * Multiplication factor apply to the canvas size to compute the render target size
  49179. * used to generated the glowing objects (the smaller the faster).
  49180. */
  49181. mainTextureRatio: number;
  49182. /**
  49183. * Enforces a fixed size texture to ensure resize independant blur.
  49184. */
  49185. mainTextureFixedSize?: number;
  49186. /**
  49187. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49188. * of the picture to blur (the smaller the faster).
  49189. */
  49190. blurTextureSizeRatio: number;
  49191. /**
  49192. * How big in texel of the blur texture is the vertical blur.
  49193. */
  49194. blurVerticalSize: number;
  49195. /**
  49196. * How big in texel of the blur texture is the horizontal blur.
  49197. */
  49198. blurHorizontalSize: number;
  49199. /**
  49200. * Alpha blending mode used to apply the blur. Default is combine.
  49201. */
  49202. alphaBlendingMode: number;
  49203. /**
  49204. * The camera attached to the layer.
  49205. */
  49206. camera: Nullable<Camera>;
  49207. /**
  49208. * Should we display highlight as a solid stroke?
  49209. */
  49210. isStroke?: boolean;
  49211. /**
  49212. * The rendering group to draw the layer in.
  49213. */
  49214. renderingGroupId: number;
  49215. }
  49216. /**
  49217. * The highlight layer Helps adding a glow effect around a mesh.
  49218. *
  49219. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49220. * glowy meshes to your scene.
  49221. *
  49222. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49223. */
  49224. export class HighlightLayer extends EffectLayer {
  49225. name: string;
  49226. /**
  49227. * Effect Name of the highlight layer.
  49228. */
  49229. static readonly EffectName: string;
  49230. /**
  49231. * The neutral color used during the preparation of the glow effect.
  49232. * This is black by default as the blend operation is a blend operation.
  49233. */
  49234. static NeutralColor: Color4;
  49235. /**
  49236. * Stencil value used for glowing meshes.
  49237. */
  49238. static GlowingMeshStencilReference: number;
  49239. /**
  49240. * Stencil value used for the other meshes in the scene.
  49241. */
  49242. static NormalMeshStencilReference: number;
  49243. /**
  49244. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49245. */
  49246. innerGlow: boolean;
  49247. /**
  49248. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49249. */
  49250. outerGlow: boolean;
  49251. /**
  49252. * Specifies the horizontal size of the blur.
  49253. */
  49254. /**
  49255. * Gets the horizontal size of the blur.
  49256. */
  49257. blurHorizontalSize: number;
  49258. /**
  49259. * Specifies the vertical size of the blur.
  49260. */
  49261. /**
  49262. * Gets the vertical size of the blur.
  49263. */
  49264. blurVerticalSize: number;
  49265. /**
  49266. * An event triggered when the highlight layer is being blurred.
  49267. */
  49268. onBeforeBlurObservable: Observable<HighlightLayer>;
  49269. /**
  49270. * An event triggered when the highlight layer has been blurred.
  49271. */
  49272. onAfterBlurObservable: Observable<HighlightLayer>;
  49273. private _instanceGlowingMeshStencilReference;
  49274. private _options;
  49275. private _downSamplePostprocess;
  49276. private _horizontalBlurPostprocess;
  49277. private _verticalBlurPostprocess;
  49278. private _blurTexture;
  49279. private _meshes;
  49280. private _excludedMeshes;
  49281. /**
  49282. * Instantiates a new highlight Layer and references it to the scene..
  49283. * @param name The name of the layer
  49284. * @param scene The scene to use the layer in
  49285. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49286. */
  49287. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49288. /**
  49289. * Get the effect name of the layer.
  49290. * @return The effect name
  49291. */
  49292. getEffectName(): string;
  49293. /**
  49294. * Create the merge effect. This is the shader use to blit the information back
  49295. * to the main canvas at the end of the scene rendering.
  49296. */
  49297. protected _createMergeEffect(): Effect;
  49298. /**
  49299. * Creates the render target textures and post processes used in the highlight layer.
  49300. */
  49301. protected _createTextureAndPostProcesses(): void;
  49302. /**
  49303. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49304. */
  49305. needStencil(): boolean;
  49306. /**
  49307. * Checks for the readiness of the element composing the layer.
  49308. * @param subMesh the mesh to check for
  49309. * @param useInstances specify wether or not to use instances to render the mesh
  49310. * @param emissiveTexture the associated emissive texture used to generate the glow
  49311. * @return true if ready otherwise, false
  49312. */
  49313. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49314. /**
  49315. * Implementation specific of rendering the generating effect on the main canvas.
  49316. * @param effect The effect used to render through
  49317. */
  49318. protected _internalRender(effect: Effect): void;
  49319. /**
  49320. * Returns true if the layer contains information to display, otherwise false.
  49321. */
  49322. shouldRender(): boolean;
  49323. /**
  49324. * Returns true if the mesh should render, otherwise false.
  49325. * @param mesh The mesh to render
  49326. * @returns true if it should render otherwise false
  49327. */
  49328. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49329. /**
  49330. * Sets the required values for both the emissive texture and and the main color.
  49331. */
  49332. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49333. /**
  49334. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49335. * @param mesh The mesh to exclude from the highlight layer
  49336. */
  49337. addExcludedMesh(mesh: Mesh): void;
  49338. /**
  49339. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49340. * @param mesh The mesh to highlight
  49341. */
  49342. removeExcludedMesh(mesh: Mesh): void;
  49343. /**
  49344. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49345. * @param mesh mesh to test
  49346. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49347. */
  49348. hasMesh(mesh: AbstractMesh): boolean;
  49349. /**
  49350. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49351. * @param mesh The mesh to highlight
  49352. * @param color The color of the highlight
  49353. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49354. */
  49355. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49356. /**
  49357. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49358. * @param mesh The mesh to highlight
  49359. */
  49360. removeMesh(mesh: Mesh): void;
  49361. /**
  49362. * Force the stencil to the normal expected value for none glowing parts
  49363. */
  49364. private _defaultStencilReference;
  49365. /**
  49366. * Free any resources and references associated to a mesh.
  49367. * Internal use
  49368. * @param mesh The mesh to free.
  49369. * @hidden
  49370. */
  49371. _disposeMesh(mesh: Mesh): void;
  49372. /**
  49373. * Dispose the highlight layer and free resources.
  49374. */
  49375. dispose(): void;
  49376. /**
  49377. * Gets the class name of the effect layer
  49378. * @returns the string with the class name of the effect layer
  49379. */
  49380. getClassName(): string;
  49381. /**
  49382. * Serializes this Highlight layer
  49383. * @returns a serialized Highlight layer object
  49384. */
  49385. serialize(): any;
  49386. /**
  49387. * Creates a Highlight layer from parsed Highlight layer data
  49388. * @param parsedHightlightLayer defines the Highlight layer data
  49389. * @param scene defines the current scene
  49390. * @param rootUrl defines the root URL containing the Highlight layer information
  49391. * @returns a parsed Highlight layer
  49392. */
  49393. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49394. }
  49395. }
  49396. declare module "babylonjs/Layers/index" {
  49397. export * from "babylonjs/Layers/effectLayer";
  49398. export * from "babylonjs/Layers/effectLayerSceneComponent";
  49399. export * from "babylonjs/Layers/glowLayer";
  49400. export * from "babylonjs/Layers/highlightLayer";
  49401. export * from "babylonjs/Layers/layer";
  49402. export * from "babylonjs/Layers/layerSceneComponent";
  49403. }
  49404. declare module "babylonjs/Shaders/lensFlare.fragment" {
  49405. /** @hidden */
  49406. export var lensFlarePixelShader: {
  49407. name: string;
  49408. shader: string;
  49409. };
  49410. }
  49411. declare module "babylonjs/Shaders/lensFlare.vertex" {
  49412. /** @hidden */
  49413. export var lensFlareVertexShader: {
  49414. name: string;
  49415. shader: string;
  49416. };
  49417. }
  49418. declare module "babylonjs/LensFlares/lensFlareSystem" {
  49419. import { Scene } from "babylonjs/scene";
  49420. import { Vector3, Viewport } from "babylonjs/Maths/math";
  49421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49422. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  49423. import "babylonjs/Shaders/lensFlare.fragment";
  49424. import "babylonjs/Shaders/lensFlare.vertex";
  49425. /**
  49426. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49427. * It is usually composed of several `lensFlare`.
  49428. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49429. */
  49430. export class LensFlareSystem {
  49431. /**
  49432. * Define the name of the lens flare system
  49433. */
  49434. name: string;
  49435. /**
  49436. * List of lens flares used in this system.
  49437. */
  49438. lensFlares: LensFlare[];
  49439. /**
  49440. * Define a limit from the border the lens flare can be visible.
  49441. */
  49442. borderLimit: number;
  49443. /**
  49444. * Define a viewport border we do not want to see the lens flare in.
  49445. */
  49446. viewportBorder: number;
  49447. /**
  49448. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49449. */
  49450. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49451. /**
  49452. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49453. */
  49454. layerMask: number;
  49455. /**
  49456. * Define the id of the lens flare system in the scene.
  49457. * (equal to name by default)
  49458. */
  49459. id: string;
  49460. private _scene;
  49461. private _emitter;
  49462. private _vertexBuffers;
  49463. private _indexBuffer;
  49464. private _effect;
  49465. private _positionX;
  49466. private _positionY;
  49467. private _isEnabled;
  49468. /** @hidden */
  49469. static _SceneComponentInitialization: (scene: Scene) => void;
  49470. /**
  49471. * Instantiates a lens flare system.
  49472. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49473. * It is usually composed of several `lensFlare`.
  49474. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49475. * @param name Define the name of the lens flare system in the scene
  49476. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49477. * @param scene Define the scene the lens flare system belongs to
  49478. */
  49479. constructor(
  49480. /**
  49481. * Define the name of the lens flare system
  49482. */
  49483. name: string, emitter: any, scene: Scene);
  49484. /**
  49485. * Define if the lens flare system is enabled.
  49486. */
  49487. isEnabled: boolean;
  49488. /**
  49489. * Get the scene the effects belongs to.
  49490. * @returns the scene holding the lens flare system
  49491. */
  49492. getScene(): Scene;
  49493. /**
  49494. * Get the emitter of the lens flare system.
  49495. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49496. * @returns the emitter of the lens flare system
  49497. */
  49498. getEmitter(): any;
  49499. /**
  49500. * Set the emitter of the lens flare system.
  49501. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49502. * @param newEmitter Define the new emitter of the system
  49503. */
  49504. setEmitter(newEmitter: any): void;
  49505. /**
  49506. * Get the lens flare system emitter position.
  49507. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49508. * @returns the position
  49509. */
  49510. getEmitterPosition(): Vector3;
  49511. /**
  49512. * @hidden
  49513. */
  49514. computeEffectivePosition(globalViewport: Viewport): boolean;
  49515. /** @hidden */
  49516. _isVisible(): boolean;
  49517. /**
  49518. * @hidden
  49519. */
  49520. render(): boolean;
  49521. /**
  49522. * Dispose and release the lens flare with its associated resources.
  49523. */
  49524. dispose(): void;
  49525. /**
  49526. * Parse a lens flare system from a JSON repressentation
  49527. * @param parsedLensFlareSystem Define the JSON to parse
  49528. * @param scene Define the scene the parsed system should be instantiated in
  49529. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49530. * @returns the parsed system
  49531. */
  49532. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49533. /**
  49534. * Serialize the current Lens Flare System into a JSON representation.
  49535. * @returns the serialized JSON
  49536. */
  49537. serialize(): any;
  49538. }
  49539. }
  49540. declare module "babylonjs/LensFlares/lensFlare" {
  49541. import { Nullable } from "babylonjs/types";
  49542. import { Color3 } from "babylonjs/Maths/math";
  49543. import { Texture } from "babylonjs/Materials/Textures/texture";
  49544. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49545. /**
  49546. * This represents one of the lens effect in a `lensFlareSystem`.
  49547. * It controls one of the indiviual texture used in the effect.
  49548. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49549. */
  49550. export class LensFlare {
  49551. /**
  49552. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49553. */
  49554. size: number;
  49555. /**
  49556. * 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.
  49557. */
  49558. position: number;
  49559. /**
  49560. * Define the lens color.
  49561. */
  49562. color: Color3;
  49563. /**
  49564. * Define the lens texture.
  49565. */
  49566. texture: Nullable<Texture>;
  49567. /**
  49568. * Define the alpha mode to render this particular lens.
  49569. */
  49570. alphaMode: number;
  49571. private _system;
  49572. /**
  49573. * Creates a new Lens Flare.
  49574. * This represents one of the lens effect in a `lensFlareSystem`.
  49575. * It controls one of the indiviual texture used in the effect.
  49576. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49577. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49578. * @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.
  49579. * @param color Define the lens color
  49580. * @param imgUrl Define the lens texture url
  49581. * @param system Define the `lensFlareSystem` this flare is part of
  49582. * @returns The newly created Lens Flare
  49583. */
  49584. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49585. /**
  49586. * Instantiates a new Lens Flare.
  49587. * This represents one of the lens effect in a `lensFlareSystem`.
  49588. * It controls one of the indiviual texture used in the effect.
  49589. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49590. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49591. * @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.
  49592. * @param color Define the lens color
  49593. * @param imgUrl Define the lens texture url
  49594. * @param system Define the `lensFlareSystem` this flare is part of
  49595. */
  49596. constructor(
  49597. /**
  49598. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49599. */
  49600. size: number,
  49601. /**
  49602. * 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.
  49603. */
  49604. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49605. /**
  49606. * Dispose and release the lens flare with its associated resources.
  49607. */
  49608. dispose(): void;
  49609. }
  49610. }
  49611. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  49612. import { Nullable } from "babylonjs/types";
  49613. import { Scene } from "babylonjs/scene";
  49614. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49615. import { AbstractScene } from "babylonjs/abstractScene";
  49616. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49617. module "babylonjs/abstractScene" {
  49618. interface AbstractScene {
  49619. /**
  49620. * The list of lens flare system added to the scene
  49621. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49622. */
  49623. lensFlareSystems: Array<LensFlareSystem>;
  49624. /**
  49625. * Removes the given lens flare system from this scene.
  49626. * @param toRemove The lens flare system to remove
  49627. * @returns The index of the removed lens flare system
  49628. */
  49629. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49630. /**
  49631. * Adds the given lens flare system to this scene
  49632. * @param newLensFlareSystem The lens flare system to add
  49633. */
  49634. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49635. /**
  49636. * Gets a lens flare system using its name
  49637. * @param name defines the name to look for
  49638. * @returns the lens flare system or null if not found
  49639. */
  49640. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49641. /**
  49642. * Gets a lens flare system using its id
  49643. * @param id defines the id to look for
  49644. * @returns the lens flare system or null if not found
  49645. */
  49646. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49647. }
  49648. }
  49649. /**
  49650. * Defines the lens flare scene component responsible to manage any lens flares
  49651. * in a given scene.
  49652. */
  49653. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49654. /**
  49655. * The component name helpfull to identify the component in the list of scene components.
  49656. */
  49657. readonly name: string;
  49658. /**
  49659. * The scene the component belongs to.
  49660. */
  49661. scene: Scene;
  49662. /**
  49663. * Creates a new instance of the component for the given scene
  49664. * @param scene Defines the scene to register the component in
  49665. */
  49666. constructor(scene: Scene);
  49667. /**
  49668. * Registers the component in a given scene
  49669. */
  49670. register(): void;
  49671. /**
  49672. * Rebuilds the elements related to this component in case of
  49673. * context lost for instance.
  49674. */
  49675. rebuild(): void;
  49676. /**
  49677. * Adds all the element from the container to the scene
  49678. * @param container the container holding the elements
  49679. */
  49680. addFromContainer(container: AbstractScene): void;
  49681. /**
  49682. * Removes all the elements in the container from the scene
  49683. * @param container contains the elements to remove
  49684. * @param dispose if the removed element should be disposed (default: false)
  49685. */
  49686. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49687. /**
  49688. * Serializes the component data to the specified json object
  49689. * @param serializationObject The object to serialize to
  49690. */
  49691. serialize(serializationObject: any): void;
  49692. /**
  49693. * Disposes the component and the associated ressources.
  49694. */
  49695. dispose(): void;
  49696. private _draw;
  49697. }
  49698. }
  49699. declare module "babylonjs/LensFlares/index" {
  49700. export * from "babylonjs/LensFlares/lensFlare";
  49701. export * from "babylonjs/LensFlares/lensFlareSystem";
  49702. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  49703. }
  49704. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  49705. import { Scene } from "babylonjs/scene";
  49706. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49707. import { AbstractScene } from "babylonjs/abstractScene";
  49708. /**
  49709. * Defines the shadow generator component responsible to manage any shadow generators
  49710. * in a given scene.
  49711. */
  49712. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49713. /**
  49714. * The component name helpfull to identify the component in the list of scene components.
  49715. */
  49716. readonly name: string;
  49717. /**
  49718. * The scene the component belongs to.
  49719. */
  49720. scene: Scene;
  49721. /**
  49722. * Creates a new instance of the component for the given scene
  49723. * @param scene Defines the scene to register the component in
  49724. */
  49725. constructor(scene: Scene);
  49726. /**
  49727. * Registers the component in a given scene
  49728. */
  49729. register(): void;
  49730. /**
  49731. * Rebuilds the elements related to this component in case of
  49732. * context lost for instance.
  49733. */
  49734. rebuild(): void;
  49735. /**
  49736. * Serializes the component data to the specified json object
  49737. * @param serializationObject The object to serialize to
  49738. */
  49739. serialize(serializationObject: any): void;
  49740. /**
  49741. * Adds all the element from the container to the scene
  49742. * @param container the container holding the elements
  49743. */
  49744. addFromContainer(container: AbstractScene): void;
  49745. /**
  49746. * Removes all the elements in the container from the scene
  49747. * @param container contains the elements to remove
  49748. * @param dispose if the removed element should be disposed (default: false)
  49749. */
  49750. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49751. /**
  49752. * Rebuilds the elements related to this component in case of
  49753. * context lost for instance.
  49754. */
  49755. dispose(): void;
  49756. private _gatherRenderTargets;
  49757. }
  49758. }
  49759. declare module "babylonjs/Lights/Shadows/index" {
  49760. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  49761. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  49762. }
  49763. declare module "babylonjs/Lights/pointLight" {
  49764. import { Scene } from "babylonjs/scene";
  49765. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49767. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49768. import { Effect } from "babylonjs/Materials/effect";
  49769. /**
  49770. * A point light is a light defined by an unique point in world space.
  49771. * The light is emitted in every direction from this point.
  49772. * A good example of a point light is a standard light bulb.
  49773. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49774. */
  49775. export class PointLight extends ShadowLight {
  49776. private _shadowAngle;
  49777. /**
  49778. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49779. * This specifies what angle the shadow will use to be created.
  49780. *
  49781. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49782. */
  49783. /**
  49784. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49785. * This specifies what angle the shadow will use to be created.
  49786. *
  49787. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49788. */
  49789. shadowAngle: number;
  49790. /**
  49791. * Gets the direction if it has been set.
  49792. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49793. */
  49794. /**
  49795. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49796. */
  49797. direction: Vector3;
  49798. /**
  49799. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49800. * A PointLight emits the light in every direction.
  49801. * It can cast shadows.
  49802. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49803. * ```javascript
  49804. * var pointLight = new PointLight("pl", camera.position, scene);
  49805. * ```
  49806. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49807. * @param name The light friendly name
  49808. * @param position The position of the point light in the scene
  49809. * @param scene The scene the lights belongs to
  49810. */
  49811. constructor(name: string, position: Vector3, scene: Scene);
  49812. /**
  49813. * Returns the string "PointLight"
  49814. * @returns the class name
  49815. */
  49816. getClassName(): string;
  49817. /**
  49818. * Returns the integer 0.
  49819. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49820. */
  49821. getTypeID(): number;
  49822. /**
  49823. * Specifies wether or not the shadowmap should be a cube texture.
  49824. * @returns true if the shadowmap needs to be a cube texture.
  49825. */
  49826. needCube(): boolean;
  49827. /**
  49828. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49829. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49830. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49831. */
  49832. getShadowDirection(faceIndex?: number): Vector3;
  49833. /**
  49834. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49835. * - fov = PI / 2
  49836. * - aspect ratio : 1.0
  49837. * - z-near and far equal to the active camera minZ and maxZ.
  49838. * Returns the PointLight.
  49839. */
  49840. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49841. protected _buildUniformLayout(): void;
  49842. /**
  49843. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49844. * @param effect The effect to update
  49845. * @param lightIndex The index of the light in the effect to update
  49846. * @returns The point light
  49847. */
  49848. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49849. /**
  49850. * Prepares the list of defines specific to the light type.
  49851. * @param defines the list of defines
  49852. * @param lightIndex defines the index of the light for the effect
  49853. */
  49854. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49855. }
  49856. }
  49857. declare module "babylonjs/Lights/index" {
  49858. export * from "babylonjs/Lights/light";
  49859. export * from "babylonjs/Lights/shadowLight";
  49860. export * from "babylonjs/Lights/Shadows/index";
  49861. export * from "babylonjs/Lights/directionalLight";
  49862. export * from "babylonjs/Lights/hemisphericLight";
  49863. export * from "babylonjs/Lights/pointLight";
  49864. export * from "babylonjs/Lights/spotLight";
  49865. }
  49866. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  49867. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49868. /**
  49869. * Header information of HDR texture files.
  49870. */
  49871. export interface HDRInfo {
  49872. /**
  49873. * The height of the texture in pixels.
  49874. */
  49875. height: number;
  49876. /**
  49877. * The width of the texture in pixels.
  49878. */
  49879. width: number;
  49880. /**
  49881. * The index of the beginning of the data in the binary file.
  49882. */
  49883. dataPosition: number;
  49884. }
  49885. /**
  49886. * This groups tools to convert HDR texture to native colors array.
  49887. */
  49888. export class HDRTools {
  49889. private static Ldexp;
  49890. private static Rgbe2float;
  49891. private static readStringLine;
  49892. /**
  49893. * Reads header information from an RGBE texture stored in a native array.
  49894. * More information on this format are available here:
  49895. * https://en.wikipedia.org/wiki/RGBE_image_format
  49896. *
  49897. * @param uint8array The binary file stored in native array.
  49898. * @return The header information.
  49899. */
  49900. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49901. /**
  49902. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49903. * This RGBE texture needs to store the information as a panorama.
  49904. *
  49905. * More information on this format are available here:
  49906. * https://en.wikipedia.org/wiki/RGBE_image_format
  49907. *
  49908. * @param buffer The binary file stored in an array buffer.
  49909. * @param size The expected size of the extracted cubemap.
  49910. * @return The Cube Map information.
  49911. */
  49912. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49913. /**
  49914. * Returns the pixels data extracted from an RGBE texture.
  49915. * This pixels will be stored left to right up to down in the R G B order in one array.
  49916. *
  49917. * More information on this format are available here:
  49918. * https://en.wikipedia.org/wiki/RGBE_image_format
  49919. *
  49920. * @param uint8array The binary file stored in an array buffer.
  49921. * @param hdrInfo The header information of the file.
  49922. * @return The pixels data in RGB right to left up to down order.
  49923. */
  49924. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49925. private static RGBE_ReadPixels_RLE;
  49926. }
  49927. }
  49928. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  49929. import { Nullable } from "babylonjs/types";
  49930. import { Scene } from "babylonjs/scene";
  49931. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49932. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49933. import "babylonjs/Engines/Extensions/engine.rawTexture";
  49934. /**
  49935. * This represents a texture coming from an HDR input.
  49936. *
  49937. * The only supported format is currently panorama picture stored in RGBE format.
  49938. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49939. */
  49940. export class HDRCubeTexture extends BaseTexture {
  49941. private static _facesMapping;
  49942. private _generateHarmonics;
  49943. private _noMipmap;
  49944. private _textureMatrix;
  49945. private _size;
  49946. private _onLoad;
  49947. private _onError;
  49948. /**
  49949. * The texture URL.
  49950. */
  49951. url: string;
  49952. /**
  49953. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49954. */
  49955. coordinatesMode: number;
  49956. protected _isBlocking: boolean;
  49957. /**
  49958. * Sets wether or not the texture is blocking during loading.
  49959. */
  49960. /**
  49961. * Gets wether or not the texture is blocking during loading.
  49962. */
  49963. isBlocking: boolean;
  49964. protected _rotationY: number;
  49965. /**
  49966. * Sets texture matrix rotation angle around Y axis in radians.
  49967. */
  49968. /**
  49969. * Gets texture matrix rotation angle around Y axis radians.
  49970. */
  49971. rotationY: number;
  49972. /**
  49973. * Gets or sets the center of the bounding box associated with the cube texture
  49974. * It must define where the camera used to render the texture was set
  49975. */
  49976. boundingBoxPosition: Vector3;
  49977. private _boundingBoxSize;
  49978. /**
  49979. * Gets or sets the size of the bounding box associated with the cube texture
  49980. * When defined, the cubemap will switch to local mode
  49981. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49982. * @example https://www.babylonjs-playground.com/#RNASML
  49983. */
  49984. boundingBoxSize: Vector3;
  49985. /**
  49986. * Instantiates an HDRTexture from the following parameters.
  49987. *
  49988. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49989. * @param scene The scene the texture will be used in
  49990. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49991. * @param noMipmap Forces to not generate the mipmap if true
  49992. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49993. * @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)
  49994. * @param reserved Reserved flag for internal use.
  49995. */
  49996. 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>);
  49997. /**
  49998. * Get the current class name of the texture useful for serialization or dynamic coding.
  49999. * @returns "HDRCubeTexture"
  50000. */
  50001. getClassName(): string;
  50002. /**
  50003. * Occurs when the file is raw .hdr file.
  50004. */
  50005. private loadTexture;
  50006. clone(): HDRCubeTexture;
  50007. delayLoad(): void;
  50008. /**
  50009. * Get the texture reflection matrix used to rotate/transform the reflection.
  50010. * @returns the reflection matrix
  50011. */
  50012. getReflectionTextureMatrix(): Matrix;
  50013. /**
  50014. * Set the texture reflection matrix used to rotate/transform the reflection.
  50015. * @param value Define the reflection matrix to set
  50016. */
  50017. setReflectionTextureMatrix(value: Matrix): void;
  50018. /**
  50019. * Parses a JSON representation of an HDR Texture in order to create the texture
  50020. * @param parsedTexture Define the JSON representation
  50021. * @param scene Define the scene the texture should be created in
  50022. * @param rootUrl Define the root url in case we need to load relative dependencies
  50023. * @returns the newly created texture after parsing
  50024. */
  50025. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50026. serialize(): any;
  50027. }
  50028. }
  50029. declare module "babylonjs/Physics/physicsEngine" {
  50030. import { Nullable } from "babylonjs/types";
  50031. import { Vector3 } from "babylonjs/Maths/math";
  50032. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50033. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  50034. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  50035. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50036. /**
  50037. * Class used to control physics engine
  50038. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50039. */
  50040. export class PhysicsEngine implements IPhysicsEngine {
  50041. private _physicsPlugin;
  50042. /**
  50043. * Global value used to control the smallest number supported by the simulation
  50044. */
  50045. static Epsilon: number;
  50046. private _impostors;
  50047. private _joints;
  50048. /**
  50049. * Gets the gravity vector used by the simulation
  50050. */
  50051. gravity: Vector3;
  50052. /**
  50053. * Factory used to create the default physics plugin.
  50054. * @returns The default physics plugin
  50055. */
  50056. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50057. /**
  50058. * Creates a new Physics Engine
  50059. * @param gravity defines the gravity vector used by the simulation
  50060. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50061. */
  50062. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50063. /**
  50064. * Sets the gravity vector used by the simulation
  50065. * @param gravity defines the gravity vector to use
  50066. */
  50067. setGravity(gravity: Vector3): void;
  50068. /**
  50069. * Set the time step of the physics engine.
  50070. * Default is 1/60.
  50071. * To slow it down, enter 1/600 for example.
  50072. * To speed it up, 1/30
  50073. * @param newTimeStep defines the new timestep to apply to this world.
  50074. */
  50075. setTimeStep(newTimeStep?: number): void;
  50076. /**
  50077. * Get the time step of the physics engine.
  50078. * @returns the current time step
  50079. */
  50080. getTimeStep(): number;
  50081. /**
  50082. * Release all resources
  50083. */
  50084. dispose(): void;
  50085. /**
  50086. * Gets the name of the current physics plugin
  50087. * @returns the name of the plugin
  50088. */
  50089. getPhysicsPluginName(): string;
  50090. /**
  50091. * Adding a new impostor for the impostor tracking.
  50092. * This will be done by the impostor itself.
  50093. * @param impostor the impostor to add
  50094. */
  50095. addImpostor(impostor: PhysicsImpostor): void;
  50096. /**
  50097. * Remove an impostor from the engine.
  50098. * This impostor and its mesh will not longer be updated by the physics engine.
  50099. * @param impostor the impostor to remove
  50100. */
  50101. removeImpostor(impostor: PhysicsImpostor): void;
  50102. /**
  50103. * Add a joint to the physics engine
  50104. * @param mainImpostor defines the main impostor to which the joint is added.
  50105. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50106. * @param joint defines the joint that will connect both impostors.
  50107. */
  50108. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50109. /**
  50110. * Removes a joint from the simulation
  50111. * @param mainImpostor defines the impostor used with the joint
  50112. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50113. * @param joint defines the joint to remove
  50114. */
  50115. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50116. /**
  50117. * Called by the scene. No need to call it.
  50118. * @param delta defines the timespam between frames
  50119. */
  50120. _step(delta: number): void;
  50121. /**
  50122. * Gets the current plugin used to run the simulation
  50123. * @returns current plugin
  50124. */
  50125. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50126. /**
  50127. * Gets the list of physic impostors
  50128. * @returns an array of PhysicsImpostor
  50129. */
  50130. getImpostors(): Array<PhysicsImpostor>;
  50131. /**
  50132. * Gets the impostor for a physics enabled object
  50133. * @param object defines the object impersonated by the impostor
  50134. * @returns the PhysicsImpostor or null if not found
  50135. */
  50136. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50137. /**
  50138. * Gets the impostor for a physics body object
  50139. * @param body defines physics body used by the impostor
  50140. * @returns the PhysicsImpostor or null if not found
  50141. */
  50142. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50143. /**
  50144. * Does a raycast in the physics world
  50145. * @param from when should the ray start?
  50146. * @param to when should the ray end?
  50147. * @returns PhysicsRaycastResult
  50148. */
  50149. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50150. }
  50151. }
  50152. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  50153. import { Nullable } from "babylonjs/types";
  50154. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50156. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50157. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50158. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50159. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50160. /** @hidden */
  50161. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50162. private _useDeltaForWorldStep;
  50163. world: any;
  50164. name: string;
  50165. private _physicsMaterials;
  50166. private _fixedTimeStep;
  50167. private _cannonRaycastResult;
  50168. private _raycastResult;
  50169. private _removeAfterStep;
  50170. BJSCANNON: any;
  50171. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50172. setGravity(gravity: Vector3): void;
  50173. setTimeStep(timeStep: number): void;
  50174. getTimeStep(): number;
  50175. executeStep(delta: number): void;
  50176. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50177. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50178. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50179. private _processChildMeshes;
  50180. removePhysicsBody(impostor: PhysicsImpostor): void;
  50181. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50182. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50183. private _addMaterial;
  50184. private _checkWithEpsilon;
  50185. private _createShape;
  50186. private _createHeightmap;
  50187. private _minus90X;
  50188. private _plus90X;
  50189. private _tmpPosition;
  50190. private _tmpDeltaPosition;
  50191. private _tmpUnityRotation;
  50192. private _updatePhysicsBodyTransformation;
  50193. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50194. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50195. isSupported(): boolean;
  50196. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50197. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50198. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50199. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50200. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50201. getBodyMass(impostor: PhysicsImpostor): number;
  50202. getBodyFriction(impostor: PhysicsImpostor): number;
  50203. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50204. getBodyRestitution(impostor: PhysicsImpostor): number;
  50205. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50206. sleepBody(impostor: PhysicsImpostor): void;
  50207. wakeUpBody(impostor: PhysicsImpostor): void;
  50208. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50209. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50210. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50211. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50212. getRadius(impostor: PhysicsImpostor): number;
  50213. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50214. dispose(): void;
  50215. private _extendNamespace;
  50216. /**
  50217. * Does a raycast in the physics world
  50218. * @param from when should the ray start?
  50219. * @param to when should the ray end?
  50220. * @returns PhysicsRaycastResult
  50221. */
  50222. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50223. }
  50224. }
  50225. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  50226. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50227. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50228. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50230. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50231. import { Nullable } from "babylonjs/types";
  50232. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50233. /** @hidden */
  50234. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50235. world: any;
  50236. name: string;
  50237. BJSOIMO: any;
  50238. private _raycastResult;
  50239. constructor(iterations?: number, oimoInjection?: any);
  50240. setGravity(gravity: Vector3): void;
  50241. setTimeStep(timeStep: number): void;
  50242. getTimeStep(): number;
  50243. private _tmpImpostorsArray;
  50244. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50245. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50246. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50247. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50248. private _tmpPositionVector;
  50249. removePhysicsBody(impostor: PhysicsImpostor): void;
  50250. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50251. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50252. isSupported(): boolean;
  50253. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50254. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50255. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50256. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50257. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50258. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50259. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50260. getBodyMass(impostor: PhysicsImpostor): number;
  50261. getBodyFriction(impostor: PhysicsImpostor): number;
  50262. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50263. getBodyRestitution(impostor: PhysicsImpostor): number;
  50264. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50265. sleepBody(impostor: PhysicsImpostor): void;
  50266. wakeUpBody(impostor: PhysicsImpostor): void;
  50267. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50268. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50269. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50270. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50271. getRadius(impostor: PhysicsImpostor): number;
  50272. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50273. dispose(): void;
  50274. /**
  50275. * Does a raycast in the physics world
  50276. * @param from when should the ray start?
  50277. * @param to when should the ray end?
  50278. * @returns PhysicsRaycastResult
  50279. */
  50280. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50281. }
  50282. }
  50283. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50284. import { Nullable } from "babylonjs/types";
  50285. import { Scene } from "babylonjs/scene";
  50286. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50287. import { Mesh } from "babylonjs/Meshes/mesh";
  50288. /**
  50289. * Class containing static functions to help procedurally build meshes
  50290. */
  50291. export class RibbonBuilder {
  50292. /**
  50293. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50294. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50295. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50296. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50297. * * 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
  50298. * * 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
  50299. * * 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
  50300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50301. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50302. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50303. * * 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
  50304. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50305. * * 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
  50306. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50308. * @param name defines the name of the mesh
  50309. * @param options defines the options used to create the mesh
  50310. * @param scene defines the hosting scene
  50311. * @returns the ribbon mesh
  50312. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50313. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50314. */
  50315. static CreateRibbon(name: string, options: {
  50316. pathArray: Vector3[][];
  50317. closeArray?: boolean;
  50318. closePath?: boolean;
  50319. offset?: number;
  50320. updatable?: boolean;
  50321. sideOrientation?: number;
  50322. frontUVs?: Vector4;
  50323. backUVs?: Vector4;
  50324. instance?: Mesh;
  50325. invertUV?: boolean;
  50326. uvs?: Vector2[];
  50327. colors?: Color4[];
  50328. }, scene?: Nullable<Scene>): Mesh;
  50329. }
  50330. }
  50331. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50332. import { Nullable } from "babylonjs/types";
  50333. import { Scene } from "babylonjs/scene";
  50334. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50335. import { Mesh } from "babylonjs/Meshes/mesh";
  50336. /**
  50337. * Class containing static functions to help procedurally build meshes
  50338. */
  50339. export class ShapeBuilder {
  50340. /**
  50341. * 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.
  50342. * * 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.
  50343. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50344. * * 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.
  50345. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50346. * * 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
  50347. * * 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
  50348. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50349. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50350. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50351. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50353. * @param name defines the name of the mesh
  50354. * @param options defines the options used to create the mesh
  50355. * @param scene defines the hosting scene
  50356. * @returns the extruded shape mesh
  50357. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50358. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50359. */
  50360. static ExtrudeShape(name: string, options: {
  50361. shape: Vector3[];
  50362. path: Vector3[];
  50363. scale?: number;
  50364. rotation?: number;
  50365. cap?: number;
  50366. updatable?: boolean;
  50367. sideOrientation?: number;
  50368. frontUVs?: Vector4;
  50369. backUVs?: Vector4;
  50370. instance?: Mesh;
  50371. invertUV?: boolean;
  50372. }, scene?: Nullable<Scene>): Mesh;
  50373. /**
  50374. * Creates an custom extruded shape mesh.
  50375. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50376. * * 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.
  50377. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50378. * * 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
  50379. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50380. * * 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
  50381. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50382. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50383. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50384. * * 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
  50385. * * 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
  50386. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50387. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50388. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50389. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50391. * @param name defines the name of the mesh
  50392. * @param options defines the options used to create the mesh
  50393. * @param scene defines the hosting scene
  50394. * @returns the custom extruded shape mesh
  50395. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50396. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50397. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50398. */
  50399. static ExtrudeShapeCustom(name: string, options: {
  50400. shape: Vector3[];
  50401. path: Vector3[];
  50402. scaleFunction?: any;
  50403. rotationFunction?: any;
  50404. ribbonCloseArray?: boolean;
  50405. ribbonClosePath?: boolean;
  50406. cap?: number;
  50407. updatable?: boolean;
  50408. sideOrientation?: number;
  50409. frontUVs?: Vector4;
  50410. backUVs?: Vector4;
  50411. instance?: Mesh;
  50412. invertUV?: boolean;
  50413. }, scene?: Nullable<Scene>): Mesh;
  50414. private static _ExtrudeShapeGeneric;
  50415. }
  50416. }
  50417. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  50418. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  50419. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50420. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50421. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50422. import { Nullable } from "babylonjs/types";
  50423. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50424. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50425. /**
  50426. * AmmoJS Physics plugin
  50427. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50428. * @see https://github.com/kripken/ammo.js/
  50429. */
  50430. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50431. private _useDeltaForWorldStep;
  50432. /**
  50433. * Reference to the Ammo library
  50434. */
  50435. bjsAMMO: any;
  50436. /**
  50437. * Created ammoJS world which physics bodies are added to
  50438. */
  50439. world: any;
  50440. /**
  50441. * Name of the plugin
  50442. */
  50443. name: string;
  50444. private _timeStep;
  50445. private _fixedTimeStep;
  50446. private _maxSteps;
  50447. private _tmpQuaternion;
  50448. private _tmpAmmoTransform;
  50449. private _tmpAmmoQuaternion;
  50450. private _tmpAmmoConcreteContactResultCallback;
  50451. private _collisionConfiguration;
  50452. private _dispatcher;
  50453. private _overlappingPairCache;
  50454. private _solver;
  50455. private _softBodySolver;
  50456. private _tmpAmmoVectorA;
  50457. private _tmpAmmoVectorB;
  50458. private _tmpAmmoVectorC;
  50459. private _tmpAmmoVectorD;
  50460. private _tmpContactCallbackResult;
  50461. private _tmpAmmoVectorRCA;
  50462. private _tmpAmmoVectorRCB;
  50463. private _raycastResult;
  50464. private static readonly DISABLE_COLLISION_FLAG;
  50465. private static readonly KINEMATIC_FLAG;
  50466. private static readonly DISABLE_DEACTIVATION_FLAG;
  50467. /**
  50468. * Initializes the ammoJS plugin
  50469. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50470. * @param ammoInjection can be used to inject your own ammo reference
  50471. */
  50472. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  50473. /**
  50474. * Sets the gravity of the physics world (m/(s^2))
  50475. * @param gravity Gravity to set
  50476. */
  50477. setGravity(gravity: Vector3): void;
  50478. /**
  50479. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50480. * @param timeStep timestep to use in seconds
  50481. */
  50482. setTimeStep(timeStep: number): void;
  50483. /**
  50484. * 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)
  50485. * @param fixedTimeStep fixedTimeStep to use in seconds
  50486. */
  50487. setFixedTimeStep(fixedTimeStep: number): void;
  50488. /**
  50489. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50490. * @param maxSteps the maximum number of steps by the physics engine per frame
  50491. */
  50492. setMaxSteps(maxSteps: number): void;
  50493. /**
  50494. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50495. * @returns the current timestep in seconds
  50496. */
  50497. getTimeStep(): number;
  50498. private _isImpostorInContact;
  50499. private _isImpostorPairInContact;
  50500. private _stepSimulation;
  50501. /**
  50502. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50503. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50504. * After the step the babylon meshes are set to the position of the physics imposters
  50505. * @param delta amount of time to step forward
  50506. * @param impostors array of imposters to update before/after the step
  50507. */
  50508. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50509. /**
  50510. * Update babylon mesh to match physics world object
  50511. * @param impostor imposter to match
  50512. */
  50513. private _afterSoftStep;
  50514. /**
  50515. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50516. * @param impostor imposter to match
  50517. */
  50518. private _ropeStep;
  50519. /**
  50520. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50521. * @param impostor imposter to match
  50522. */
  50523. private _softbodyOrClothStep;
  50524. private _tmpVector;
  50525. private _tmpMatrix;
  50526. /**
  50527. * Applies an impulse on the imposter
  50528. * @param impostor imposter to apply impulse to
  50529. * @param force amount of force to be applied to the imposter
  50530. * @param contactPoint the location to apply the impulse on the imposter
  50531. */
  50532. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50533. /**
  50534. * Applies a force on the imposter
  50535. * @param impostor imposter to apply force
  50536. * @param force amount of force to be applied to the imposter
  50537. * @param contactPoint the location to apply the force on the imposter
  50538. */
  50539. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50540. /**
  50541. * Creates a physics body using the plugin
  50542. * @param impostor the imposter to create the physics body on
  50543. */
  50544. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50545. /**
  50546. * Removes the physics body from the imposter and disposes of the body's memory
  50547. * @param impostor imposter to remove the physics body from
  50548. */
  50549. removePhysicsBody(impostor: PhysicsImpostor): void;
  50550. /**
  50551. * Generates a joint
  50552. * @param impostorJoint the imposter joint to create the joint with
  50553. */
  50554. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50555. /**
  50556. * Removes a joint
  50557. * @param impostorJoint the imposter joint to remove the joint from
  50558. */
  50559. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50560. private _addMeshVerts;
  50561. /**
  50562. * Initialise the soft body vertices to match its object's (mesh) vertices
  50563. * Softbody vertices (nodes) are in world space and to match this
  50564. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50565. * @param impostor to create the softbody for
  50566. */
  50567. private _softVertexData;
  50568. /**
  50569. * Create an impostor's soft body
  50570. * @param impostor to create the softbody for
  50571. */
  50572. private _createSoftbody;
  50573. /**
  50574. * Create cloth for an impostor
  50575. * @param impostor to create the softbody for
  50576. */
  50577. private _createCloth;
  50578. /**
  50579. * Create rope for an impostor
  50580. * @param impostor to create the softbody for
  50581. */
  50582. private _createRope;
  50583. private _addHullVerts;
  50584. private _createShape;
  50585. /**
  50586. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50587. * @param impostor imposter containing the physics body and babylon object
  50588. */
  50589. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50590. /**
  50591. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50592. * @param impostor imposter containing the physics body and babylon object
  50593. * @param newPosition new position
  50594. * @param newRotation new rotation
  50595. */
  50596. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50597. /**
  50598. * If this plugin is supported
  50599. * @returns true if its supported
  50600. */
  50601. isSupported(): boolean;
  50602. /**
  50603. * Sets the linear velocity of the physics body
  50604. * @param impostor imposter to set the velocity on
  50605. * @param velocity velocity to set
  50606. */
  50607. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50608. /**
  50609. * Sets the angular velocity of the physics body
  50610. * @param impostor imposter to set the velocity on
  50611. * @param velocity velocity to set
  50612. */
  50613. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50614. /**
  50615. * gets the linear velocity
  50616. * @param impostor imposter to get linear velocity from
  50617. * @returns linear velocity
  50618. */
  50619. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50620. /**
  50621. * gets the angular velocity
  50622. * @param impostor imposter to get angular velocity from
  50623. * @returns angular velocity
  50624. */
  50625. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50626. /**
  50627. * Sets the mass of physics body
  50628. * @param impostor imposter to set the mass on
  50629. * @param mass mass to set
  50630. */
  50631. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50632. /**
  50633. * Gets the mass of the physics body
  50634. * @param impostor imposter to get the mass from
  50635. * @returns mass
  50636. */
  50637. getBodyMass(impostor: PhysicsImpostor): number;
  50638. /**
  50639. * Gets friction of the impostor
  50640. * @param impostor impostor to get friction from
  50641. * @returns friction value
  50642. */
  50643. getBodyFriction(impostor: PhysicsImpostor): number;
  50644. /**
  50645. * Sets friction of the impostor
  50646. * @param impostor impostor to set friction on
  50647. * @param friction friction value
  50648. */
  50649. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50650. /**
  50651. * Gets restitution of the impostor
  50652. * @param impostor impostor to get restitution from
  50653. * @returns restitution value
  50654. */
  50655. getBodyRestitution(impostor: PhysicsImpostor): number;
  50656. /**
  50657. * Sets resitution of the impostor
  50658. * @param impostor impostor to set resitution on
  50659. * @param restitution resitution value
  50660. */
  50661. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50662. /**
  50663. * Gets pressure inside the impostor
  50664. * @param impostor impostor to get pressure from
  50665. * @returns pressure value
  50666. */
  50667. getBodyPressure(impostor: PhysicsImpostor): number;
  50668. /**
  50669. * Sets pressure inside a soft body impostor
  50670. * Cloth and rope must remain 0 pressure
  50671. * @param impostor impostor to set pressure on
  50672. * @param pressure pressure value
  50673. */
  50674. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50675. /**
  50676. * Gets stiffness of the impostor
  50677. * @param impostor impostor to get stiffness from
  50678. * @returns pressure value
  50679. */
  50680. getBodyStiffness(impostor: PhysicsImpostor): number;
  50681. /**
  50682. * Sets stiffness of the impostor
  50683. * @param impostor impostor to set stiffness on
  50684. * @param stiffness stiffness value from 0 to 1
  50685. */
  50686. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50687. /**
  50688. * Gets velocityIterations of the impostor
  50689. * @param impostor impostor to get velocity iterations from
  50690. * @returns velocityIterations value
  50691. */
  50692. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50693. /**
  50694. * Sets velocityIterations of the impostor
  50695. * @param impostor impostor to set velocity iterations on
  50696. * @param velocityIterations velocityIterations value
  50697. */
  50698. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50699. /**
  50700. * Gets positionIterations of the impostor
  50701. * @param impostor impostor to get position iterations from
  50702. * @returns positionIterations value
  50703. */
  50704. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50705. /**
  50706. * Sets positionIterations of the impostor
  50707. * @param impostor impostor to set position on
  50708. * @param positionIterations positionIterations value
  50709. */
  50710. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50711. /**
  50712. * Append an anchor to a cloth object
  50713. * @param impostor is the cloth impostor to add anchor to
  50714. * @param otherImpostor is the rigid impostor to anchor to
  50715. * @param width ratio across width from 0 to 1
  50716. * @param height ratio up height from 0 to 1
  50717. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50718. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50719. */
  50720. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50721. /**
  50722. * Append an hook to a rope object
  50723. * @param impostor is the rope impostor to add hook to
  50724. * @param otherImpostor is the rigid impostor to hook to
  50725. * @param length ratio along the rope from 0 to 1
  50726. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50727. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50728. */
  50729. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50730. /**
  50731. * Sleeps the physics body and stops it from being active
  50732. * @param impostor impostor to sleep
  50733. */
  50734. sleepBody(impostor: PhysicsImpostor): void;
  50735. /**
  50736. * Activates the physics body
  50737. * @param impostor impostor to activate
  50738. */
  50739. wakeUpBody(impostor: PhysicsImpostor): void;
  50740. /**
  50741. * Updates the distance parameters of the joint
  50742. * @param joint joint to update
  50743. * @param maxDistance maximum distance of the joint
  50744. * @param minDistance minimum distance of the joint
  50745. */
  50746. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50747. /**
  50748. * Sets a motor on the joint
  50749. * @param joint joint to set motor on
  50750. * @param speed speed of the motor
  50751. * @param maxForce maximum force of the motor
  50752. * @param motorIndex index of the motor
  50753. */
  50754. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50755. /**
  50756. * Sets the motors limit
  50757. * @param joint joint to set limit on
  50758. * @param upperLimit upper limit
  50759. * @param lowerLimit lower limit
  50760. */
  50761. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50762. /**
  50763. * Syncs the position and rotation of a mesh with the impostor
  50764. * @param mesh mesh to sync
  50765. * @param impostor impostor to update the mesh with
  50766. */
  50767. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50768. /**
  50769. * Gets the radius of the impostor
  50770. * @param impostor impostor to get radius from
  50771. * @returns the radius
  50772. */
  50773. getRadius(impostor: PhysicsImpostor): number;
  50774. /**
  50775. * Gets the box size of the impostor
  50776. * @param impostor impostor to get box size from
  50777. * @param result the resulting box size
  50778. */
  50779. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50780. /**
  50781. * Disposes of the impostor
  50782. */
  50783. dispose(): void;
  50784. /**
  50785. * Does a raycast in the physics world
  50786. * @param from when should the ray start?
  50787. * @param to when should the ray end?
  50788. * @returns PhysicsRaycastResult
  50789. */
  50790. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50791. }
  50792. }
  50793. declare module "babylonjs/Probes/reflectionProbe" {
  50794. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50795. import { Vector3 } from "babylonjs/Maths/math";
  50796. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50797. import { Nullable } from "babylonjs/types";
  50798. import { Scene } from "babylonjs/scene";
  50799. module "babylonjs/abstractScene" {
  50800. interface AbstractScene {
  50801. /**
  50802. * The list of reflection probes added to the scene
  50803. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50804. */
  50805. reflectionProbes: Array<ReflectionProbe>;
  50806. /**
  50807. * Removes the given reflection probe from this scene.
  50808. * @param toRemove The reflection probe to remove
  50809. * @returns The index of the removed reflection probe
  50810. */
  50811. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50812. /**
  50813. * Adds the given reflection probe to this scene.
  50814. * @param newReflectionProbe The reflection probe to add
  50815. */
  50816. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50817. }
  50818. }
  50819. /**
  50820. * Class used to generate realtime reflection / refraction cube textures
  50821. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50822. */
  50823. export class ReflectionProbe {
  50824. /** defines the name of the probe */
  50825. name: string;
  50826. private _scene;
  50827. private _renderTargetTexture;
  50828. private _projectionMatrix;
  50829. private _viewMatrix;
  50830. private _target;
  50831. private _add;
  50832. private _attachedMesh;
  50833. private _invertYAxis;
  50834. /** Gets or sets probe position (center of the cube map) */
  50835. position: Vector3;
  50836. /**
  50837. * Creates a new reflection probe
  50838. * @param name defines the name of the probe
  50839. * @param size defines the texture resolution (for each face)
  50840. * @param scene defines the hosting scene
  50841. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50842. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50843. */
  50844. constructor(
  50845. /** defines the name of the probe */
  50846. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50847. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50848. samples: number;
  50849. /** Gets or sets the refresh rate to use (on every frame by default) */
  50850. refreshRate: number;
  50851. /**
  50852. * Gets the hosting scene
  50853. * @returns a Scene
  50854. */
  50855. getScene(): Scene;
  50856. /** Gets the internal CubeTexture used to render to */
  50857. readonly cubeTexture: RenderTargetTexture;
  50858. /** Gets the list of meshes to render */
  50859. readonly renderList: Nullable<AbstractMesh[]>;
  50860. /**
  50861. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50862. * @param mesh defines the mesh to attach to
  50863. */
  50864. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50865. /**
  50866. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50867. * @param renderingGroupId The rendering group id corresponding to its index
  50868. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50869. */
  50870. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50871. /**
  50872. * Clean all associated resources
  50873. */
  50874. dispose(): void;
  50875. /**
  50876. * Converts the reflection probe information to a readable string for debug purpose.
  50877. * @param fullDetails Supports for multiple levels of logging within scene loading
  50878. * @returns the human readable reflection probe info
  50879. */
  50880. toString(fullDetails?: boolean): string;
  50881. /**
  50882. * Get the class name of the relfection probe.
  50883. * @returns "ReflectionProbe"
  50884. */
  50885. getClassName(): string;
  50886. /**
  50887. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50888. * @returns The JSON representation of the texture
  50889. */
  50890. serialize(): any;
  50891. /**
  50892. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50893. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50894. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50895. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50896. * @returns The parsed reflection probe if successful
  50897. */
  50898. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50899. }
  50900. }
  50901. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  50902. /** @hidden */
  50903. export var _BabylonLoaderRegistered: boolean;
  50904. }
  50905. declare module "babylonjs/Loading/Plugins/index" {
  50906. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  50907. }
  50908. declare module "babylonjs/Loading/index" {
  50909. export * from "babylonjs/Loading/loadingScreen";
  50910. export * from "babylonjs/Loading/Plugins/index";
  50911. export * from "babylonjs/Loading/sceneLoader";
  50912. export * from "babylonjs/Loading/sceneLoaderFlags";
  50913. }
  50914. declare module "babylonjs/Materials/Background/index" {
  50915. export * from "babylonjs/Materials/Background/backgroundMaterial";
  50916. }
  50917. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  50918. import { Scene } from "babylonjs/scene";
  50919. import { Color3 } from "babylonjs/Maths/math";
  50920. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50921. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50922. /**
  50923. * The Physically based simple base material of BJS.
  50924. *
  50925. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50926. * It is used as the base class for both the specGloss and metalRough conventions.
  50927. */
  50928. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50929. /**
  50930. * Number of Simultaneous lights allowed on the material.
  50931. */
  50932. maxSimultaneousLights: number;
  50933. /**
  50934. * If sets to true, disables all the lights affecting the material.
  50935. */
  50936. disableLighting: boolean;
  50937. /**
  50938. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50939. */
  50940. environmentTexture: BaseTexture;
  50941. /**
  50942. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50943. */
  50944. invertNormalMapX: boolean;
  50945. /**
  50946. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50947. */
  50948. invertNormalMapY: boolean;
  50949. /**
  50950. * Normal map used in the model.
  50951. */
  50952. normalTexture: BaseTexture;
  50953. /**
  50954. * Emissivie color used to self-illuminate the model.
  50955. */
  50956. emissiveColor: Color3;
  50957. /**
  50958. * Emissivie texture used to self-illuminate the model.
  50959. */
  50960. emissiveTexture: BaseTexture;
  50961. /**
  50962. * Occlusion Channel Strenght.
  50963. */
  50964. occlusionStrength: number;
  50965. /**
  50966. * Occlusion Texture of the material (adding extra occlusion effects).
  50967. */
  50968. occlusionTexture: BaseTexture;
  50969. /**
  50970. * Defines the alpha limits in alpha test mode.
  50971. */
  50972. alphaCutOff: number;
  50973. /**
  50974. * Gets the current double sided mode.
  50975. */
  50976. /**
  50977. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50978. */
  50979. doubleSided: boolean;
  50980. /**
  50981. * Stores the pre-calculated light information of a mesh in a texture.
  50982. */
  50983. lightmapTexture: BaseTexture;
  50984. /**
  50985. * If true, the light map contains occlusion information instead of lighting info.
  50986. */
  50987. useLightmapAsShadowmap: boolean;
  50988. /**
  50989. * Instantiates a new PBRMaterial instance.
  50990. *
  50991. * @param name The material name
  50992. * @param scene The scene the material will be use in.
  50993. */
  50994. constructor(name: string, scene: Scene);
  50995. getClassName(): string;
  50996. }
  50997. }
  50998. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  50999. import { Scene } from "babylonjs/scene";
  51000. import { Color3 } from "babylonjs/Maths/math";
  51001. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51002. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51003. /**
  51004. * The PBR material of BJS following the metal roughness convention.
  51005. *
  51006. * This fits to the PBR convention in the GLTF definition:
  51007. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51008. */
  51009. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51010. /**
  51011. * The base color has two different interpretations depending on the value of metalness.
  51012. * When the material is a metal, the base color is the specific measured reflectance value
  51013. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51014. * of the material.
  51015. */
  51016. baseColor: Color3;
  51017. /**
  51018. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51019. * well as opacity information in the alpha channel.
  51020. */
  51021. baseTexture: BaseTexture;
  51022. /**
  51023. * Specifies the metallic scalar value of the material.
  51024. * Can also be used to scale the metalness values of the metallic texture.
  51025. */
  51026. metallic: number;
  51027. /**
  51028. * Specifies the roughness scalar value of the material.
  51029. * Can also be used to scale the roughness values of the metallic texture.
  51030. */
  51031. roughness: number;
  51032. /**
  51033. * Texture containing both the metallic value in the B channel and the
  51034. * roughness value in the G channel to keep better precision.
  51035. */
  51036. metallicRoughnessTexture: BaseTexture;
  51037. /**
  51038. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51039. *
  51040. * @param name The material name
  51041. * @param scene The scene the material will be use in.
  51042. */
  51043. constructor(name: string, scene: Scene);
  51044. /**
  51045. * Return the currrent class name of the material.
  51046. */
  51047. getClassName(): string;
  51048. /**
  51049. * Makes a duplicate of the current material.
  51050. * @param name - name to use for the new material.
  51051. */
  51052. clone(name: string): PBRMetallicRoughnessMaterial;
  51053. /**
  51054. * Serialize the material to a parsable JSON object.
  51055. */
  51056. serialize(): any;
  51057. /**
  51058. * Parses a JSON object correponding to the serialize function.
  51059. */
  51060. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51061. }
  51062. }
  51063. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  51064. import { Scene } from "babylonjs/scene";
  51065. import { Color3 } from "babylonjs/Maths/math";
  51066. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51067. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51068. /**
  51069. * The PBR material of BJS following the specular glossiness convention.
  51070. *
  51071. * This fits to the PBR convention in the GLTF definition:
  51072. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51073. */
  51074. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51075. /**
  51076. * Specifies the diffuse color of the material.
  51077. */
  51078. diffuseColor: Color3;
  51079. /**
  51080. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51081. * channel.
  51082. */
  51083. diffuseTexture: BaseTexture;
  51084. /**
  51085. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51086. */
  51087. specularColor: Color3;
  51088. /**
  51089. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51090. */
  51091. glossiness: number;
  51092. /**
  51093. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51094. */
  51095. specularGlossinessTexture: BaseTexture;
  51096. /**
  51097. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51098. *
  51099. * @param name The material name
  51100. * @param scene The scene the material will be use in.
  51101. */
  51102. constructor(name: string, scene: Scene);
  51103. /**
  51104. * Return the currrent class name of the material.
  51105. */
  51106. getClassName(): string;
  51107. /**
  51108. * Makes a duplicate of the current material.
  51109. * @param name - name to use for the new material.
  51110. */
  51111. clone(name: string): PBRSpecularGlossinessMaterial;
  51112. /**
  51113. * Serialize the material to a parsable JSON object.
  51114. */
  51115. serialize(): any;
  51116. /**
  51117. * Parses a JSON object correponding to the serialize function.
  51118. */
  51119. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51120. }
  51121. }
  51122. declare module "babylonjs/Materials/PBR/index" {
  51123. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51124. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51125. export * from "babylonjs/Materials/PBR/pbrMaterial";
  51126. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  51127. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  51128. }
  51129. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  51130. import { Nullable } from "babylonjs/types";
  51131. import { Scene } from "babylonjs/scene";
  51132. import { Matrix } from "babylonjs/Maths/math";
  51133. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51134. /**
  51135. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51136. * It can help converting any input color in a desired output one. This can then be used to create effects
  51137. * from sepia, black and white to sixties or futuristic rendering...
  51138. *
  51139. * The only supported format is currently 3dl.
  51140. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51141. */
  51142. export class ColorGradingTexture extends BaseTexture {
  51143. /**
  51144. * The current texture matrix. (will always be identity in color grading texture)
  51145. */
  51146. private _textureMatrix;
  51147. /**
  51148. * The texture URL.
  51149. */
  51150. url: string;
  51151. /**
  51152. * Empty line regex stored for GC.
  51153. */
  51154. private static _noneEmptyLineRegex;
  51155. private _engine;
  51156. /**
  51157. * Instantiates a ColorGradingTexture from the following parameters.
  51158. *
  51159. * @param url The location of the color gradind data (currently only supporting 3dl)
  51160. * @param scene The scene the texture will be used in
  51161. */
  51162. constructor(url: string, scene: Scene);
  51163. /**
  51164. * Returns the texture matrix used in most of the material.
  51165. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51166. */
  51167. getTextureMatrix(): Matrix;
  51168. /**
  51169. * Occurs when the file being loaded is a .3dl LUT file.
  51170. */
  51171. private load3dlTexture;
  51172. /**
  51173. * Starts the loading process of the texture.
  51174. */
  51175. private loadTexture;
  51176. /**
  51177. * Clones the color gradind texture.
  51178. */
  51179. clone(): ColorGradingTexture;
  51180. /**
  51181. * Called during delayed load for textures.
  51182. */
  51183. delayLoad(): void;
  51184. /**
  51185. * Parses a color grading texture serialized by Babylon.
  51186. * @param parsedTexture The texture information being parsedTexture
  51187. * @param scene The scene to load the texture in
  51188. * @param rootUrl The root url of the data assets to load
  51189. * @return A color gradind texture
  51190. */
  51191. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51192. /**
  51193. * Serializes the LUT texture to json format.
  51194. */
  51195. serialize(): any;
  51196. }
  51197. }
  51198. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  51199. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51200. import { Scene } from "babylonjs/scene";
  51201. import { Nullable } from "babylonjs/types";
  51202. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51203. /**
  51204. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51205. */
  51206. export class EquiRectangularCubeTexture extends BaseTexture {
  51207. /** The six faces of the cube. */
  51208. private static _FacesMapping;
  51209. private _noMipmap;
  51210. private _onLoad;
  51211. private _onError;
  51212. /** The size of the cubemap. */
  51213. private _size;
  51214. /** The buffer of the image. */
  51215. private _buffer;
  51216. /** The width of the input image. */
  51217. private _width;
  51218. /** The height of the input image. */
  51219. private _height;
  51220. /** The URL to the image. */
  51221. url: string;
  51222. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51223. coordinatesMode: number;
  51224. /**
  51225. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51226. * @param url The location of the image
  51227. * @param scene The scene the texture will be used in
  51228. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51229. * @param noMipmap Forces to not generate the mipmap if true
  51230. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51231. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51232. * @param onLoad — defines a callback called when texture is loaded
  51233. * @param onError — defines a callback called if there is an error
  51234. */
  51235. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51236. /**
  51237. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51238. */
  51239. private loadImage;
  51240. /**
  51241. * Convert the image buffer into a cubemap and create a CubeTexture.
  51242. */
  51243. private loadTexture;
  51244. /**
  51245. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51246. * @param buffer The ArrayBuffer that should be converted.
  51247. * @returns The buffer as Float32Array.
  51248. */
  51249. private getFloat32ArrayFromArrayBuffer;
  51250. /**
  51251. * Get the current class name of the texture useful for serialization or dynamic coding.
  51252. * @returns "EquiRectangularCubeTexture"
  51253. */
  51254. getClassName(): string;
  51255. /**
  51256. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51257. * @returns A clone of the current EquiRectangularCubeTexture.
  51258. */
  51259. clone(): EquiRectangularCubeTexture;
  51260. }
  51261. }
  51262. declare module "babylonjs/Misc/tga" {
  51263. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51264. /**
  51265. * Based on jsTGALoader - Javascript loader for TGA file
  51266. * By Vincent Thibault
  51267. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51268. */
  51269. export class TGATools {
  51270. private static _TYPE_INDEXED;
  51271. private static _TYPE_RGB;
  51272. private static _TYPE_GREY;
  51273. private static _TYPE_RLE_INDEXED;
  51274. private static _TYPE_RLE_RGB;
  51275. private static _TYPE_RLE_GREY;
  51276. private static _ORIGIN_MASK;
  51277. private static _ORIGIN_SHIFT;
  51278. private static _ORIGIN_BL;
  51279. private static _ORIGIN_BR;
  51280. private static _ORIGIN_UL;
  51281. private static _ORIGIN_UR;
  51282. /**
  51283. * Gets the header of a TGA file
  51284. * @param data defines the TGA data
  51285. * @returns the header
  51286. */
  51287. static GetTGAHeader(data: Uint8Array): any;
  51288. /**
  51289. * Uploads TGA content to a Babylon Texture
  51290. * @hidden
  51291. */
  51292. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51293. /** @hidden */
  51294. 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;
  51295. /** @hidden */
  51296. 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;
  51297. /** @hidden */
  51298. 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;
  51299. /** @hidden */
  51300. 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;
  51301. /** @hidden */
  51302. 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;
  51303. /** @hidden */
  51304. 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;
  51305. }
  51306. }
  51307. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  51308. import { Nullable } from "babylonjs/types";
  51309. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51310. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51311. /**
  51312. * Implementation of the TGA Texture Loader.
  51313. * @hidden
  51314. */
  51315. export class _TGATextureLoader implements IInternalTextureLoader {
  51316. /**
  51317. * Defines wether the loader supports cascade loading the different faces.
  51318. */
  51319. readonly supportCascades: boolean;
  51320. /**
  51321. * This returns if the loader support the current file information.
  51322. * @param extension defines the file extension of the file being loaded
  51323. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51324. * @param fallback defines the fallback internal texture if any
  51325. * @param isBase64 defines whether the texture is encoded as a base64
  51326. * @param isBuffer defines whether the texture data are stored as a buffer
  51327. * @returns true if the loader can load the specified file
  51328. */
  51329. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51330. /**
  51331. * Transform the url before loading if required.
  51332. * @param rootUrl the url of the texture
  51333. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51334. * @returns the transformed texture
  51335. */
  51336. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51337. /**
  51338. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51339. * @param rootUrl the url of the texture
  51340. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51341. * @returns the fallback texture
  51342. */
  51343. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51344. /**
  51345. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51346. * @param data contains the texture data
  51347. * @param texture defines the BabylonJS internal texture
  51348. * @param createPolynomials will be true if polynomials have been requested
  51349. * @param onLoad defines the callback to trigger once the texture is ready
  51350. * @param onError defines the callback to trigger in case of error
  51351. */
  51352. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51353. /**
  51354. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51355. * @param data contains the texture data
  51356. * @param texture defines the BabylonJS internal texture
  51357. * @param callback defines the method to call once ready to upload
  51358. */
  51359. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51360. }
  51361. }
  51362. declare module "babylonjs/Materials/Textures/Loaders/index" {
  51363. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51364. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51365. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51366. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  51367. }
  51368. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  51369. import { Scene } from "babylonjs/scene";
  51370. import { Texture } from "babylonjs/Materials/Textures/texture";
  51371. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51372. /**
  51373. * 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.
  51374. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51375. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51376. */
  51377. export class CustomProceduralTexture extends ProceduralTexture {
  51378. private _animate;
  51379. private _time;
  51380. private _config;
  51381. private _texturePath;
  51382. /**
  51383. * Instantiates a new Custom Procedural Texture.
  51384. * 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.
  51385. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51386. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51387. * @param name Define the name of the texture
  51388. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51389. * @param size Define the size of the texture to create
  51390. * @param scene Define the scene the texture belongs to
  51391. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51392. * @param generateMipMaps Define if the texture should creates mip maps or not
  51393. */
  51394. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51395. private _loadJson;
  51396. /**
  51397. * Is the texture ready to be used ? (rendered at least once)
  51398. * @returns true if ready, otherwise, false.
  51399. */
  51400. isReady(): boolean;
  51401. /**
  51402. * Render the texture to its associated render target.
  51403. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51404. */
  51405. render(useCameraPostProcess?: boolean): void;
  51406. /**
  51407. * Update the list of dependant textures samplers in the shader.
  51408. */
  51409. updateTextures(): void;
  51410. /**
  51411. * Update the uniform values of the procedural texture in the shader.
  51412. */
  51413. updateShaderUniforms(): void;
  51414. /**
  51415. * Define if the texture animates or not.
  51416. */
  51417. animate: boolean;
  51418. }
  51419. }
  51420. declare module "babylonjs/Shaders/noise.fragment" {
  51421. /** @hidden */
  51422. export var noisePixelShader: {
  51423. name: string;
  51424. shader: string;
  51425. };
  51426. }
  51427. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  51428. import { Nullable } from "babylonjs/types";
  51429. import { Scene } from "babylonjs/scene";
  51430. import { Texture } from "babylonjs/Materials/Textures/texture";
  51431. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51432. import "babylonjs/Shaders/noise.fragment";
  51433. /**
  51434. * Class used to generate noise procedural textures
  51435. */
  51436. export class NoiseProceduralTexture extends ProceduralTexture {
  51437. private _time;
  51438. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51439. brightness: number;
  51440. /** Defines the number of octaves to process */
  51441. octaves: number;
  51442. /** Defines the level of persistence (0.8 by default) */
  51443. persistence: number;
  51444. /** Gets or sets animation speed factor (default is 1) */
  51445. animationSpeedFactor: number;
  51446. /**
  51447. * Creates a new NoiseProceduralTexture
  51448. * @param name defines the name fo the texture
  51449. * @param size defines the size of the texture (default is 256)
  51450. * @param scene defines the hosting scene
  51451. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51452. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51453. */
  51454. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51455. private _updateShaderUniforms;
  51456. protected _getDefines(): string;
  51457. /** Generate the current state of the procedural texture */
  51458. render(useCameraPostProcess?: boolean): void;
  51459. /**
  51460. * Serializes this noise procedural texture
  51461. * @returns a serialized noise procedural texture object
  51462. */
  51463. serialize(): any;
  51464. /**
  51465. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51466. * @param parsedTexture defines parsed texture data
  51467. * @param scene defines the current scene
  51468. * @param rootUrl defines the root URL containing noise procedural texture information
  51469. * @returns a parsed NoiseProceduralTexture
  51470. */
  51471. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51472. }
  51473. }
  51474. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  51475. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  51476. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  51477. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51478. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  51479. }
  51480. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  51481. import { Nullable } from "babylonjs/types";
  51482. import { Scene } from "babylonjs/scene";
  51483. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51484. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51485. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  51486. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51487. /**
  51488. * Raw cube texture where the raw buffers are passed in
  51489. */
  51490. export class RawCubeTexture extends CubeTexture {
  51491. /**
  51492. * Creates a cube texture where the raw buffers are passed in.
  51493. * @param scene defines the scene the texture is attached to
  51494. * @param data defines the array of data to use to create each face
  51495. * @param size defines the size of the textures
  51496. * @param format defines the format of the data
  51497. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51498. * @param generateMipMaps defines if the engine should generate the mip levels
  51499. * @param invertY defines if data must be stored with Y axis inverted
  51500. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51501. * @param compression defines the compression used (null by default)
  51502. */
  51503. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51504. /**
  51505. * Updates the raw cube texture.
  51506. * @param data defines the data to store
  51507. * @param format defines the data format
  51508. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51509. * @param invertY defines if data must be stored with Y axis inverted
  51510. * @param compression defines the compression used (null by default)
  51511. * @param level defines which level of the texture to update
  51512. */
  51513. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51514. /**
  51515. * Updates a raw cube texture with RGBD encoded data.
  51516. * @param data defines the array of data [mipmap][face] to use to create each face
  51517. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51518. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51519. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51520. * @returns a promsie that resolves when the operation is complete
  51521. */
  51522. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51523. /**
  51524. * Clones the raw cube texture.
  51525. * @return a new cube texture
  51526. */
  51527. clone(): CubeTexture;
  51528. /** @hidden */
  51529. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51530. }
  51531. }
  51532. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  51533. import { Scene } from "babylonjs/scene";
  51534. import { Texture } from "babylonjs/Materials/Textures/texture";
  51535. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51536. /**
  51537. * Class used to store 3D textures containing user data
  51538. */
  51539. export class RawTexture3D extends Texture {
  51540. /** Gets or sets the texture format to use */
  51541. format: number;
  51542. private _engine;
  51543. /**
  51544. * Create a new RawTexture3D
  51545. * @param data defines the data of the texture
  51546. * @param width defines the width of the texture
  51547. * @param height defines the height of the texture
  51548. * @param depth defines the depth of the texture
  51549. * @param format defines the texture format to use
  51550. * @param scene defines the hosting scene
  51551. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51552. * @param invertY defines if texture must be stored with Y axis inverted
  51553. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51554. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51555. */
  51556. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51557. /** Gets or sets the texture format to use */
  51558. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51559. /**
  51560. * Update the texture with new data
  51561. * @param data defines the data to store in the texture
  51562. */
  51563. update(data: ArrayBufferView): void;
  51564. }
  51565. }
  51566. declare module "babylonjs/Materials/Textures/refractionTexture" {
  51567. import { Scene } from "babylonjs/scene";
  51568. import { Plane } from "babylonjs/Maths/math";
  51569. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51570. /**
  51571. * Creates a refraction texture used by refraction channel of the standard material.
  51572. * It is like a mirror but to see through a material.
  51573. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51574. */
  51575. export class RefractionTexture extends RenderTargetTexture {
  51576. /**
  51577. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51578. * 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.
  51579. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51580. */
  51581. refractionPlane: Plane;
  51582. /**
  51583. * Define how deep under the surface we should see.
  51584. */
  51585. depth: number;
  51586. /**
  51587. * Creates a refraction texture used by refraction channel of the standard material.
  51588. * It is like a mirror but to see through a material.
  51589. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51590. * @param name Define the texture name
  51591. * @param size Define the size of the underlying texture
  51592. * @param scene Define the scene the refraction belongs to
  51593. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51594. */
  51595. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51596. /**
  51597. * Clone the refraction texture.
  51598. * @returns the cloned texture
  51599. */
  51600. clone(): RefractionTexture;
  51601. /**
  51602. * Serialize the texture to a JSON representation you could use in Parse later on
  51603. * @returns the serialized JSON representation
  51604. */
  51605. serialize(): any;
  51606. }
  51607. }
  51608. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  51609. import { Nullable } from "babylonjs/types";
  51610. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51611. import { Matrix } from "babylonjs/Maths/math";
  51612. import { Engine } from "babylonjs/Engines/engine";
  51613. import { Scene } from "babylonjs/scene";
  51614. /**
  51615. * Defines the options related to the creation of an HtmlElementTexture
  51616. */
  51617. export interface IHtmlElementTextureOptions {
  51618. /**
  51619. * Defines wether mip maps should be created or not.
  51620. */
  51621. generateMipMaps?: boolean;
  51622. /**
  51623. * Defines the sampling mode of the texture.
  51624. */
  51625. samplingMode?: number;
  51626. /**
  51627. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51628. */
  51629. engine: Nullable<Engine>;
  51630. /**
  51631. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51632. */
  51633. scene: Nullable<Scene>;
  51634. }
  51635. /**
  51636. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51637. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51638. * is automatically managed.
  51639. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51640. * in your application.
  51641. *
  51642. * As the update is not automatic, you need to call them manually.
  51643. */
  51644. export class HtmlElementTexture extends BaseTexture {
  51645. /**
  51646. * The texture URL.
  51647. */
  51648. element: HTMLVideoElement | HTMLCanvasElement;
  51649. private static readonly DefaultOptions;
  51650. private _textureMatrix;
  51651. private _engine;
  51652. private _isVideo;
  51653. private _generateMipMaps;
  51654. private _samplingMode;
  51655. /**
  51656. * Instantiates a HtmlElementTexture from the following parameters.
  51657. *
  51658. * @param name Defines the name of the texture
  51659. * @param element Defines the video or canvas the texture is filled with
  51660. * @param options Defines the other none mandatory texture creation options
  51661. */
  51662. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51663. private _createInternalTexture;
  51664. /**
  51665. * Returns the texture matrix used in most of the material.
  51666. */
  51667. getTextureMatrix(): Matrix;
  51668. /**
  51669. * Updates the content of the texture.
  51670. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51671. */
  51672. update(invertY?: Nullable<boolean>): void;
  51673. }
  51674. }
  51675. declare module "babylonjs/Materials/Textures/index" {
  51676. export * from "babylonjs/Materials/Textures/baseTexture";
  51677. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  51678. export * from "babylonjs/Materials/Textures/cubeTexture";
  51679. export * from "babylonjs/Materials/Textures/dynamicTexture";
  51680. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  51681. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  51682. export * from "babylonjs/Materials/Textures/internalTexture";
  51683. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  51684. export * from "babylonjs/Materials/Textures/Loaders/index";
  51685. export * from "babylonjs/Materials/Textures/mirrorTexture";
  51686. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  51687. export * from "babylonjs/Materials/Textures/Procedurals/index";
  51688. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  51689. export * from "babylonjs/Materials/Textures/rawTexture";
  51690. export * from "babylonjs/Materials/Textures/rawTexture3D";
  51691. export * from "babylonjs/Materials/Textures/refractionTexture";
  51692. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  51693. export * from "babylonjs/Materials/Textures/texture";
  51694. export * from "babylonjs/Materials/Textures/videoTexture";
  51695. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  51696. }
  51697. declare module "babylonjs/Materials/index" {
  51698. export * from "babylonjs/Materials/Background/index";
  51699. export * from "babylonjs/Materials/colorCurves";
  51700. export * from "babylonjs/Materials/effect";
  51701. export * from "babylonjs/Materials/fresnelParameters";
  51702. export * from "babylonjs/Materials/imageProcessingConfiguration";
  51703. export * from "babylonjs/Materials/material";
  51704. export * from "babylonjs/Materials/materialDefines";
  51705. export * from "babylonjs/Materials/materialHelper";
  51706. export * from "babylonjs/Materials/multiMaterial";
  51707. export * from "babylonjs/Materials/PBR/index";
  51708. export * from "babylonjs/Materials/pushMaterial";
  51709. export * from "babylonjs/Materials/shaderMaterial";
  51710. export * from "babylonjs/Materials/standardMaterial";
  51711. export * from "babylonjs/Materials/Textures/index";
  51712. export * from "babylonjs/Materials/uniformBuffer";
  51713. export * from "babylonjs/Materials/materialFlags";
  51714. }
  51715. declare module "babylonjs/Maths/index" {
  51716. export * from "babylonjs/Maths/math.scalar";
  51717. export * from "babylonjs/Maths/math";
  51718. export * from "babylonjs/Maths/sphericalPolynomial";
  51719. }
  51720. declare module "babylonjs/Misc/workerPool" {
  51721. import { IDisposable } from "babylonjs/scene";
  51722. /**
  51723. * Helper class to push actions to a pool of workers.
  51724. */
  51725. export class WorkerPool implements IDisposable {
  51726. private _workerInfos;
  51727. private _pendingActions;
  51728. /**
  51729. * Constructor
  51730. * @param workers Array of workers to use for actions
  51731. */
  51732. constructor(workers: Array<Worker>);
  51733. /**
  51734. * Terminates all workers and clears any pending actions.
  51735. */
  51736. dispose(): void;
  51737. /**
  51738. * Pushes an action to the worker pool. If all the workers are active, the action will be
  51739. * pended until a worker has completed its action.
  51740. * @param action The action to perform. Call onComplete when the action is complete.
  51741. */
  51742. push(action: (worker: Worker, onComplete: () => void) => void): void;
  51743. private _execute;
  51744. }
  51745. }
  51746. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  51747. import { IDisposable } from "babylonjs/scene";
  51748. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51749. /**
  51750. * Configuration for Draco compression
  51751. */
  51752. export interface IDracoCompressionConfiguration {
  51753. /**
  51754. * Configuration for the decoder.
  51755. */
  51756. decoder?: {
  51757. /**
  51758. * The url to the WebAssembly module.
  51759. */
  51760. wasmUrl?: string;
  51761. /**
  51762. * The url to the WebAssembly binary.
  51763. */
  51764. wasmBinaryUrl?: string;
  51765. /**
  51766. * The url to the fallback JavaScript module.
  51767. */
  51768. fallbackUrl?: string;
  51769. };
  51770. }
  51771. /**
  51772. * Draco compression (https://google.github.io/draco/)
  51773. *
  51774. * This class wraps the Draco module.
  51775. *
  51776. * **Encoder**
  51777. *
  51778. * The encoder is not currently implemented.
  51779. *
  51780. * **Decoder**
  51781. *
  51782. * 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.
  51783. *
  51784. * To update the configuration, use the following code:
  51785. * ```javascript
  51786. * DracoCompression.Configuration = {
  51787. * decoder: {
  51788. * wasmUrl: "<url to the WebAssembly library>",
  51789. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51790. * fallbackUrl: "<url to the fallback JavaScript library>",
  51791. * }
  51792. * };
  51793. * ```
  51794. *
  51795. * 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.
  51796. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  51797. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  51798. *
  51799. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  51800. * ```javascript
  51801. * var dracoCompression = new DracoCompression();
  51802. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  51803. * [VertexBuffer.PositionKind]: 0
  51804. * });
  51805. * ```
  51806. *
  51807. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  51808. */
  51809. export class DracoCompression implements IDisposable {
  51810. private _workerPoolPromise;
  51811. /**
  51812. * The configuration. Defaults to the following urls:
  51813. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  51814. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  51815. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  51816. */
  51817. static Configuration: IDracoCompressionConfiguration;
  51818. /**
  51819. * Returns true if the decoder is available.
  51820. */
  51821. static readonly DecoderAvailable: boolean;
  51822. /**
  51823. * Default number of workers to create when creating the draco compression object.
  51824. */
  51825. static DefaultNumWorkers: number;
  51826. private static GetDefaultNumWorkers;
  51827. /**
  51828. * Constructor
  51829. * @param numWorkers The number of workers for async operations
  51830. */
  51831. constructor(numWorkers?: number);
  51832. /**
  51833. * Stop all async operations and release resources.
  51834. */
  51835. dispose(): void;
  51836. /**
  51837. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  51838. * @returns a promise that resolves when ready
  51839. */
  51840. whenReadyAsync(): Promise<void>;
  51841. /**
  51842. * Decode Draco compressed mesh data to vertex data.
  51843. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  51844. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  51845. * @returns A promise that resolves with the decoded vertex data
  51846. */
  51847. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  51848. [kind: string]: number;
  51849. }): Promise<VertexData>;
  51850. /**
  51851. * The worker function that gets converted to a blob url to pass into a worker.
  51852. */
  51853. private static _Worker;
  51854. private _loadDecoderWasmBinaryAsync;
  51855. }
  51856. }
  51857. declare module "babylonjs/Meshes/Compression/index" {
  51858. export * from "babylonjs/Meshes/Compression/dracoCompression";
  51859. }
  51860. declare module "babylonjs/Meshes/csg" {
  51861. import { Nullable } from "babylonjs/types";
  51862. import { Scene } from "babylonjs/scene";
  51863. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  51864. import { Mesh } from "babylonjs/Meshes/mesh";
  51865. import { Material } from "babylonjs/Materials/material";
  51866. /**
  51867. * Class for building Constructive Solid Geometry
  51868. */
  51869. export class CSG {
  51870. private polygons;
  51871. /**
  51872. * The world matrix
  51873. */
  51874. matrix: Matrix;
  51875. /**
  51876. * Stores the position
  51877. */
  51878. position: Vector3;
  51879. /**
  51880. * Stores the rotation
  51881. */
  51882. rotation: Vector3;
  51883. /**
  51884. * Stores the rotation quaternion
  51885. */
  51886. rotationQuaternion: Nullable<Quaternion>;
  51887. /**
  51888. * Stores the scaling vector
  51889. */
  51890. scaling: Vector3;
  51891. /**
  51892. * Convert the Mesh to CSG
  51893. * @param mesh The Mesh to convert to CSG
  51894. * @returns A new CSG from the Mesh
  51895. */
  51896. static FromMesh(mesh: Mesh): CSG;
  51897. /**
  51898. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  51899. * @param polygons Polygons used to construct a CSG solid
  51900. */
  51901. private static FromPolygons;
  51902. /**
  51903. * Clones, or makes a deep copy, of the CSG
  51904. * @returns A new CSG
  51905. */
  51906. clone(): CSG;
  51907. /**
  51908. * Unions this CSG with another CSG
  51909. * @param csg The CSG to union against this CSG
  51910. * @returns The unioned CSG
  51911. */
  51912. union(csg: CSG): CSG;
  51913. /**
  51914. * Unions this CSG with another CSG in place
  51915. * @param csg The CSG to union against this CSG
  51916. */
  51917. unionInPlace(csg: CSG): void;
  51918. /**
  51919. * Subtracts this CSG with another CSG
  51920. * @param csg The CSG to subtract against this CSG
  51921. * @returns A new CSG
  51922. */
  51923. subtract(csg: CSG): CSG;
  51924. /**
  51925. * Subtracts this CSG with another CSG in place
  51926. * @param csg The CSG to subtact against this CSG
  51927. */
  51928. subtractInPlace(csg: CSG): void;
  51929. /**
  51930. * Intersect this CSG with another CSG
  51931. * @param csg The CSG to intersect against this CSG
  51932. * @returns A new CSG
  51933. */
  51934. intersect(csg: CSG): CSG;
  51935. /**
  51936. * Intersects this CSG with another CSG in place
  51937. * @param csg The CSG to intersect against this CSG
  51938. */
  51939. intersectInPlace(csg: CSG): void;
  51940. /**
  51941. * Return a new CSG solid with solid and empty space switched. This solid is
  51942. * not modified.
  51943. * @returns A new CSG solid with solid and empty space switched
  51944. */
  51945. inverse(): CSG;
  51946. /**
  51947. * Inverses the CSG in place
  51948. */
  51949. inverseInPlace(): void;
  51950. /**
  51951. * This is used to keep meshes transformations so they can be restored
  51952. * when we build back a Babylon Mesh
  51953. * NB : All CSG operations are performed in world coordinates
  51954. * @param csg The CSG to copy the transform attributes from
  51955. * @returns This CSG
  51956. */
  51957. copyTransformAttributes(csg: CSG): CSG;
  51958. /**
  51959. * Build Raw mesh from CSG
  51960. * Coordinates here are in world space
  51961. * @param name The name of the mesh geometry
  51962. * @param scene The Scene
  51963. * @param keepSubMeshes Specifies if the submeshes should be kept
  51964. * @returns A new Mesh
  51965. */
  51966. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  51967. /**
  51968. * Build Mesh from CSG taking material and transforms into account
  51969. * @param name The name of the Mesh
  51970. * @param material The material of the Mesh
  51971. * @param scene The Scene
  51972. * @param keepSubMeshes Specifies if submeshes should be kept
  51973. * @returns The new Mesh
  51974. */
  51975. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  51976. }
  51977. }
  51978. declare module "babylonjs/Meshes/trailMesh" {
  51979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51980. import { Mesh } from "babylonjs/Meshes/mesh";
  51981. import { Scene } from "babylonjs/scene";
  51982. /**
  51983. * Class used to create a trail following a mesh
  51984. */
  51985. export class TrailMesh extends Mesh {
  51986. private _generator;
  51987. private _autoStart;
  51988. private _running;
  51989. private _diameter;
  51990. private _length;
  51991. private _sectionPolygonPointsCount;
  51992. private _sectionVectors;
  51993. private _sectionNormalVectors;
  51994. private _beforeRenderObserver;
  51995. /**
  51996. * @constructor
  51997. * @param name The value used by scene.getMeshByName() to do a lookup.
  51998. * @param generator The mesh to generate a trail.
  51999. * @param scene The scene to add this mesh to.
  52000. * @param diameter Diameter of trailing mesh. Default is 1.
  52001. * @param length Length of trailing mesh. Default is 60.
  52002. * @param autoStart Automatically start trailing mesh. Default true.
  52003. */
  52004. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  52005. /**
  52006. * "TrailMesh"
  52007. * @returns "TrailMesh"
  52008. */
  52009. getClassName(): string;
  52010. private _createMesh;
  52011. /**
  52012. * Start trailing mesh.
  52013. */
  52014. start(): void;
  52015. /**
  52016. * Stop trailing mesh.
  52017. */
  52018. stop(): void;
  52019. /**
  52020. * Update trailing mesh geometry.
  52021. */
  52022. update(): void;
  52023. /**
  52024. * Returns a new TrailMesh object.
  52025. * @param name is a string, the name given to the new mesh
  52026. * @param newGenerator use new generator object for cloned trail mesh
  52027. * @returns a new mesh
  52028. */
  52029. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  52030. /**
  52031. * Serializes this trail mesh
  52032. * @param serializationObject object to write serialization to
  52033. */
  52034. serialize(serializationObject: any): void;
  52035. /**
  52036. * Parses a serialized trail mesh
  52037. * @param parsedMesh the serialized mesh
  52038. * @param scene the scene to create the trail mesh in
  52039. * @returns the created trail mesh
  52040. */
  52041. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  52042. }
  52043. }
  52044. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  52045. import { Vector4 } from "babylonjs/Maths/math";
  52046. import { Mesh } from "babylonjs/Meshes/mesh";
  52047. /**
  52048. * Class containing static functions to help procedurally build meshes
  52049. */
  52050. export class TorusKnotBuilder {
  52051. /**
  52052. * Creates a torus knot mesh
  52053. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52054. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52055. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52056. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52058. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52060. * @param name defines the name of the mesh
  52061. * @param options defines the options used to create the mesh
  52062. * @param scene defines the hosting scene
  52063. * @returns the torus knot mesh
  52064. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52065. */
  52066. static CreateTorusKnot(name: string, options: {
  52067. radius?: number;
  52068. tube?: number;
  52069. radialSegments?: number;
  52070. tubularSegments?: number;
  52071. p?: number;
  52072. q?: number;
  52073. updatable?: boolean;
  52074. sideOrientation?: number;
  52075. frontUVs?: Vector4;
  52076. backUVs?: Vector4;
  52077. }, scene: any): Mesh;
  52078. }
  52079. }
  52080. declare module "babylonjs/Meshes/polygonMesh" {
  52081. import { Scene } from "babylonjs/scene";
  52082. import { Vector2, Path2 } from "babylonjs/Maths/math";
  52083. import { Mesh } from "babylonjs/Meshes/mesh";
  52084. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  52085. /**
  52086. * Polygon
  52087. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  52088. */
  52089. export class Polygon {
  52090. /**
  52091. * Creates a rectangle
  52092. * @param xmin bottom X coord
  52093. * @param ymin bottom Y coord
  52094. * @param xmax top X coord
  52095. * @param ymax top Y coord
  52096. * @returns points that make the resulting rectation
  52097. */
  52098. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  52099. /**
  52100. * Creates a circle
  52101. * @param radius radius of circle
  52102. * @param cx scale in x
  52103. * @param cy scale in y
  52104. * @param numberOfSides number of sides that make up the circle
  52105. * @returns points that make the resulting circle
  52106. */
  52107. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  52108. /**
  52109. * Creates a polygon from input string
  52110. * @param input Input polygon data
  52111. * @returns the parsed points
  52112. */
  52113. static Parse(input: string): Vector2[];
  52114. /**
  52115. * Starts building a polygon from x and y coordinates
  52116. * @param x x coordinate
  52117. * @param y y coordinate
  52118. * @returns the started path2
  52119. */
  52120. static StartingAt(x: number, y: number): Path2;
  52121. }
  52122. /**
  52123. * Builds a polygon
  52124. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  52125. */
  52126. export class PolygonMeshBuilder {
  52127. private _points;
  52128. private _outlinepoints;
  52129. private _holes;
  52130. private _name;
  52131. private _scene;
  52132. private _epoints;
  52133. private _eholes;
  52134. private _addToepoint;
  52135. /**
  52136. * Babylon reference to the earcut plugin.
  52137. */
  52138. bjsEarcut: any;
  52139. /**
  52140. * Creates a PolygonMeshBuilder
  52141. * @param name name of the builder
  52142. * @param contours Path of the polygon
  52143. * @param scene scene to add to when creating the mesh
  52144. * @param earcutInjection can be used to inject your own earcut reference
  52145. */
  52146. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  52147. /**
  52148. * Adds a whole within the polygon
  52149. * @param hole Array of points defining the hole
  52150. * @returns this
  52151. */
  52152. addHole(hole: Vector2[]): PolygonMeshBuilder;
  52153. /**
  52154. * Creates the polygon
  52155. * @param updatable If the mesh should be updatable
  52156. * @param depth The depth of the mesh created
  52157. * @returns the created mesh
  52158. */
  52159. build(updatable?: boolean, depth?: number): Mesh;
  52160. /**
  52161. * Creates the polygon
  52162. * @param depth The depth of the mesh created
  52163. * @returns the created VertexData
  52164. */
  52165. buildVertexData(depth?: number): VertexData;
  52166. /**
  52167. * Adds a side to the polygon
  52168. * @param positions points that make the polygon
  52169. * @param normals normals of the polygon
  52170. * @param uvs uvs of the polygon
  52171. * @param indices indices of the polygon
  52172. * @param bounds bounds of the polygon
  52173. * @param points points of the polygon
  52174. * @param depth depth of the polygon
  52175. * @param flip flip of the polygon
  52176. */
  52177. private addSide;
  52178. }
  52179. }
  52180. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  52181. import { Scene } from "babylonjs/scene";
  52182. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  52183. import { Mesh } from "babylonjs/Meshes/mesh";
  52184. import { Nullable } from "babylonjs/types";
  52185. /**
  52186. * Class containing static functions to help procedurally build meshes
  52187. */
  52188. export class PolygonBuilder {
  52189. /**
  52190. * Creates a polygon mesh
  52191. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52192. * * 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
  52193. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52195. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  52196. * * Remember you can only change the shape positions, not their number when updating a polygon
  52197. * @param name defines the name of the mesh
  52198. * @param options defines the options used to create the mesh
  52199. * @param scene defines the hosting scene
  52200. * @param earcutInjection can be used to inject your own earcut reference
  52201. * @returns the polygon mesh
  52202. */
  52203. static CreatePolygon(name: string, options: {
  52204. shape: Vector3[];
  52205. holes?: Vector3[][];
  52206. depth?: number;
  52207. faceUV?: Vector4[];
  52208. faceColors?: Color4[];
  52209. updatable?: boolean;
  52210. sideOrientation?: number;
  52211. frontUVs?: Vector4;
  52212. backUVs?: Vector4;
  52213. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52214. /**
  52215. * Creates an extruded polygon mesh, with depth in the Y direction.
  52216. * * 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)
  52217. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52218. * @param name defines the name of the mesh
  52219. * @param options defines the options used to create the mesh
  52220. * @param scene defines the hosting scene
  52221. * @param earcutInjection can be used to inject your own earcut reference
  52222. * @returns the polygon mesh
  52223. */
  52224. static ExtrudePolygon(name: string, options: {
  52225. shape: Vector3[];
  52226. holes?: Vector3[][];
  52227. depth?: number;
  52228. faceUV?: Vector4[];
  52229. faceColors?: Color4[];
  52230. updatable?: boolean;
  52231. sideOrientation?: number;
  52232. frontUVs?: Vector4;
  52233. backUVs?: Vector4;
  52234. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52235. }
  52236. }
  52237. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  52238. import { Scene } from "babylonjs/scene";
  52239. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52240. import { Mesh } from "babylonjs/Meshes/mesh";
  52241. import { Nullable } from "babylonjs/types";
  52242. /**
  52243. * Class containing static functions to help procedurally build meshes
  52244. */
  52245. export class LatheBuilder {
  52246. /**
  52247. * Creates lathe mesh.
  52248. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52249. * * 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
  52250. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52251. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52252. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52253. * * 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
  52254. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52255. * * 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
  52256. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52257. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52258. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52260. * @param name defines the name of the mesh
  52261. * @param options defines the options used to create the mesh
  52262. * @param scene defines the hosting scene
  52263. * @returns the lathe mesh
  52264. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52265. */
  52266. static CreateLathe(name: string, options: {
  52267. shape: Vector3[];
  52268. radius?: number;
  52269. tessellation?: number;
  52270. clip?: number;
  52271. arc?: number;
  52272. closed?: boolean;
  52273. updatable?: boolean;
  52274. sideOrientation?: number;
  52275. frontUVs?: Vector4;
  52276. backUVs?: Vector4;
  52277. cap?: number;
  52278. invertUV?: boolean;
  52279. }, scene?: Nullable<Scene>): Mesh;
  52280. }
  52281. }
  52282. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  52283. import { Nullable } from "babylonjs/types";
  52284. import { Scene } from "babylonjs/scene";
  52285. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52286. import { Mesh } from "babylonjs/Meshes/mesh";
  52287. /**
  52288. * Class containing static functions to help procedurally build meshes
  52289. */
  52290. export class TubeBuilder {
  52291. /**
  52292. * Creates a tube mesh.
  52293. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52294. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52295. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52296. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52297. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52298. * * 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)
  52299. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52300. * * 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
  52301. * * 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
  52302. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52303. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52304. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52306. * @param name defines the name of the mesh
  52307. * @param options defines the options used to create the mesh
  52308. * @param scene defines the hosting scene
  52309. * @returns the tube mesh
  52310. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52311. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52312. */
  52313. static CreateTube(name: string, options: {
  52314. path: Vector3[];
  52315. radius?: number;
  52316. tessellation?: number;
  52317. radiusFunction?: {
  52318. (i: number, distance: number): number;
  52319. };
  52320. cap?: number;
  52321. arc?: number;
  52322. updatable?: boolean;
  52323. sideOrientation?: number;
  52324. frontUVs?: Vector4;
  52325. backUVs?: Vector4;
  52326. instance?: Mesh;
  52327. invertUV?: boolean;
  52328. }, scene?: Nullable<Scene>): Mesh;
  52329. }
  52330. }
  52331. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  52332. import { Scene } from "babylonjs/scene";
  52333. import { Vector4 } from "babylonjs/Maths/math";
  52334. import { Mesh } from "babylonjs/Meshes/mesh";
  52335. import { Nullable } from "babylonjs/types";
  52336. /**
  52337. * Class containing static functions to help procedurally build meshes
  52338. */
  52339. export class IcoSphereBuilder {
  52340. /**
  52341. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52342. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52343. * * 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`)
  52344. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52345. * * 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
  52346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52347. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52349. * @param name defines the name of the mesh
  52350. * @param options defines the options used to create the mesh
  52351. * @param scene defines the hosting scene
  52352. * @returns the icosahedron mesh
  52353. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52354. */
  52355. static CreateIcoSphere(name: string, options: {
  52356. radius?: number;
  52357. radiusX?: number;
  52358. radiusY?: number;
  52359. radiusZ?: number;
  52360. flat?: boolean;
  52361. subdivisions?: number;
  52362. sideOrientation?: number;
  52363. frontUVs?: Vector4;
  52364. backUVs?: Vector4;
  52365. updatable?: boolean;
  52366. }, scene?: Nullable<Scene>): Mesh;
  52367. }
  52368. }
  52369. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  52370. import { Vector3 } from "babylonjs/Maths/math";
  52371. import { Mesh } from "babylonjs/Meshes/mesh";
  52372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52373. /**
  52374. * Class containing static functions to help procedurally build meshes
  52375. */
  52376. export class DecalBuilder {
  52377. /**
  52378. * Creates a decal mesh.
  52379. * 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
  52380. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52381. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52382. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52383. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52384. * @param name defines the name of the mesh
  52385. * @param sourceMesh defines the mesh where the decal must be applied
  52386. * @param options defines the options used to create the mesh
  52387. * @param scene defines the hosting scene
  52388. * @returns the decal mesh
  52389. * @see https://doc.babylonjs.com/how_to/decals
  52390. */
  52391. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52392. position?: Vector3;
  52393. normal?: Vector3;
  52394. size?: Vector3;
  52395. angle?: number;
  52396. }): Mesh;
  52397. }
  52398. }
  52399. declare module "babylonjs/Meshes/meshBuilder" {
  52400. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  52401. import { Nullable } from "babylonjs/types";
  52402. import { Scene } from "babylonjs/scene";
  52403. import { Mesh } from "babylonjs/Meshes/mesh";
  52404. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52405. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  52406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52407. /**
  52408. * Class containing static functions to help procedurally build meshes
  52409. */
  52410. export class MeshBuilder {
  52411. /**
  52412. * Creates a box mesh
  52413. * * The parameter `size` sets the size (float) of each box side (default 1)
  52414. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52415. * * 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)
  52416. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52417. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52418. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52420. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52421. * @param name defines the name of the mesh
  52422. * @param options defines the options used to create the mesh
  52423. * @param scene defines the hosting scene
  52424. * @returns the box mesh
  52425. */
  52426. static CreateBox(name: string, options: {
  52427. size?: number;
  52428. width?: number;
  52429. height?: number;
  52430. depth?: number;
  52431. faceUV?: Vector4[];
  52432. faceColors?: Color4[];
  52433. sideOrientation?: number;
  52434. frontUVs?: Vector4;
  52435. backUVs?: Vector4;
  52436. updatable?: boolean;
  52437. }, scene?: Nullable<Scene>): Mesh;
  52438. /**
  52439. * Creates a sphere mesh
  52440. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52441. * * 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`)
  52442. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52443. * * 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
  52444. * * 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)
  52445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52446. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52448. * @param name defines the name of the mesh
  52449. * @param options defines the options used to create the mesh
  52450. * @param scene defines the hosting scene
  52451. * @returns the sphere mesh
  52452. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52453. */
  52454. static CreateSphere(name: string, options: {
  52455. segments?: number;
  52456. diameter?: number;
  52457. diameterX?: number;
  52458. diameterY?: number;
  52459. diameterZ?: number;
  52460. arc?: number;
  52461. slice?: number;
  52462. sideOrientation?: number;
  52463. frontUVs?: Vector4;
  52464. backUVs?: Vector4;
  52465. updatable?: boolean;
  52466. }, scene?: Nullable<Scene>): Mesh;
  52467. /**
  52468. * Creates a plane polygonal mesh. By default, this is a disc
  52469. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52470. * * 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
  52471. * * 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
  52472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52473. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52475. * @param name defines the name of the mesh
  52476. * @param options defines the options used to create the mesh
  52477. * @param scene defines the hosting scene
  52478. * @returns the plane polygonal mesh
  52479. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52480. */
  52481. static CreateDisc(name: string, options: {
  52482. radius?: number;
  52483. tessellation?: number;
  52484. arc?: number;
  52485. updatable?: boolean;
  52486. sideOrientation?: number;
  52487. frontUVs?: Vector4;
  52488. backUVs?: Vector4;
  52489. }, scene?: Nullable<Scene>): Mesh;
  52490. /**
  52491. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52492. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52493. * * 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`)
  52494. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52495. * * 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
  52496. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52497. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52499. * @param name defines the name of the mesh
  52500. * @param options defines the options used to create the mesh
  52501. * @param scene defines the hosting scene
  52502. * @returns the icosahedron mesh
  52503. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52504. */
  52505. static CreateIcoSphere(name: string, options: {
  52506. radius?: number;
  52507. radiusX?: number;
  52508. radiusY?: number;
  52509. radiusZ?: number;
  52510. flat?: boolean;
  52511. subdivisions?: number;
  52512. sideOrientation?: number;
  52513. frontUVs?: Vector4;
  52514. backUVs?: Vector4;
  52515. updatable?: boolean;
  52516. }, scene?: Nullable<Scene>): Mesh;
  52517. /**
  52518. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52519. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52520. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52521. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52522. * * 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
  52523. * * 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
  52524. * * 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
  52525. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52526. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52527. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52528. * * 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
  52529. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52530. * * 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
  52531. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52533. * @param name defines the name of the mesh
  52534. * @param options defines the options used to create the mesh
  52535. * @param scene defines the hosting scene
  52536. * @returns the ribbon mesh
  52537. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52538. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52539. */
  52540. static CreateRibbon(name: string, options: {
  52541. pathArray: Vector3[][];
  52542. closeArray?: boolean;
  52543. closePath?: boolean;
  52544. offset?: number;
  52545. updatable?: boolean;
  52546. sideOrientation?: number;
  52547. frontUVs?: Vector4;
  52548. backUVs?: Vector4;
  52549. instance?: Mesh;
  52550. invertUV?: boolean;
  52551. uvs?: Vector2[];
  52552. colors?: Color4[];
  52553. }, scene?: Nullable<Scene>): Mesh;
  52554. /**
  52555. * Creates a cylinder or a cone mesh
  52556. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52557. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52558. * * 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.
  52559. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52560. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52561. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52562. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52563. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52564. * * 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).
  52565. * * 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
  52566. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52567. * * 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
  52568. * * 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.
  52569. * * If `enclose` is false, a ring surface is one element.
  52570. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52571. * * 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
  52572. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52573. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52575. * @param name defines the name of the mesh
  52576. * @param options defines the options used to create the mesh
  52577. * @param scene defines the hosting scene
  52578. * @returns the cylinder mesh
  52579. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52580. */
  52581. static CreateCylinder(name: string, options: {
  52582. height?: number;
  52583. diameterTop?: number;
  52584. diameterBottom?: number;
  52585. diameter?: number;
  52586. tessellation?: number;
  52587. subdivisions?: number;
  52588. arc?: number;
  52589. faceColors?: Color4[];
  52590. faceUV?: Vector4[];
  52591. updatable?: boolean;
  52592. hasRings?: boolean;
  52593. enclose?: boolean;
  52594. sideOrientation?: number;
  52595. frontUVs?: Vector4;
  52596. backUVs?: Vector4;
  52597. }, scene?: Nullable<Scene>): Mesh;
  52598. /**
  52599. * Creates a torus mesh
  52600. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52601. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52602. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52603. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52604. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52606. * @param name defines the name of the mesh
  52607. * @param options defines the options used to create the mesh
  52608. * @param scene defines the hosting scene
  52609. * @returns the torus mesh
  52610. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52611. */
  52612. static CreateTorus(name: string, options: {
  52613. diameter?: number;
  52614. thickness?: number;
  52615. tessellation?: number;
  52616. updatable?: boolean;
  52617. sideOrientation?: number;
  52618. frontUVs?: Vector4;
  52619. backUVs?: Vector4;
  52620. }, scene?: Nullable<Scene>): Mesh;
  52621. /**
  52622. * Creates a torus knot mesh
  52623. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52624. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52625. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52626. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52627. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52628. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52630. * @param name defines the name of the mesh
  52631. * @param options defines the options used to create the mesh
  52632. * @param scene defines the hosting scene
  52633. * @returns the torus knot mesh
  52634. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52635. */
  52636. static CreateTorusKnot(name: string, options: {
  52637. radius?: number;
  52638. tube?: number;
  52639. radialSegments?: number;
  52640. tubularSegments?: number;
  52641. p?: number;
  52642. q?: number;
  52643. updatable?: boolean;
  52644. sideOrientation?: number;
  52645. frontUVs?: Vector4;
  52646. backUVs?: Vector4;
  52647. }, scene?: Nullable<Scene>): Mesh;
  52648. /**
  52649. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52650. * * 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
  52651. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52652. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52653. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52654. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52655. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52656. * * 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
  52657. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52659. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52660. * @param name defines the name of the new line system
  52661. * @param options defines the options used to create the line system
  52662. * @param scene defines the hosting scene
  52663. * @returns a new line system mesh
  52664. */
  52665. static CreateLineSystem(name: string, options: {
  52666. lines: Vector3[][];
  52667. updatable?: boolean;
  52668. instance?: Nullable<LinesMesh>;
  52669. colors?: Nullable<Color4[][]>;
  52670. useVertexAlpha?: boolean;
  52671. }, scene: Nullable<Scene>): LinesMesh;
  52672. /**
  52673. * Creates a line mesh
  52674. * 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
  52675. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52676. * * The parameter `points` is an array successive Vector3
  52677. * * 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
  52678. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52679. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52680. * * When updating an instance, remember that only point positions can change, not the number of points
  52681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52682. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52683. * @param name defines the name of the new line system
  52684. * @param options defines the options used to create the line system
  52685. * @param scene defines the hosting scene
  52686. * @returns a new line mesh
  52687. */
  52688. static CreateLines(name: string, options: {
  52689. points: Vector3[];
  52690. updatable?: boolean;
  52691. instance?: Nullable<LinesMesh>;
  52692. colors?: Color4[];
  52693. useVertexAlpha?: boolean;
  52694. }, scene?: Nullable<Scene>): LinesMesh;
  52695. /**
  52696. * Creates a dashed line mesh
  52697. * * 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
  52698. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52699. * * The parameter `points` is an array successive Vector3
  52700. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52701. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52702. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52703. * * 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
  52704. * * When updating an instance, remember that only point positions can change, not the number of points
  52705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52706. * @param name defines the name of the mesh
  52707. * @param options defines the options used to create the mesh
  52708. * @param scene defines the hosting scene
  52709. * @returns the dashed line mesh
  52710. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52711. */
  52712. static CreateDashedLines(name: string, options: {
  52713. points: Vector3[];
  52714. dashSize?: number;
  52715. gapSize?: number;
  52716. dashNb?: number;
  52717. updatable?: boolean;
  52718. instance?: LinesMesh;
  52719. }, scene?: Nullable<Scene>): LinesMesh;
  52720. /**
  52721. * 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.
  52722. * * 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.
  52723. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52724. * * 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.
  52725. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52726. * * 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
  52727. * * 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
  52728. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52729. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52730. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52731. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52733. * @param name defines the name of the mesh
  52734. * @param options defines the options used to create the mesh
  52735. * @param scene defines the hosting scene
  52736. * @returns the extruded shape mesh
  52737. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52738. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52739. */
  52740. static ExtrudeShape(name: string, options: {
  52741. shape: Vector3[];
  52742. path: Vector3[];
  52743. scale?: number;
  52744. rotation?: number;
  52745. cap?: number;
  52746. updatable?: boolean;
  52747. sideOrientation?: number;
  52748. frontUVs?: Vector4;
  52749. backUVs?: Vector4;
  52750. instance?: Mesh;
  52751. invertUV?: boolean;
  52752. }, scene?: Nullable<Scene>): Mesh;
  52753. /**
  52754. * Creates an custom extruded shape mesh.
  52755. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52756. * * 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.
  52757. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52758. * * 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
  52759. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52760. * * 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
  52761. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52762. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52763. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52764. * * 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
  52765. * * 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
  52766. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52767. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52768. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52769. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52771. * @param name defines the name of the mesh
  52772. * @param options defines the options used to create the mesh
  52773. * @param scene defines the hosting scene
  52774. * @returns the custom extruded shape mesh
  52775. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52776. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52777. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52778. */
  52779. static ExtrudeShapeCustom(name: string, options: {
  52780. shape: Vector3[];
  52781. path: Vector3[];
  52782. scaleFunction?: any;
  52783. rotationFunction?: any;
  52784. ribbonCloseArray?: boolean;
  52785. ribbonClosePath?: boolean;
  52786. cap?: number;
  52787. updatable?: boolean;
  52788. sideOrientation?: number;
  52789. frontUVs?: Vector4;
  52790. backUVs?: Vector4;
  52791. instance?: Mesh;
  52792. invertUV?: boolean;
  52793. }, scene?: Nullable<Scene>): Mesh;
  52794. /**
  52795. * Creates lathe mesh.
  52796. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52797. * * 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
  52798. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52799. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52800. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52801. * * 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
  52802. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52803. * * 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
  52804. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52805. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52806. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52808. * @param name defines the name of the mesh
  52809. * @param options defines the options used to create the mesh
  52810. * @param scene defines the hosting scene
  52811. * @returns the lathe mesh
  52812. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52813. */
  52814. static CreateLathe(name: string, options: {
  52815. shape: Vector3[];
  52816. radius?: number;
  52817. tessellation?: number;
  52818. clip?: number;
  52819. arc?: number;
  52820. closed?: boolean;
  52821. updatable?: boolean;
  52822. sideOrientation?: number;
  52823. frontUVs?: Vector4;
  52824. backUVs?: Vector4;
  52825. cap?: number;
  52826. invertUV?: boolean;
  52827. }, scene?: Nullable<Scene>): Mesh;
  52828. /**
  52829. * Creates a plane mesh
  52830. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  52831. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  52832. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  52833. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52834. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52836. * @param name defines the name of the mesh
  52837. * @param options defines the options used to create the mesh
  52838. * @param scene defines the hosting scene
  52839. * @returns the plane mesh
  52840. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  52841. */
  52842. static CreatePlane(name: string, options: {
  52843. size?: number;
  52844. width?: number;
  52845. height?: number;
  52846. sideOrientation?: number;
  52847. frontUVs?: Vector4;
  52848. backUVs?: Vector4;
  52849. updatable?: boolean;
  52850. sourcePlane?: Plane;
  52851. }, scene?: Nullable<Scene>): Mesh;
  52852. /**
  52853. * Creates a ground mesh
  52854. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  52855. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  52856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52857. * @param name defines the name of the mesh
  52858. * @param options defines the options used to create the mesh
  52859. * @param scene defines the hosting scene
  52860. * @returns the ground mesh
  52861. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  52862. */
  52863. static CreateGround(name: string, options: {
  52864. width?: number;
  52865. height?: number;
  52866. subdivisions?: number;
  52867. subdivisionsX?: number;
  52868. subdivisionsY?: number;
  52869. updatable?: boolean;
  52870. }, scene?: Nullable<Scene>): Mesh;
  52871. /**
  52872. * Creates a tiled ground mesh
  52873. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  52874. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  52875. * * 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
  52876. * * 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
  52877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52878. * @param name defines the name of the mesh
  52879. * @param options defines the options used to create the mesh
  52880. * @param scene defines the hosting scene
  52881. * @returns the tiled ground mesh
  52882. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  52883. */
  52884. static CreateTiledGround(name: string, options: {
  52885. xmin: number;
  52886. zmin: number;
  52887. xmax: number;
  52888. zmax: number;
  52889. subdivisions?: {
  52890. w: number;
  52891. h: number;
  52892. };
  52893. precision?: {
  52894. w: number;
  52895. h: number;
  52896. };
  52897. updatable?: boolean;
  52898. }, scene?: Nullable<Scene>): Mesh;
  52899. /**
  52900. * Creates a ground mesh from a height map
  52901. * * The parameter `url` sets the URL of the height map image resource.
  52902. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  52903. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  52904. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  52905. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  52906. * * 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.
  52907. * * 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).
  52908. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  52909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52910. * @param name defines the name of the mesh
  52911. * @param url defines the url to the height map
  52912. * @param options defines the options used to create the mesh
  52913. * @param scene defines the hosting scene
  52914. * @returns the ground mesh
  52915. * @see https://doc.babylonjs.com/babylon101/height_map
  52916. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  52917. */
  52918. static CreateGroundFromHeightMap(name: string, url: string, options: {
  52919. width?: number;
  52920. height?: number;
  52921. subdivisions?: number;
  52922. minHeight?: number;
  52923. maxHeight?: number;
  52924. colorFilter?: Color3;
  52925. alphaFilter?: number;
  52926. updatable?: boolean;
  52927. onReady?: (mesh: GroundMesh) => void;
  52928. }, scene?: Nullable<Scene>): GroundMesh;
  52929. /**
  52930. * Creates a polygon mesh
  52931. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52932. * * 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
  52933. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52935. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  52936. * * Remember you can only change the shape positions, not their number when updating a polygon
  52937. * @param name defines the name of the mesh
  52938. * @param options defines the options used to create the mesh
  52939. * @param scene defines the hosting scene
  52940. * @param earcutInjection can be used to inject your own earcut reference
  52941. * @returns the polygon mesh
  52942. */
  52943. static CreatePolygon(name: string, options: {
  52944. shape: Vector3[];
  52945. holes?: Vector3[][];
  52946. depth?: number;
  52947. faceUV?: Vector4[];
  52948. faceColors?: Color4[];
  52949. updatable?: boolean;
  52950. sideOrientation?: number;
  52951. frontUVs?: Vector4;
  52952. backUVs?: Vector4;
  52953. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52954. /**
  52955. * Creates an extruded polygon mesh, with depth in the Y direction.
  52956. * * 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)
  52957. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52958. * @param name defines the name of the mesh
  52959. * @param options defines the options used to create the mesh
  52960. * @param scene defines the hosting scene
  52961. * @param earcutInjection can be used to inject your own earcut reference
  52962. * @returns the polygon mesh
  52963. */
  52964. static ExtrudePolygon(name: string, options: {
  52965. shape: Vector3[];
  52966. holes?: Vector3[][];
  52967. depth?: number;
  52968. faceUV?: Vector4[];
  52969. faceColors?: Color4[];
  52970. updatable?: boolean;
  52971. sideOrientation?: number;
  52972. frontUVs?: Vector4;
  52973. backUVs?: Vector4;
  52974. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52975. /**
  52976. * Creates a tube mesh.
  52977. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52978. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52979. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52980. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52981. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52982. * * 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)
  52983. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52984. * * 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
  52985. * * 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
  52986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52987. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52988. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52990. * @param name defines the name of the mesh
  52991. * @param options defines the options used to create the mesh
  52992. * @param scene defines the hosting scene
  52993. * @returns the tube mesh
  52994. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52995. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52996. */
  52997. static CreateTube(name: string, options: {
  52998. path: Vector3[];
  52999. radius?: number;
  53000. tessellation?: number;
  53001. radiusFunction?: {
  53002. (i: number, distance: number): number;
  53003. };
  53004. cap?: number;
  53005. arc?: number;
  53006. updatable?: boolean;
  53007. sideOrientation?: number;
  53008. frontUVs?: Vector4;
  53009. backUVs?: Vector4;
  53010. instance?: Mesh;
  53011. invertUV?: boolean;
  53012. }, scene?: Nullable<Scene>): Mesh;
  53013. /**
  53014. * Creates a polyhedron mesh
  53015. * * 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
  53016. * * The parameter `size` (positive float, default 1) sets the polygon size
  53017. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53018. * * 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`
  53019. * * 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
  53020. * * 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)`)
  53021. * * 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
  53022. * * 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
  53023. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53024. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53026. * @param name defines the name of the mesh
  53027. * @param options defines the options used to create the mesh
  53028. * @param scene defines the hosting scene
  53029. * @returns the polyhedron mesh
  53030. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53031. */
  53032. static CreatePolyhedron(name: string, options: {
  53033. type?: number;
  53034. size?: number;
  53035. sizeX?: number;
  53036. sizeY?: number;
  53037. sizeZ?: number;
  53038. custom?: any;
  53039. faceUV?: Vector4[];
  53040. faceColors?: Color4[];
  53041. flat?: boolean;
  53042. updatable?: boolean;
  53043. sideOrientation?: number;
  53044. frontUVs?: Vector4;
  53045. backUVs?: Vector4;
  53046. }, scene?: Nullable<Scene>): Mesh;
  53047. /**
  53048. * Creates a decal mesh.
  53049. * 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
  53050. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53051. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53052. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53053. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53054. * @param name defines the name of the mesh
  53055. * @param sourceMesh defines the mesh where the decal must be applied
  53056. * @param options defines the options used to create the mesh
  53057. * @param scene defines the hosting scene
  53058. * @returns the decal mesh
  53059. * @see https://doc.babylonjs.com/how_to/decals
  53060. */
  53061. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53062. position?: Vector3;
  53063. normal?: Vector3;
  53064. size?: Vector3;
  53065. angle?: number;
  53066. }): Mesh;
  53067. }
  53068. }
  53069. declare module "babylonjs/Meshes/meshSimplification" {
  53070. import { Mesh } from "babylonjs/Meshes/mesh";
  53071. /**
  53072. * A simplifier interface for future simplification implementations
  53073. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53074. */
  53075. export interface ISimplifier {
  53076. /**
  53077. * Simplification of a given mesh according to the given settings.
  53078. * Since this requires computation, it is assumed that the function runs async.
  53079. * @param settings The settings of the simplification, including quality and distance
  53080. * @param successCallback A callback that will be called after the mesh was simplified.
  53081. * @param errorCallback in case of an error, this callback will be called. optional.
  53082. */
  53083. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  53084. }
  53085. /**
  53086. * Expected simplification settings.
  53087. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  53088. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53089. */
  53090. export interface ISimplificationSettings {
  53091. /**
  53092. * Gets or sets the expected quality
  53093. */
  53094. quality: number;
  53095. /**
  53096. * Gets or sets the distance when this optimized version should be used
  53097. */
  53098. distance: number;
  53099. /**
  53100. * Gets an already optimized mesh
  53101. */
  53102. optimizeMesh?: boolean;
  53103. }
  53104. /**
  53105. * Class used to specify simplification options
  53106. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53107. */
  53108. export class SimplificationSettings implements ISimplificationSettings {
  53109. /** expected quality */
  53110. quality: number;
  53111. /** distance when this optimized version should be used */
  53112. distance: number;
  53113. /** already optimized mesh */
  53114. optimizeMesh?: boolean | undefined;
  53115. /**
  53116. * Creates a SimplificationSettings
  53117. * @param quality expected quality
  53118. * @param distance distance when this optimized version should be used
  53119. * @param optimizeMesh already optimized mesh
  53120. */
  53121. constructor(
  53122. /** expected quality */
  53123. quality: number,
  53124. /** distance when this optimized version should be used */
  53125. distance: number,
  53126. /** already optimized mesh */
  53127. optimizeMesh?: boolean | undefined);
  53128. }
  53129. /**
  53130. * Interface used to define a simplification task
  53131. */
  53132. export interface ISimplificationTask {
  53133. /**
  53134. * Array of settings
  53135. */
  53136. settings: Array<ISimplificationSettings>;
  53137. /**
  53138. * Simplification type
  53139. */
  53140. simplificationType: SimplificationType;
  53141. /**
  53142. * Mesh to simplify
  53143. */
  53144. mesh: Mesh;
  53145. /**
  53146. * Callback called on success
  53147. */
  53148. successCallback?: () => void;
  53149. /**
  53150. * Defines if parallel processing can be used
  53151. */
  53152. parallelProcessing: boolean;
  53153. }
  53154. /**
  53155. * Queue used to order the simplification tasks
  53156. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53157. */
  53158. export class SimplificationQueue {
  53159. private _simplificationArray;
  53160. /**
  53161. * Gets a boolean indicating that the process is still running
  53162. */
  53163. running: boolean;
  53164. /**
  53165. * Creates a new queue
  53166. */
  53167. constructor();
  53168. /**
  53169. * Adds a new simplification task
  53170. * @param task defines a task to add
  53171. */
  53172. addTask(task: ISimplificationTask): void;
  53173. /**
  53174. * Execute next task
  53175. */
  53176. executeNext(): void;
  53177. /**
  53178. * Execute a simplification task
  53179. * @param task defines the task to run
  53180. */
  53181. runSimplification(task: ISimplificationTask): void;
  53182. private getSimplifier;
  53183. }
  53184. /**
  53185. * The implemented types of simplification
  53186. * At the moment only Quadratic Error Decimation is implemented
  53187. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53188. */
  53189. export enum SimplificationType {
  53190. /** Quadratic error decimation */
  53191. QUADRATIC = 0
  53192. }
  53193. }
  53194. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  53195. import { Scene } from "babylonjs/scene";
  53196. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  53197. import { ISceneComponent } from "babylonjs/sceneComponent";
  53198. module "babylonjs/scene" {
  53199. interface Scene {
  53200. /** @hidden (Backing field) */
  53201. _simplificationQueue: SimplificationQueue;
  53202. /**
  53203. * Gets or sets the simplification queue attached to the scene
  53204. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53205. */
  53206. simplificationQueue: SimplificationQueue;
  53207. }
  53208. }
  53209. module "babylonjs/Meshes/mesh" {
  53210. interface Mesh {
  53211. /**
  53212. * Simplify the mesh according to the given array of settings.
  53213. * Function will return immediately and will simplify async
  53214. * @param settings a collection of simplification settings
  53215. * @param parallelProcessing should all levels calculate parallel or one after the other
  53216. * @param simplificationType the type of simplification to run
  53217. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  53218. * @returns the current mesh
  53219. */
  53220. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  53221. }
  53222. }
  53223. /**
  53224. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  53225. * created in a scene
  53226. */
  53227. export class SimplicationQueueSceneComponent implements ISceneComponent {
  53228. /**
  53229. * The component name helpfull to identify the component in the list of scene components.
  53230. */
  53231. readonly name: string;
  53232. /**
  53233. * The scene the component belongs to.
  53234. */
  53235. scene: Scene;
  53236. /**
  53237. * Creates a new instance of the component for the given scene
  53238. * @param scene Defines the scene to register the component in
  53239. */
  53240. constructor(scene: Scene);
  53241. /**
  53242. * Registers the component in a given scene
  53243. */
  53244. register(): void;
  53245. /**
  53246. * Rebuilds the elements related to this component in case of
  53247. * context lost for instance.
  53248. */
  53249. rebuild(): void;
  53250. /**
  53251. * Disposes the component and the associated ressources
  53252. */
  53253. dispose(): void;
  53254. private _beforeCameraUpdate;
  53255. }
  53256. }
  53257. declare module "babylonjs/Meshes/Builders/index" {
  53258. export * from "babylonjs/Meshes/Builders/boxBuilder";
  53259. export * from "babylonjs/Meshes/Builders/discBuilder";
  53260. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  53261. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  53262. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  53263. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  53264. export * from "babylonjs/Meshes/Builders/torusBuilder";
  53265. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  53266. export * from "babylonjs/Meshes/Builders/linesBuilder";
  53267. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  53268. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  53269. export * from "babylonjs/Meshes/Builders/latheBuilder";
  53270. export * from "babylonjs/Meshes/Builders/planeBuilder";
  53271. export * from "babylonjs/Meshes/Builders/groundBuilder";
  53272. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  53273. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  53274. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  53275. export * from "babylonjs/Meshes/Builders/decalBuilder";
  53276. }
  53277. declare module "babylonjs/Meshes/index" {
  53278. export * from "babylonjs/Meshes/abstractMesh";
  53279. export * from "babylonjs/Meshes/buffer";
  53280. export * from "babylonjs/Meshes/Compression/index";
  53281. export * from "babylonjs/Meshes/csg";
  53282. export * from "babylonjs/Meshes/geometry";
  53283. export * from "babylonjs/Meshes/groundMesh";
  53284. export * from "babylonjs/Meshes/trailMesh";
  53285. export * from "babylonjs/Meshes/instancedMesh";
  53286. export * from "babylonjs/Meshes/linesMesh";
  53287. export * from "babylonjs/Meshes/mesh";
  53288. export * from "babylonjs/Meshes/mesh.vertexData";
  53289. export * from "babylonjs/Meshes/meshBuilder";
  53290. export * from "babylonjs/Meshes/meshSimplification";
  53291. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  53292. export * from "babylonjs/Meshes/polygonMesh";
  53293. export * from "babylonjs/Meshes/subMesh";
  53294. export * from "babylonjs/Meshes/meshLODLevel";
  53295. export * from "babylonjs/Meshes/transformNode";
  53296. export * from "babylonjs/Meshes/Builders/index";
  53297. export * from "babylonjs/Meshes/dataBuffer";
  53298. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  53299. }
  53300. declare module "babylonjs/Morph/index" {
  53301. export * from "babylonjs/Morph/morphTarget";
  53302. export * from "babylonjs/Morph/morphTargetManager";
  53303. }
  53304. declare module "babylonjs/Offline/database" {
  53305. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  53306. /**
  53307. * Class used to enable access to IndexedDB
  53308. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  53309. */
  53310. export class Database implements IOfflineProvider {
  53311. private _callbackManifestChecked;
  53312. private _currentSceneUrl;
  53313. private _db;
  53314. private _enableSceneOffline;
  53315. private _enableTexturesOffline;
  53316. private _manifestVersionFound;
  53317. private _mustUpdateRessources;
  53318. private _hasReachedQuota;
  53319. private _isSupported;
  53320. private _idbFactory;
  53321. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53322. private static IsUASupportingBlobStorage;
  53323. /**
  53324. * Gets a boolean indicating if Database storate is enabled (off by default)
  53325. */
  53326. static IDBStorageEnabled: boolean;
  53327. /**
  53328. * Gets a boolean indicating if scene must be saved in the database
  53329. */
  53330. readonly enableSceneOffline: boolean;
  53331. /**
  53332. * Gets a boolean indicating if textures must be saved in the database
  53333. */
  53334. readonly enableTexturesOffline: boolean;
  53335. /**
  53336. * Creates a new Database
  53337. * @param urlToScene defines the url to load the scene
  53338. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53339. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53340. */
  53341. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53342. private static _ParseURL;
  53343. private static _ReturnFullUrlLocation;
  53344. private _checkManifestFile;
  53345. /**
  53346. * Open the database and make it available
  53347. * @param successCallback defines the callback to call on success
  53348. * @param errorCallback defines the callback to call on error
  53349. */
  53350. open(successCallback: () => void, errorCallback: () => void): void;
  53351. /**
  53352. * Loads an image from the database
  53353. * @param url defines the url to load from
  53354. * @param image defines the target DOM image
  53355. */
  53356. loadImage(url: string, image: HTMLImageElement): void;
  53357. private _loadImageFromDBAsync;
  53358. private _saveImageIntoDBAsync;
  53359. private _checkVersionFromDB;
  53360. private _loadVersionFromDBAsync;
  53361. private _saveVersionIntoDBAsync;
  53362. /**
  53363. * Loads a file from database
  53364. * @param url defines the URL to load from
  53365. * @param sceneLoaded defines a callback to call on success
  53366. * @param progressCallBack defines a callback to call when progress changed
  53367. * @param errorCallback defines a callback to call on error
  53368. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53369. */
  53370. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53371. private _loadFileAsync;
  53372. private _saveFileAsync;
  53373. /**
  53374. * Validates if xhr data is correct
  53375. * @param xhr defines the request to validate
  53376. * @param dataType defines the expected data type
  53377. * @returns true if data is correct
  53378. */
  53379. private static _ValidateXHRData;
  53380. }
  53381. }
  53382. declare module "babylonjs/Offline/index" {
  53383. export * from "babylonjs/Offline/database";
  53384. export * from "babylonjs/Offline/IOfflineProvider";
  53385. }
  53386. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  53387. /** @hidden */
  53388. export var gpuUpdateParticlesPixelShader: {
  53389. name: string;
  53390. shader: string;
  53391. };
  53392. }
  53393. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  53394. /** @hidden */
  53395. export var gpuUpdateParticlesVertexShader: {
  53396. name: string;
  53397. shader: string;
  53398. };
  53399. }
  53400. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  53401. /** @hidden */
  53402. export var clipPlaneFragmentDeclaration2: {
  53403. name: string;
  53404. shader: string;
  53405. };
  53406. }
  53407. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  53408. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  53409. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53410. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53411. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53412. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53413. /** @hidden */
  53414. export var gpuRenderParticlesPixelShader: {
  53415. name: string;
  53416. shader: string;
  53417. };
  53418. }
  53419. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  53420. /** @hidden */
  53421. export var clipPlaneVertexDeclaration2: {
  53422. name: string;
  53423. shader: string;
  53424. };
  53425. }
  53426. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  53427. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  53428. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53429. /** @hidden */
  53430. export var gpuRenderParticlesVertexShader: {
  53431. name: string;
  53432. shader: string;
  53433. };
  53434. }
  53435. declare module "babylonjs/Particles/gpuParticleSystem" {
  53436. import { Nullable } from "babylonjs/types";
  53437. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  53438. import { Observable } from "babylonjs/Misc/observable";
  53439. import { Color4, Color3 } from "babylonjs/Maths/math";
  53440. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53441. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  53442. import { Scene, IDisposable } from "babylonjs/scene";
  53443. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  53444. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  53445. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  53446. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  53447. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  53448. /**
  53449. * This represents a GPU particle system in Babylon
  53450. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53451. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53452. */
  53453. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53454. /**
  53455. * The layer mask we are rendering the particles through.
  53456. */
  53457. layerMask: number;
  53458. private _capacity;
  53459. private _activeCount;
  53460. private _currentActiveCount;
  53461. private _accumulatedCount;
  53462. private _renderEffect;
  53463. private _updateEffect;
  53464. private _buffer0;
  53465. private _buffer1;
  53466. private _spriteBuffer;
  53467. private _updateVAO;
  53468. private _renderVAO;
  53469. private _targetIndex;
  53470. private _sourceBuffer;
  53471. private _targetBuffer;
  53472. private _engine;
  53473. private _currentRenderId;
  53474. private _started;
  53475. private _stopped;
  53476. private _timeDelta;
  53477. private _randomTexture;
  53478. private _randomTexture2;
  53479. private _attributesStrideSize;
  53480. private _updateEffectOptions;
  53481. private _randomTextureSize;
  53482. private _actualFrame;
  53483. private readonly _rawTextureWidth;
  53484. /**
  53485. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53486. */
  53487. static readonly IsSupported: boolean;
  53488. /**
  53489. * An event triggered when the system is disposed.
  53490. */
  53491. onDisposeObservable: Observable<GPUParticleSystem>;
  53492. /**
  53493. * Gets the maximum number of particles active at the same time.
  53494. * @returns The max number of active particles.
  53495. */
  53496. getCapacity(): number;
  53497. /**
  53498. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53499. * to override the particles.
  53500. */
  53501. forceDepthWrite: boolean;
  53502. /**
  53503. * Gets or set the number of active particles
  53504. */
  53505. activeParticleCount: number;
  53506. private _preWarmDone;
  53507. /**
  53508. * Is this system ready to be used/rendered
  53509. * @return true if the system is ready
  53510. */
  53511. isReady(): boolean;
  53512. /**
  53513. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53514. * @returns True if it has been started, otherwise false.
  53515. */
  53516. isStarted(): boolean;
  53517. /**
  53518. * Starts the particle system and begins to emit
  53519. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53520. */
  53521. start(delay?: number): void;
  53522. /**
  53523. * Stops the particle system.
  53524. */
  53525. stop(): void;
  53526. /**
  53527. * Remove all active particles
  53528. */
  53529. reset(): void;
  53530. /**
  53531. * Returns the string "GPUParticleSystem"
  53532. * @returns a string containing the class name
  53533. */
  53534. getClassName(): string;
  53535. private _colorGradientsTexture;
  53536. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53537. /**
  53538. * Adds a new color gradient
  53539. * @param gradient defines the gradient to use (between 0 and 1)
  53540. * @param color1 defines the color to affect to the specified gradient
  53541. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53542. * @returns the current particle system
  53543. */
  53544. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53545. /**
  53546. * Remove a specific color gradient
  53547. * @param gradient defines the gradient to remove
  53548. * @returns the current particle system
  53549. */
  53550. removeColorGradient(gradient: number): GPUParticleSystem;
  53551. private _angularSpeedGradientsTexture;
  53552. private _sizeGradientsTexture;
  53553. private _velocityGradientsTexture;
  53554. private _limitVelocityGradientsTexture;
  53555. private _dragGradientsTexture;
  53556. private _addFactorGradient;
  53557. /**
  53558. * Adds a new size gradient
  53559. * @param gradient defines the gradient to use (between 0 and 1)
  53560. * @param factor defines the size factor to affect to the specified gradient
  53561. * @returns the current particle system
  53562. */
  53563. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53564. /**
  53565. * Remove a specific size gradient
  53566. * @param gradient defines the gradient to remove
  53567. * @returns the current particle system
  53568. */
  53569. removeSizeGradient(gradient: number): GPUParticleSystem;
  53570. /**
  53571. * Adds a new angular speed gradient
  53572. * @param gradient defines the gradient to use (between 0 and 1)
  53573. * @param factor defines the angular speed to affect to the specified gradient
  53574. * @returns the current particle system
  53575. */
  53576. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53577. /**
  53578. * Remove a specific angular speed gradient
  53579. * @param gradient defines the gradient to remove
  53580. * @returns the current particle system
  53581. */
  53582. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53583. /**
  53584. * Adds a new velocity gradient
  53585. * @param gradient defines the gradient to use (between 0 and 1)
  53586. * @param factor defines the velocity to affect to the specified gradient
  53587. * @returns the current particle system
  53588. */
  53589. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53590. /**
  53591. * Remove a specific velocity gradient
  53592. * @param gradient defines the gradient to remove
  53593. * @returns the current particle system
  53594. */
  53595. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53596. /**
  53597. * Adds a new limit velocity gradient
  53598. * @param gradient defines the gradient to use (between 0 and 1)
  53599. * @param factor defines the limit velocity value to affect to the specified gradient
  53600. * @returns the current particle system
  53601. */
  53602. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53603. /**
  53604. * Remove a specific limit velocity gradient
  53605. * @param gradient defines the gradient to remove
  53606. * @returns the current particle system
  53607. */
  53608. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53609. /**
  53610. * Adds a new drag gradient
  53611. * @param gradient defines the gradient to use (between 0 and 1)
  53612. * @param factor defines the drag value to affect to the specified gradient
  53613. * @returns the current particle system
  53614. */
  53615. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53616. /**
  53617. * Remove a specific drag gradient
  53618. * @param gradient defines the gradient to remove
  53619. * @returns the current particle system
  53620. */
  53621. removeDragGradient(gradient: number): GPUParticleSystem;
  53622. /**
  53623. * Not supported by GPUParticleSystem
  53624. * @param gradient defines the gradient to use (between 0 and 1)
  53625. * @param factor defines the emit rate value to affect to the specified gradient
  53626. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53627. * @returns the current particle system
  53628. */
  53629. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53630. /**
  53631. * Not supported by GPUParticleSystem
  53632. * @param gradient defines the gradient to remove
  53633. * @returns the current particle system
  53634. */
  53635. removeEmitRateGradient(gradient: number): IParticleSystem;
  53636. /**
  53637. * Not supported by GPUParticleSystem
  53638. * @param gradient defines the gradient to use (between 0 and 1)
  53639. * @param factor defines the start size value to affect to the specified gradient
  53640. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53641. * @returns the current particle system
  53642. */
  53643. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53644. /**
  53645. * Not supported by GPUParticleSystem
  53646. * @param gradient defines the gradient to remove
  53647. * @returns the current particle system
  53648. */
  53649. removeStartSizeGradient(gradient: number): IParticleSystem;
  53650. /**
  53651. * Not supported by GPUParticleSystem
  53652. * @param gradient defines the gradient to use (between 0 and 1)
  53653. * @param min defines the color remap minimal range
  53654. * @param max defines the color remap maximal range
  53655. * @returns the current particle system
  53656. */
  53657. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53658. /**
  53659. * Not supported by GPUParticleSystem
  53660. * @param gradient defines the gradient to remove
  53661. * @returns the current particle system
  53662. */
  53663. removeColorRemapGradient(): IParticleSystem;
  53664. /**
  53665. * Not supported by GPUParticleSystem
  53666. * @param gradient defines the gradient to use (between 0 and 1)
  53667. * @param min defines the alpha remap minimal range
  53668. * @param max defines the alpha remap maximal range
  53669. * @returns the current particle system
  53670. */
  53671. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53672. /**
  53673. * Not supported by GPUParticleSystem
  53674. * @param gradient defines the gradient to remove
  53675. * @returns the current particle system
  53676. */
  53677. removeAlphaRemapGradient(): IParticleSystem;
  53678. /**
  53679. * Not supported by GPUParticleSystem
  53680. * @param gradient defines the gradient to use (between 0 and 1)
  53681. * @param color defines the color to affect to the specified gradient
  53682. * @returns the current particle system
  53683. */
  53684. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53685. /**
  53686. * Not supported by GPUParticleSystem
  53687. * @param gradient defines the gradient to remove
  53688. * @returns the current particle system
  53689. */
  53690. removeRampGradient(): IParticleSystem;
  53691. /**
  53692. * Not supported by GPUParticleSystem
  53693. * @returns the list of ramp gradients
  53694. */
  53695. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53696. /**
  53697. * Not supported by GPUParticleSystem
  53698. * Gets or sets a boolean indicating that ramp gradients must be used
  53699. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53700. */
  53701. useRampGradients: boolean;
  53702. /**
  53703. * Not supported by GPUParticleSystem
  53704. * @param gradient defines the gradient to use (between 0 and 1)
  53705. * @param factor defines the life time factor to affect to the specified gradient
  53706. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53707. * @returns the current particle system
  53708. */
  53709. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53710. /**
  53711. * Not supported by GPUParticleSystem
  53712. * @param gradient defines the gradient to remove
  53713. * @returns the current particle system
  53714. */
  53715. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53716. /**
  53717. * Instantiates a GPU particle system.
  53718. * 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.
  53719. * @param name The name of the particle system
  53720. * @param options The options used to create the system
  53721. * @param scene The scene the particle system belongs to
  53722. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53723. */
  53724. constructor(name: string, options: Partial<{
  53725. capacity: number;
  53726. randomTextureSize: number;
  53727. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53728. protected _reset(): void;
  53729. private _createUpdateVAO;
  53730. private _createRenderVAO;
  53731. private _initialize;
  53732. /** @hidden */
  53733. _recreateUpdateEffect(): void;
  53734. /** @hidden */
  53735. _recreateRenderEffect(): void;
  53736. /**
  53737. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53738. * @param preWarm defines if we are in the pre-warmimg phase
  53739. */
  53740. animate(preWarm?: boolean): void;
  53741. private _createFactorGradientTexture;
  53742. private _createSizeGradientTexture;
  53743. private _createAngularSpeedGradientTexture;
  53744. private _createVelocityGradientTexture;
  53745. private _createLimitVelocityGradientTexture;
  53746. private _createDragGradientTexture;
  53747. private _createColorGradientTexture;
  53748. /**
  53749. * Renders the particle system in its current state
  53750. * @param preWarm defines if the system should only update the particles but not render them
  53751. * @returns the current number of particles
  53752. */
  53753. render(preWarm?: boolean): number;
  53754. /**
  53755. * Rebuilds the particle system
  53756. */
  53757. rebuild(): void;
  53758. private _releaseBuffers;
  53759. private _releaseVAOs;
  53760. /**
  53761. * Disposes the particle system and free the associated resources
  53762. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53763. */
  53764. dispose(disposeTexture?: boolean): void;
  53765. /**
  53766. * Clones the particle system.
  53767. * @param name The name of the cloned object
  53768. * @param newEmitter The new emitter to use
  53769. * @returns the cloned particle system
  53770. */
  53771. clone(name: string, newEmitter: any): GPUParticleSystem;
  53772. /**
  53773. * Serializes the particle system to a JSON object.
  53774. * @returns the JSON object
  53775. */
  53776. serialize(): any;
  53777. /**
  53778. * Parses a JSON object to create a GPU particle system.
  53779. * @param parsedParticleSystem The JSON object to parse
  53780. * @param scene The scene to create the particle system in
  53781. * @param rootUrl The root url to use to load external dependencies like texture
  53782. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53783. * @returns the parsed GPU particle system
  53784. */
  53785. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53786. }
  53787. }
  53788. declare module "babylonjs/Particles/particleSystemSet" {
  53789. import { Nullable } from "babylonjs/types";
  53790. import { Color3 } from "babylonjs/Maths/math";
  53791. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53792. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53793. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53794. import { Scene, IDisposable } from "babylonjs/scene";
  53795. /**
  53796. * Represents a set of particle systems working together to create a specific effect
  53797. */
  53798. export class ParticleSystemSet implements IDisposable {
  53799. private _emitterCreationOptions;
  53800. private _emitterNode;
  53801. /**
  53802. * Gets the particle system list
  53803. */
  53804. systems: IParticleSystem[];
  53805. /**
  53806. * Gets the emitter node used with this set
  53807. */
  53808. readonly emitterNode: Nullable<TransformNode>;
  53809. /**
  53810. * Creates a new emitter mesh as a sphere
  53811. * @param options defines the options used to create the sphere
  53812. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  53813. * @param scene defines the hosting scene
  53814. */
  53815. setEmitterAsSphere(options: {
  53816. diameter: number;
  53817. segments: number;
  53818. color: Color3;
  53819. }, renderingGroupId: number, scene: Scene): void;
  53820. /**
  53821. * Starts all particle systems of the set
  53822. * @param emitter defines an optional mesh to use as emitter for the particle systems
  53823. */
  53824. start(emitter?: AbstractMesh): void;
  53825. /**
  53826. * Release all associated resources
  53827. */
  53828. dispose(): void;
  53829. /**
  53830. * Serialize the set into a JSON compatible object
  53831. * @returns a JSON compatible representation of the set
  53832. */
  53833. serialize(): any;
  53834. /**
  53835. * Parse a new ParticleSystemSet from a serialized source
  53836. * @param data defines a JSON compatible representation of the set
  53837. * @param scene defines the hosting scene
  53838. * @param gpu defines if we want GPU particles or CPU particles
  53839. * @returns a new ParticleSystemSet
  53840. */
  53841. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  53842. }
  53843. }
  53844. declare module "babylonjs/Particles/particleHelper" {
  53845. import { Nullable } from "babylonjs/types";
  53846. import { Scene } from "babylonjs/scene";
  53847. import { Vector3 } from "babylonjs/Maths/math";
  53848. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53849. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53850. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  53851. /**
  53852. * This class is made for on one-liner static method to help creating particle system set.
  53853. */
  53854. export class ParticleHelper {
  53855. /**
  53856. * Gets or sets base Assets URL
  53857. */
  53858. static BaseAssetsUrl: string;
  53859. /**
  53860. * Create a default particle system that you can tweak
  53861. * @param emitter defines the emitter to use
  53862. * @param capacity defines the system capacity (default is 500 particles)
  53863. * @param scene defines the hosting scene
  53864. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  53865. * @returns the new Particle system
  53866. */
  53867. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  53868. /**
  53869. * This is the main static method (one-liner) of this helper to create different particle systems
  53870. * @param type This string represents the type to the particle system to create
  53871. * @param scene The scene where the particle system should live
  53872. * @param gpu If the system will use gpu
  53873. * @returns the ParticleSystemSet created
  53874. */
  53875. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  53876. /**
  53877. * Static function used to export a particle system to a ParticleSystemSet variable.
  53878. * Please note that the emitter shape is not exported
  53879. * @param systems defines the particle systems to export
  53880. * @returns the created particle system set
  53881. */
  53882. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  53883. }
  53884. }
  53885. declare module "babylonjs/Particles/particleSystemComponent" {
  53886. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53887. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53888. import "babylonjs/Shaders/particles.vertex";
  53889. module "babylonjs/Engines/engine" {
  53890. interface Engine {
  53891. /**
  53892. * Create an effect to use with particle systems.
  53893. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  53894. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  53895. * @param uniformsNames defines a list of attribute names
  53896. * @param samplers defines an array of string used to represent textures
  53897. * @param defines defines the string containing the defines to use to compile the shaders
  53898. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  53899. * @param onCompiled defines a function to call when the effect creation is successful
  53900. * @param onError defines a function to call when the effect creation has failed
  53901. * @returns the new Effect
  53902. */
  53903. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  53904. }
  53905. }
  53906. module "babylonjs/Meshes/mesh" {
  53907. interface Mesh {
  53908. /**
  53909. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  53910. * @returns an array of IParticleSystem
  53911. */
  53912. getEmittedParticleSystems(): IParticleSystem[];
  53913. /**
  53914. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  53915. * @returns an array of IParticleSystem
  53916. */
  53917. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  53918. }
  53919. }
  53920. /**
  53921. * @hidden
  53922. */
  53923. export var _IDoNeedToBeInTheBuild: number;
  53924. }
  53925. declare module "babylonjs/Particles/index" {
  53926. export * from "babylonjs/Particles/baseParticleSystem";
  53927. export * from "babylonjs/Particles/EmitterTypes/index";
  53928. export * from "babylonjs/Particles/gpuParticleSystem";
  53929. export * from "babylonjs/Particles/IParticleSystem";
  53930. export * from "babylonjs/Particles/particle";
  53931. export * from "babylonjs/Particles/particleHelper";
  53932. export * from "babylonjs/Particles/particleSystem";
  53933. export * from "babylonjs/Particles/particleSystemComponent";
  53934. export * from "babylonjs/Particles/particleSystemSet";
  53935. export * from "babylonjs/Particles/solidParticle";
  53936. export * from "babylonjs/Particles/solidParticleSystem";
  53937. export * from "babylonjs/Particles/subEmitter";
  53938. }
  53939. declare module "babylonjs/Physics/physicsEngineComponent" {
  53940. import { Nullable } from "babylonjs/types";
  53941. import { Observable, Observer } from "babylonjs/Misc/observable";
  53942. import { Vector3 } from "babylonjs/Maths/math";
  53943. import { Mesh } from "babylonjs/Meshes/mesh";
  53944. import { ISceneComponent } from "babylonjs/sceneComponent";
  53945. import { Scene } from "babylonjs/scene";
  53946. import { Node } from "babylonjs/node";
  53947. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53948. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53949. module "babylonjs/scene" {
  53950. interface Scene {
  53951. /** @hidden (Backing field) */
  53952. _physicsEngine: Nullable<IPhysicsEngine>;
  53953. /**
  53954. * Gets the current physics engine
  53955. * @returns a IPhysicsEngine or null if none attached
  53956. */
  53957. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  53958. /**
  53959. * Enables physics to the current scene
  53960. * @param gravity defines the scene's gravity for the physics engine
  53961. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  53962. * @return a boolean indicating if the physics engine was initialized
  53963. */
  53964. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  53965. /**
  53966. * Disables and disposes the physics engine associated with the scene
  53967. */
  53968. disablePhysicsEngine(): void;
  53969. /**
  53970. * Gets a boolean indicating if there is an active physics engine
  53971. * @returns a boolean indicating if there is an active physics engine
  53972. */
  53973. isPhysicsEnabled(): boolean;
  53974. /**
  53975. * Deletes a physics compound impostor
  53976. * @param compound defines the compound to delete
  53977. */
  53978. deleteCompoundImpostor(compound: any): void;
  53979. /**
  53980. * An event triggered when physic simulation is about to be run
  53981. */
  53982. onBeforePhysicsObservable: Observable<Scene>;
  53983. /**
  53984. * An event triggered when physic simulation has been done
  53985. */
  53986. onAfterPhysicsObservable: Observable<Scene>;
  53987. }
  53988. }
  53989. module "babylonjs/Meshes/abstractMesh" {
  53990. interface AbstractMesh {
  53991. /** @hidden */
  53992. _physicsImpostor: Nullable<PhysicsImpostor>;
  53993. /**
  53994. * Gets or sets impostor used for physic simulation
  53995. * @see http://doc.babylonjs.com/features/physics_engine
  53996. */
  53997. physicsImpostor: Nullable<PhysicsImpostor>;
  53998. /**
  53999. * Gets the current physics impostor
  54000. * @see http://doc.babylonjs.com/features/physics_engine
  54001. * @returns a physics impostor or null
  54002. */
  54003. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  54004. /** Apply a physic impulse to the mesh
  54005. * @param force defines the force to apply
  54006. * @param contactPoint defines where to apply the force
  54007. * @returns the current mesh
  54008. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54009. */
  54010. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  54011. /**
  54012. * Creates a physic joint between two meshes
  54013. * @param otherMesh defines the other mesh to use
  54014. * @param pivot1 defines the pivot to use on this mesh
  54015. * @param pivot2 defines the pivot to use on the other mesh
  54016. * @param options defines additional options (can be plugin dependent)
  54017. * @returns the current mesh
  54018. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  54019. */
  54020. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  54021. /** @hidden */
  54022. _disposePhysicsObserver: Nullable<Observer<Node>>;
  54023. }
  54024. }
  54025. /**
  54026. * Defines the physics engine scene component responsible to manage a physics engine
  54027. */
  54028. export class PhysicsEngineSceneComponent implements ISceneComponent {
  54029. /**
  54030. * The component name helpful to identify the component in the list of scene components.
  54031. */
  54032. readonly name: string;
  54033. /**
  54034. * The scene the component belongs to.
  54035. */
  54036. scene: Scene;
  54037. /**
  54038. * Creates a new instance of the component for the given scene
  54039. * @param scene Defines the scene to register the component in
  54040. */
  54041. constructor(scene: Scene);
  54042. /**
  54043. * Registers the component in a given scene
  54044. */
  54045. register(): void;
  54046. /**
  54047. * Rebuilds the elements related to this component in case of
  54048. * context lost for instance.
  54049. */
  54050. rebuild(): void;
  54051. /**
  54052. * Disposes the component and the associated ressources
  54053. */
  54054. dispose(): void;
  54055. }
  54056. }
  54057. declare module "babylonjs/Physics/physicsHelper" {
  54058. import { Nullable } from "babylonjs/types";
  54059. import { Vector3 } from "babylonjs/Maths/math";
  54060. import { Mesh } from "babylonjs/Meshes/mesh";
  54061. import { Scene } from "babylonjs/scene";
  54062. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54063. /**
  54064. * A helper for physics simulations
  54065. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54066. */
  54067. export class PhysicsHelper {
  54068. private _scene;
  54069. private _physicsEngine;
  54070. /**
  54071. * Initializes the Physics helper
  54072. * @param scene Babylon.js scene
  54073. */
  54074. constructor(scene: Scene);
  54075. /**
  54076. * Applies a radial explosion impulse
  54077. * @param origin the origin of the explosion
  54078. * @param radiusOrEventOptions the radius or the options of radial explosion
  54079. * @param strength the explosion strength
  54080. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54081. * @returns A physics radial explosion event, or null
  54082. */
  54083. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54084. /**
  54085. * Applies a radial explosion force
  54086. * @param origin the origin of the explosion
  54087. * @param radiusOrEventOptions the radius or the options of radial explosion
  54088. * @param strength the explosion strength
  54089. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54090. * @returns A physics radial explosion event, or null
  54091. */
  54092. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54093. /**
  54094. * Creates a gravitational field
  54095. * @param origin the origin of the explosion
  54096. * @param radiusOrEventOptions the radius or the options of radial explosion
  54097. * @param strength the explosion strength
  54098. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54099. * @returns A physics gravitational field event, or null
  54100. */
  54101. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  54102. /**
  54103. * Creates a physics updraft event
  54104. * @param origin the origin of the updraft
  54105. * @param radiusOrEventOptions the radius or the options of the updraft
  54106. * @param strength the strength of the updraft
  54107. * @param height the height of the updraft
  54108. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  54109. * @returns A physics updraft event, or null
  54110. */
  54111. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  54112. /**
  54113. * Creates a physics vortex event
  54114. * @param origin the of the vortex
  54115. * @param radiusOrEventOptions the radius or the options of the vortex
  54116. * @param strength the strength of the vortex
  54117. * @param height the height of the vortex
  54118. * @returns a Physics vortex event, or null
  54119. * A physics vortex event or null
  54120. */
  54121. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  54122. }
  54123. /**
  54124. * Represents a physics radial explosion event
  54125. */
  54126. class PhysicsRadialExplosionEvent {
  54127. private _scene;
  54128. private _options;
  54129. private _sphere;
  54130. private _dataFetched;
  54131. /**
  54132. * Initializes a radial explosioin event
  54133. * @param _scene BabylonJS scene
  54134. * @param _options The options for the vortex event
  54135. */
  54136. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  54137. /**
  54138. * Returns the data related to the radial explosion event (sphere).
  54139. * @returns The radial explosion event data
  54140. */
  54141. getData(): PhysicsRadialExplosionEventData;
  54142. /**
  54143. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  54144. * @param impostor A physics imposter
  54145. * @param origin the origin of the explosion
  54146. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  54147. */
  54148. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  54149. /**
  54150. * Triggers affecterd impostors callbacks
  54151. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  54152. */
  54153. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  54154. /**
  54155. * Disposes the sphere.
  54156. * @param force Specifies if the sphere should be disposed by force
  54157. */
  54158. dispose(force?: boolean): void;
  54159. /*** Helpers ***/
  54160. private _prepareSphere;
  54161. private _intersectsWithSphere;
  54162. }
  54163. /**
  54164. * Represents a gravitational field event
  54165. */
  54166. class PhysicsGravitationalFieldEvent {
  54167. private _physicsHelper;
  54168. private _scene;
  54169. private _origin;
  54170. private _options;
  54171. private _tickCallback;
  54172. private _sphere;
  54173. private _dataFetched;
  54174. /**
  54175. * Initializes the physics gravitational field event
  54176. * @param _physicsHelper A physics helper
  54177. * @param _scene BabylonJS scene
  54178. * @param _origin The origin position of the gravitational field event
  54179. * @param _options The options for the vortex event
  54180. */
  54181. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  54182. /**
  54183. * Returns the data related to the gravitational field event (sphere).
  54184. * @returns A gravitational field event
  54185. */
  54186. getData(): PhysicsGravitationalFieldEventData;
  54187. /**
  54188. * Enables the gravitational field.
  54189. */
  54190. enable(): void;
  54191. /**
  54192. * Disables the gravitational field.
  54193. */
  54194. disable(): void;
  54195. /**
  54196. * Disposes the sphere.
  54197. * @param force The force to dispose from the gravitational field event
  54198. */
  54199. dispose(force?: boolean): void;
  54200. private _tick;
  54201. }
  54202. /**
  54203. * Represents a physics updraft event
  54204. */
  54205. class PhysicsUpdraftEvent {
  54206. private _scene;
  54207. private _origin;
  54208. private _options;
  54209. private _physicsEngine;
  54210. private _originTop;
  54211. private _originDirection;
  54212. private _tickCallback;
  54213. private _cylinder;
  54214. private _cylinderPosition;
  54215. private _dataFetched;
  54216. /**
  54217. * Initializes the physics updraft event
  54218. * @param _scene BabylonJS scene
  54219. * @param _origin The origin position of the updraft
  54220. * @param _options The options for the updraft event
  54221. */
  54222. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  54223. /**
  54224. * Returns the data related to the updraft event (cylinder).
  54225. * @returns A physics updraft event
  54226. */
  54227. getData(): PhysicsUpdraftEventData;
  54228. /**
  54229. * Enables the updraft.
  54230. */
  54231. enable(): void;
  54232. /**
  54233. * Disables the updraft.
  54234. */
  54235. disable(): void;
  54236. /**
  54237. * Disposes the cylinder.
  54238. * @param force Specifies if the updraft should be disposed by force
  54239. */
  54240. dispose(force?: boolean): void;
  54241. private getImpostorHitData;
  54242. private _tick;
  54243. /*** Helpers ***/
  54244. private _prepareCylinder;
  54245. private _intersectsWithCylinder;
  54246. }
  54247. /**
  54248. * Represents a physics vortex event
  54249. */
  54250. class PhysicsVortexEvent {
  54251. private _scene;
  54252. private _origin;
  54253. private _options;
  54254. private _physicsEngine;
  54255. private _originTop;
  54256. private _tickCallback;
  54257. private _cylinder;
  54258. private _cylinderPosition;
  54259. private _dataFetched;
  54260. /**
  54261. * Initializes the physics vortex event
  54262. * @param _scene The BabylonJS scene
  54263. * @param _origin The origin position of the vortex
  54264. * @param _options The options for the vortex event
  54265. */
  54266. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  54267. /**
  54268. * Returns the data related to the vortex event (cylinder).
  54269. * @returns The physics vortex event data
  54270. */
  54271. getData(): PhysicsVortexEventData;
  54272. /**
  54273. * Enables the vortex.
  54274. */
  54275. enable(): void;
  54276. /**
  54277. * Disables the cortex.
  54278. */
  54279. disable(): void;
  54280. /**
  54281. * Disposes the sphere.
  54282. * @param force
  54283. */
  54284. dispose(force?: boolean): void;
  54285. private getImpostorHitData;
  54286. private _tick;
  54287. /*** Helpers ***/
  54288. private _prepareCylinder;
  54289. private _intersectsWithCylinder;
  54290. }
  54291. /**
  54292. * Options fot the radial explosion event
  54293. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54294. */
  54295. export class PhysicsRadialExplosionEventOptions {
  54296. /**
  54297. * The radius of the sphere for the radial explosion.
  54298. */
  54299. radius: number;
  54300. /**
  54301. * The strenth of the explosion.
  54302. */
  54303. strength: number;
  54304. /**
  54305. * The strenght of the force in correspondence to the distance of the affected object
  54306. */
  54307. falloff: PhysicsRadialImpulseFalloff;
  54308. /**
  54309. * Sphere options for the radial explosion.
  54310. */
  54311. sphere: {
  54312. segments: number;
  54313. diameter: number;
  54314. };
  54315. /**
  54316. * Sphere options for the radial explosion.
  54317. */
  54318. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  54319. }
  54320. /**
  54321. * Options fot the updraft event
  54322. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54323. */
  54324. export class PhysicsUpdraftEventOptions {
  54325. /**
  54326. * The radius of the cylinder for the vortex
  54327. */
  54328. radius: number;
  54329. /**
  54330. * The strenth of the updraft.
  54331. */
  54332. strength: number;
  54333. /**
  54334. * The height of the cylinder for the updraft.
  54335. */
  54336. height: number;
  54337. /**
  54338. * The mode for the the updraft.
  54339. */
  54340. updraftMode: PhysicsUpdraftMode;
  54341. }
  54342. /**
  54343. * Options fot the vortex event
  54344. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54345. */
  54346. export class PhysicsVortexEventOptions {
  54347. /**
  54348. * The radius of the cylinder for the vortex
  54349. */
  54350. radius: number;
  54351. /**
  54352. * The strenth of the vortex.
  54353. */
  54354. strength: number;
  54355. /**
  54356. * The height of the cylinder for the vortex.
  54357. */
  54358. height: number;
  54359. /**
  54360. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  54361. */
  54362. centripetalForceThreshold: number;
  54363. /**
  54364. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  54365. */
  54366. centripetalForceMultiplier: number;
  54367. /**
  54368. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54369. */
  54370. centrifugalForceMultiplier: number;
  54371. /**
  54372. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54373. */
  54374. updraftForceMultiplier: number;
  54375. }
  54376. /**
  54377. * The strenght of the force in correspondence to the distance of the affected object
  54378. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54379. */
  54380. export enum PhysicsRadialImpulseFalloff {
  54381. /** Defines that impulse is constant in strength across it's whole radius */
  54382. Constant = 0,
  54383. /** Defines that impulse gets weaker if it's further from the origin */
  54384. Linear = 1
  54385. }
  54386. /**
  54387. * The strength of the force in correspondence to the distance of the affected object
  54388. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54389. */
  54390. export enum PhysicsUpdraftMode {
  54391. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54392. Center = 0,
  54393. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54394. Perpendicular = 1
  54395. }
  54396. /**
  54397. * Interface for a physics hit data
  54398. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54399. */
  54400. export interface PhysicsHitData {
  54401. /**
  54402. * The force applied at the contact point
  54403. */
  54404. force: Vector3;
  54405. /**
  54406. * The contact point
  54407. */
  54408. contactPoint: Vector3;
  54409. /**
  54410. * The distance from the origin to the contact point
  54411. */
  54412. distanceFromOrigin: number;
  54413. }
  54414. /**
  54415. * Interface for radial explosion event data
  54416. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54417. */
  54418. export interface PhysicsRadialExplosionEventData {
  54419. /**
  54420. * A sphere used for the radial explosion event
  54421. */
  54422. sphere: Mesh;
  54423. }
  54424. /**
  54425. * Interface for gravitational field event data
  54426. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54427. */
  54428. export interface PhysicsGravitationalFieldEventData {
  54429. /**
  54430. * A sphere mesh used for the gravitational field event
  54431. */
  54432. sphere: Mesh;
  54433. }
  54434. /**
  54435. * Interface for updraft event data
  54436. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54437. */
  54438. export interface PhysicsUpdraftEventData {
  54439. /**
  54440. * A cylinder used for the updraft event
  54441. */
  54442. cylinder: Mesh;
  54443. }
  54444. /**
  54445. * Interface for vortex event data
  54446. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54447. */
  54448. export interface PhysicsVortexEventData {
  54449. /**
  54450. * A cylinder used for the vortex event
  54451. */
  54452. cylinder: Mesh;
  54453. }
  54454. /**
  54455. * Interface for an affected physics impostor
  54456. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54457. */
  54458. export interface PhysicsAffectedImpostorWithData {
  54459. /**
  54460. * The impostor affected by the effect
  54461. */
  54462. impostor: PhysicsImpostor;
  54463. /**
  54464. * The data about the hit/horce from the explosion
  54465. */
  54466. hitData: PhysicsHitData;
  54467. }
  54468. }
  54469. declare module "babylonjs/Physics/Plugins/index" {
  54470. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  54471. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  54472. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  54473. }
  54474. declare module "babylonjs/Physics/index" {
  54475. export * from "babylonjs/Physics/IPhysicsEngine";
  54476. export * from "babylonjs/Physics/physicsEngine";
  54477. export * from "babylonjs/Physics/physicsEngineComponent";
  54478. export * from "babylonjs/Physics/physicsHelper";
  54479. export * from "babylonjs/Physics/physicsImpostor";
  54480. export * from "babylonjs/Physics/physicsJoint";
  54481. export * from "babylonjs/Physics/Plugins/index";
  54482. }
  54483. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  54484. /** @hidden */
  54485. export var blackAndWhitePixelShader: {
  54486. name: string;
  54487. shader: string;
  54488. };
  54489. }
  54490. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  54491. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54492. import { Camera } from "babylonjs/Cameras/camera";
  54493. import { Engine } from "babylonjs/Engines/engine";
  54494. import "babylonjs/Shaders/blackAndWhite.fragment";
  54495. /**
  54496. * Post process used to render in black and white
  54497. */
  54498. export class BlackAndWhitePostProcess extends PostProcess {
  54499. /**
  54500. * Linear about to convert he result to black and white (default: 1)
  54501. */
  54502. degree: number;
  54503. /**
  54504. * Creates a black and white post process
  54505. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54506. * @param name The name of the effect.
  54507. * @param options The required width/height ratio to downsize to before computing the render pass.
  54508. * @param camera The camera to apply the render pass to.
  54509. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54510. * @param engine The engine which the post process will be applied. (default: current engine)
  54511. * @param reusable If the post process can be reused on the same frame. (default: false)
  54512. */
  54513. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54514. }
  54515. }
  54516. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  54517. import { Nullable } from "babylonjs/types";
  54518. import { Camera } from "babylonjs/Cameras/camera";
  54519. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54520. import { Engine } from "babylonjs/Engines/engine";
  54521. /**
  54522. * This represents a set of one or more post processes in Babylon.
  54523. * A post process can be used to apply a shader to a texture after it is rendered.
  54524. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54525. */
  54526. export class PostProcessRenderEffect {
  54527. private _postProcesses;
  54528. private _getPostProcesses;
  54529. private _singleInstance;
  54530. private _cameras;
  54531. private _indicesForCamera;
  54532. /**
  54533. * Name of the effect
  54534. * @hidden
  54535. */
  54536. _name: string;
  54537. /**
  54538. * Instantiates a post process render effect.
  54539. * A post process can be used to apply a shader to a texture after it is rendered.
  54540. * @param engine The engine the effect is tied to
  54541. * @param name The name of the effect
  54542. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54543. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54544. */
  54545. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54546. /**
  54547. * Checks if all the post processes in the effect are supported.
  54548. */
  54549. readonly isSupported: boolean;
  54550. /**
  54551. * Updates the current state of the effect
  54552. * @hidden
  54553. */
  54554. _update(): void;
  54555. /**
  54556. * Attaches the effect on cameras
  54557. * @param cameras The camera to attach to.
  54558. * @hidden
  54559. */
  54560. _attachCameras(cameras: Camera): void;
  54561. /**
  54562. * Attaches the effect on cameras
  54563. * @param cameras The camera to attach to.
  54564. * @hidden
  54565. */
  54566. _attachCameras(cameras: Camera[]): void;
  54567. /**
  54568. * Detaches the effect on cameras
  54569. * @param cameras The camera to detatch from.
  54570. * @hidden
  54571. */
  54572. _detachCameras(cameras: Camera): void;
  54573. /**
  54574. * Detatches the effect on cameras
  54575. * @param cameras The camera to detatch from.
  54576. * @hidden
  54577. */
  54578. _detachCameras(cameras: Camera[]): void;
  54579. /**
  54580. * Enables the effect on given cameras
  54581. * @param cameras The camera to enable.
  54582. * @hidden
  54583. */
  54584. _enable(cameras: Camera): void;
  54585. /**
  54586. * Enables the effect on given cameras
  54587. * @param cameras The camera to enable.
  54588. * @hidden
  54589. */
  54590. _enable(cameras: Nullable<Camera[]>): void;
  54591. /**
  54592. * Disables the effect on the given cameras
  54593. * @param cameras The camera to disable.
  54594. * @hidden
  54595. */
  54596. _disable(cameras: Camera): void;
  54597. /**
  54598. * Disables the effect on the given cameras
  54599. * @param cameras The camera to disable.
  54600. * @hidden
  54601. */
  54602. _disable(cameras: Nullable<Camera[]>): void;
  54603. /**
  54604. * Gets a list of the post processes contained in the effect.
  54605. * @param camera The camera to get the post processes on.
  54606. * @returns The list of the post processes in the effect.
  54607. */
  54608. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54609. }
  54610. }
  54611. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  54612. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54613. /** @hidden */
  54614. export var extractHighlightsPixelShader: {
  54615. name: string;
  54616. shader: string;
  54617. };
  54618. }
  54619. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  54620. import { Nullable } from "babylonjs/types";
  54621. import { Camera } from "babylonjs/Cameras/camera";
  54622. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54623. import { Engine } from "babylonjs/Engines/engine";
  54624. import "babylonjs/Shaders/extractHighlights.fragment";
  54625. /**
  54626. * 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.
  54627. */
  54628. export class ExtractHighlightsPostProcess extends PostProcess {
  54629. /**
  54630. * The luminance threshold, pixels below this value will be set to black.
  54631. */
  54632. threshold: number;
  54633. /** @hidden */
  54634. _exposure: number;
  54635. /**
  54636. * Post process which has the input texture to be used when performing highlight extraction
  54637. * @hidden
  54638. */
  54639. _inputPostProcess: Nullable<PostProcess>;
  54640. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54641. }
  54642. }
  54643. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  54644. /** @hidden */
  54645. export var bloomMergePixelShader: {
  54646. name: string;
  54647. shader: string;
  54648. };
  54649. }
  54650. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  54651. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54652. import { Nullable } from "babylonjs/types";
  54653. import { Engine } from "babylonjs/Engines/engine";
  54654. import { Camera } from "babylonjs/Cameras/camera";
  54655. import "babylonjs/Shaders/bloomMerge.fragment";
  54656. /**
  54657. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54658. */
  54659. export class BloomMergePostProcess extends PostProcess {
  54660. /** Weight of the bloom to be added to the original input. */
  54661. weight: number;
  54662. /**
  54663. * Creates a new instance of @see BloomMergePostProcess
  54664. * @param name The name of the effect.
  54665. * @param originalFromInput Post process which's input will be used for the merge.
  54666. * @param blurred Blurred highlights post process which's output will be used.
  54667. * @param weight Weight of the bloom to be added to the original input.
  54668. * @param options The required width/height ratio to downsize to before computing the render pass.
  54669. * @param camera The camera to apply the render pass to.
  54670. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54671. * @param engine The engine which the post process will be applied. (default: current engine)
  54672. * @param reusable If the post process can be reused on the same frame. (default: false)
  54673. * @param textureType Type of textures used when performing the post process. (default: 0)
  54674. * @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)
  54675. */
  54676. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54677. /** Weight of the bloom to be added to the original input. */
  54678. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54679. }
  54680. }
  54681. declare module "babylonjs/PostProcesses/bloomEffect" {
  54682. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54683. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54684. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54685. import { Camera } from "babylonjs/Cameras/camera";
  54686. import { Scene } from "babylonjs/scene";
  54687. /**
  54688. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54689. */
  54690. export class BloomEffect extends PostProcessRenderEffect {
  54691. private bloomScale;
  54692. /**
  54693. * @hidden Internal
  54694. */
  54695. _effects: Array<PostProcess>;
  54696. /**
  54697. * @hidden Internal
  54698. */
  54699. _downscale: ExtractHighlightsPostProcess;
  54700. private _blurX;
  54701. private _blurY;
  54702. private _merge;
  54703. /**
  54704. * The luminance threshold to find bright areas of the image to bloom.
  54705. */
  54706. threshold: number;
  54707. /**
  54708. * The strength of the bloom.
  54709. */
  54710. weight: number;
  54711. /**
  54712. * Specifies the size of the bloom blur kernel, relative to the final output size
  54713. */
  54714. kernel: number;
  54715. /**
  54716. * Creates a new instance of @see BloomEffect
  54717. * @param scene The scene the effect belongs to.
  54718. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54719. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54720. * @param bloomWeight The the strength of bloom.
  54721. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54722. * @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)
  54723. */
  54724. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54725. /**
  54726. * Disposes each of the internal effects for a given camera.
  54727. * @param camera The camera to dispose the effect on.
  54728. */
  54729. disposeEffects(camera: Camera): void;
  54730. /**
  54731. * @hidden Internal
  54732. */
  54733. _updateEffects(): void;
  54734. /**
  54735. * Internal
  54736. * @returns if all the contained post processes are ready.
  54737. * @hidden
  54738. */
  54739. _isReady(): boolean;
  54740. }
  54741. }
  54742. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  54743. /** @hidden */
  54744. export var chromaticAberrationPixelShader: {
  54745. name: string;
  54746. shader: string;
  54747. };
  54748. }
  54749. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  54750. import { Vector2 } from "babylonjs/Maths/math";
  54751. import { Nullable } from "babylonjs/types";
  54752. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54753. import { Camera } from "babylonjs/Cameras/camera";
  54754. import { Engine } from "babylonjs/Engines/engine";
  54755. import "babylonjs/Shaders/chromaticAberration.fragment";
  54756. /**
  54757. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54758. */
  54759. export class ChromaticAberrationPostProcess extends PostProcess {
  54760. /**
  54761. * The amount of seperation of rgb channels (default: 30)
  54762. */
  54763. aberrationAmount: number;
  54764. /**
  54765. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54766. */
  54767. radialIntensity: number;
  54768. /**
  54769. * 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))
  54770. */
  54771. direction: Vector2;
  54772. /**
  54773. * 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))
  54774. */
  54775. centerPosition: Vector2;
  54776. /**
  54777. * Creates a new instance ChromaticAberrationPostProcess
  54778. * @param name The name of the effect.
  54779. * @param screenWidth The width of the screen to apply the effect on.
  54780. * @param screenHeight The height of the screen to apply the effect on.
  54781. * @param options The required width/height ratio to downsize to before computing the render pass.
  54782. * @param camera The camera to apply the render pass to.
  54783. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54784. * @param engine The engine which the post process will be applied. (default: current engine)
  54785. * @param reusable If the post process can be reused on the same frame. (default: false)
  54786. * @param textureType Type of textures used when performing the post process. (default: 0)
  54787. * @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)
  54788. */
  54789. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54790. }
  54791. }
  54792. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  54793. /** @hidden */
  54794. export var circleOfConfusionPixelShader: {
  54795. name: string;
  54796. shader: string;
  54797. };
  54798. }
  54799. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  54800. import { Nullable } from "babylonjs/types";
  54801. import { Engine } from "babylonjs/Engines/engine";
  54802. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54803. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54804. import { Camera } from "babylonjs/Cameras/camera";
  54805. import "babylonjs/Shaders/circleOfConfusion.fragment";
  54806. /**
  54807. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  54808. */
  54809. export class CircleOfConfusionPostProcess extends PostProcess {
  54810. /**
  54811. * 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.
  54812. */
  54813. lensSize: number;
  54814. /**
  54815. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54816. */
  54817. fStop: number;
  54818. /**
  54819. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54820. */
  54821. focusDistance: number;
  54822. /**
  54823. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  54824. */
  54825. focalLength: number;
  54826. private _depthTexture;
  54827. /**
  54828. * Creates a new instance CircleOfConfusionPostProcess
  54829. * @param name The name of the effect.
  54830. * @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.
  54831. * @param options The required width/height ratio to downsize to before computing the render pass.
  54832. * @param camera The camera to apply the render pass to.
  54833. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54834. * @param engine The engine which the post process will be applied. (default: current engine)
  54835. * @param reusable If the post process can be reused on the same frame. (default: false)
  54836. * @param textureType Type of textures used when performing the post process. (default: 0)
  54837. * @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)
  54838. */
  54839. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54840. /**
  54841. * 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.
  54842. */
  54843. depthTexture: RenderTargetTexture;
  54844. }
  54845. }
  54846. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  54847. /** @hidden */
  54848. export var colorCorrectionPixelShader: {
  54849. name: string;
  54850. shader: string;
  54851. };
  54852. }
  54853. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  54854. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54855. import { Engine } from "babylonjs/Engines/engine";
  54856. import { Camera } from "babylonjs/Cameras/camera";
  54857. import "babylonjs/Shaders/colorCorrection.fragment";
  54858. /**
  54859. *
  54860. * This post-process allows the modification of rendered colors by using
  54861. * a 'look-up table' (LUT). This effect is also called Color Grading.
  54862. *
  54863. * The object needs to be provided an url to a texture containing the color
  54864. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  54865. * Use an image editing software to tweak the LUT to match your needs.
  54866. *
  54867. * For an example of a color LUT, see here:
  54868. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  54869. * For explanations on color grading, see here:
  54870. * @see http://udn.epicgames.com/Three/ColorGrading.html
  54871. *
  54872. */
  54873. export class ColorCorrectionPostProcess extends PostProcess {
  54874. private _colorTableTexture;
  54875. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54876. }
  54877. }
  54878. declare module "babylonjs/Shaders/convolution.fragment" {
  54879. /** @hidden */
  54880. export var convolutionPixelShader: {
  54881. name: string;
  54882. shader: string;
  54883. };
  54884. }
  54885. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  54886. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54887. import { Nullable } from "babylonjs/types";
  54888. import { Camera } from "babylonjs/Cameras/camera";
  54889. import { Engine } from "babylonjs/Engines/engine";
  54890. import "babylonjs/Shaders/convolution.fragment";
  54891. /**
  54892. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  54893. * input texture to perform effects such as edge detection or sharpening
  54894. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54895. */
  54896. export class ConvolutionPostProcess extends PostProcess {
  54897. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54898. kernel: number[];
  54899. /**
  54900. * Creates a new instance ConvolutionPostProcess
  54901. * @param name The name of the effect.
  54902. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  54903. * @param options The required width/height ratio to downsize to before computing the render pass.
  54904. * @param camera The camera to apply the render pass to.
  54905. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54906. * @param engine The engine which the post process will be applied. (default: current engine)
  54907. * @param reusable If the post process can be reused on the same frame. (default: false)
  54908. * @param textureType Type of textures used when performing the post process. (default: 0)
  54909. */
  54910. constructor(name: string,
  54911. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54912. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54913. /**
  54914. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54915. */
  54916. static EdgeDetect0Kernel: number[];
  54917. /**
  54918. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54919. */
  54920. static EdgeDetect1Kernel: number[];
  54921. /**
  54922. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54923. */
  54924. static EdgeDetect2Kernel: number[];
  54925. /**
  54926. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54927. */
  54928. static SharpenKernel: number[];
  54929. /**
  54930. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54931. */
  54932. static EmbossKernel: number[];
  54933. /**
  54934. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54935. */
  54936. static GaussianKernel: number[];
  54937. }
  54938. }
  54939. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  54940. import { Nullable } from "babylonjs/types";
  54941. import { Vector2 } from "babylonjs/Maths/math";
  54942. import { Camera } from "babylonjs/Cameras/camera";
  54943. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54944. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  54945. import { Engine } from "babylonjs/Engines/engine";
  54946. import { Scene } from "babylonjs/scene";
  54947. /**
  54948. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  54949. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  54950. * based on samples that have a large difference in distance than the center pixel.
  54951. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  54952. */
  54953. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  54954. direction: Vector2;
  54955. /**
  54956. * Creates a new instance CircleOfConfusionPostProcess
  54957. * @param name The name of the effect.
  54958. * @param scene The scene the effect belongs to.
  54959. * @param direction The direction the blur should be applied.
  54960. * @param kernel The size of the kernel used to blur.
  54961. * @param options The required width/height ratio to downsize to before computing the render pass.
  54962. * @param camera The camera to apply the render pass to.
  54963. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  54964. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  54965. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54966. * @param engine The engine which the post process will be applied. (default: current engine)
  54967. * @param reusable If the post process can be reused on the same frame. (default: false)
  54968. * @param textureType Type of textures used when performing the post process. (default: 0)
  54969. * @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)
  54970. */
  54971. 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);
  54972. }
  54973. }
  54974. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  54975. /** @hidden */
  54976. export var depthOfFieldMergePixelShader: {
  54977. name: string;
  54978. shader: string;
  54979. };
  54980. }
  54981. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  54982. import { Nullable } from "babylonjs/types";
  54983. import { Camera } from "babylonjs/Cameras/camera";
  54984. import { Effect } from "babylonjs/Materials/effect";
  54985. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54986. import { Engine } from "babylonjs/Engines/engine";
  54987. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  54988. /**
  54989. * Options to be set when merging outputs from the default pipeline.
  54990. */
  54991. export class DepthOfFieldMergePostProcessOptions {
  54992. /**
  54993. * The original image to merge on top of
  54994. */
  54995. originalFromInput: PostProcess;
  54996. /**
  54997. * Parameters to perform the merge of the depth of field effect
  54998. */
  54999. depthOfField?: {
  55000. circleOfConfusion: PostProcess;
  55001. blurSteps: Array<PostProcess>;
  55002. };
  55003. /**
  55004. * Parameters to perform the merge of bloom effect
  55005. */
  55006. bloom?: {
  55007. blurred: PostProcess;
  55008. weight: number;
  55009. };
  55010. }
  55011. /**
  55012. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55013. */
  55014. export class DepthOfFieldMergePostProcess extends PostProcess {
  55015. private blurSteps;
  55016. /**
  55017. * Creates a new instance of DepthOfFieldMergePostProcess
  55018. * @param name The name of the effect.
  55019. * @param originalFromInput Post process which's input will be used for the merge.
  55020. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  55021. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  55022. * @param options The required width/height ratio to downsize to before computing the render pass.
  55023. * @param camera The camera to apply the render pass to.
  55024. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55025. * @param engine The engine which the post process will be applied. (default: current engine)
  55026. * @param reusable If the post process can be reused on the same frame. (default: false)
  55027. * @param textureType Type of textures used when performing the post process. (default: 0)
  55028. * @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)
  55029. */
  55030. 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);
  55031. /**
  55032. * Updates the effect with the current post process compile time values and recompiles the shader.
  55033. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  55034. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  55035. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  55036. * @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
  55037. * @param onCompiled Called when the shader has been compiled.
  55038. * @param onError Called if there is an error when compiling a shader.
  55039. */
  55040. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  55041. }
  55042. }
  55043. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  55044. import { Nullable } from "babylonjs/types";
  55045. import { Camera } from "babylonjs/Cameras/camera";
  55046. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55047. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55048. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55049. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  55050. import { Scene } from "babylonjs/scene";
  55051. /**
  55052. * Specifies the level of max blur that should be applied when using the depth of field effect
  55053. */
  55054. export enum DepthOfFieldEffectBlurLevel {
  55055. /**
  55056. * Subtle blur
  55057. */
  55058. Low = 0,
  55059. /**
  55060. * Medium blur
  55061. */
  55062. Medium = 1,
  55063. /**
  55064. * Large blur
  55065. */
  55066. High = 2
  55067. }
  55068. /**
  55069. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  55070. */
  55071. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  55072. private _circleOfConfusion;
  55073. /**
  55074. * @hidden Internal, blurs from high to low
  55075. */
  55076. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  55077. private _depthOfFieldBlurY;
  55078. private _dofMerge;
  55079. /**
  55080. * @hidden Internal post processes in depth of field effect
  55081. */
  55082. _effects: Array<PostProcess>;
  55083. /**
  55084. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  55085. */
  55086. focalLength: number;
  55087. /**
  55088. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55089. */
  55090. fStop: number;
  55091. /**
  55092. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55093. */
  55094. focusDistance: number;
  55095. /**
  55096. * 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.
  55097. */
  55098. lensSize: number;
  55099. /**
  55100. * Creates a new instance DepthOfFieldEffect
  55101. * @param scene The scene the effect belongs to.
  55102. * @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.
  55103. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55104. * @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)
  55105. */
  55106. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  55107. /**
  55108. * Get the current class name of the current effet
  55109. * @returns "DepthOfFieldEffect"
  55110. */
  55111. getClassName(): string;
  55112. /**
  55113. * 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.
  55114. */
  55115. depthTexture: RenderTargetTexture;
  55116. /**
  55117. * Disposes each of the internal effects for a given camera.
  55118. * @param camera The camera to dispose the effect on.
  55119. */
  55120. disposeEffects(camera: Camera): void;
  55121. /**
  55122. * @hidden Internal
  55123. */
  55124. _updateEffects(): void;
  55125. /**
  55126. * Internal
  55127. * @returns if all the contained post processes are ready.
  55128. * @hidden
  55129. */
  55130. _isReady(): boolean;
  55131. }
  55132. }
  55133. declare module "babylonjs/Shaders/displayPass.fragment" {
  55134. /** @hidden */
  55135. export var displayPassPixelShader: {
  55136. name: string;
  55137. shader: string;
  55138. };
  55139. }
  55140. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  55141. import { Nullable } from "babylonjs/types";
  55142. import { Camera } from "babylonjs/Cameras/camera";
  55143. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55144. import { Engine } from "babylonjs/Engines/engine";
  55145. import "babylonjs/Shaders/displayPass.fragment";
  55146. /**
  55147. * DisplayPassPostProcess which produces an output the same as it's input
  55148. */
  55149. export class DisplayPassPostProcess extends PostProcess {
  55150. /**
  55151. * Creates the DisplayPassPostProcess
  55152. * @param name The name of the effect.
  55153. * @param options The required width/height ratio to downsize to before computing the render pass.
  55154. * @param camera The camera to apply the render pass to.
  55155. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55156. * @param engine The engine which the post process will be applied. (default: current engine)
  55157. * @param reusable If the post process can be reused on the same frame. (default: false)
  55158. */
  55159. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55160. }
  55161. }
  55162. declare module "babylonjs/Shaders/filter.fragment" {
  55163. /** @hidden */
  55164. export var filterPixelShader: {
  55165. name: string;
  55166. shader: string;
  55167. };
  55168. }
  55169. declare module "babylonjs/PostProcesses/filterPostProcess" {
  55170. import { Nullable } from "babylonjs/types";
  55171. import { Matrix } from "babylonjs/Maths/math";
  55172. import { Camera } from "babylonjs/Cameras/camera";
  55173. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55174. import { Engine } from "babylonjs/Engines/engine";
  55175. import "babylonjs/Shaders/filter.fragment";
  55176. /**
  55177. * Applies a kernel filter to the image
  55178. */
  55179. export class FilterPostProcess extends PostProcess {
  55180. /** The matrix to be applied to the image */
  55181. kernelMatrix: Matrix;
  55182. /**
  55183. *
  55184. * @param name The name of the effect.
  55185. * @param kernelMatrix The matrix to be applied to the image
  55186. * @param options The required width/height ratio to downsize to before computing the render pass.
  55187. * @param camera The camera to apply the render pass to.
  55188. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55189. * @param engine The engine which the post process will be applied. (default: current engine)
  55190. * @param reusable If the post process can be reused on the same frame. (default: false)
  55191. */
  55192. constructor(name: string,
  55193. /** The matrix to be applied to the image */
  55194. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55195. }
  55196. }
  55197. declare module "babylonjs/Shaders/fxaa.fragment" {
  55198. /** @hidden */
  55199. export var fxaaPixelShader: {
  55200. name: string;
  55201. shader: string;
  55202. };
  55203. }
  55204. declare module "babylonjs/Shaders/fxaa.vertex" {
  55205. /** @hidden */
  55206. export var fxaaVertexShader: {
  55207. name: string;
  55208. shader: string;
  55209. };
  55210. }
  55211. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  55212. import { Nullable } from "babylonjs/types";
  55213. import { Camera } from "babylonjs/Cameras/camera";
  55214. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55215. import { Engine } from "babylonjs/Engines/engine";
  55216. import "babylonjs/Shaders/fxaa.fragment";
  55217. import "babylonjs/Shaders/fxaa.vertex";
  55218. /**
  55219. * Fxaa post process
  55220. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  55221. */
  55222. export class FxaaPostProcess extends PostProcess {
  55223. /** @hidden */
  55224. texelWidth: number;
  55225. /** @hidden */
  55226. texelHeight: number;
  55227. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55228. private _getDefines;
  55229. }
  55230. }
  55231. declare module "babylonjs/Shaders/grain.fragment" {
  55232. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55233. /** @hidden */
  55234. export var grainPixelShader: {
  55235. name: string;
  55236. shader: string;
  55237. };
  55238. }
  55239. declare module "babylonjs/PostProcesses/grainPostProcess" {
  55240. import { Nullable } from "babylonjs/types";
  55241. import { Camera } from "babylonjs/Cameras/camera";
  55242. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55243. import { Engine } from "babylonjs/Engines/engine";
  55244. import "babylonjs/Shaders/grain.fragment";
  55245. /**
  55246. * The GrainPostProcess adds noise to the image at mid luminance levels
  55247. */
  55248. export class GrainPostProcess extends PostProcess {
  55249. /**
  55250. * The intensity of the grain added (default: 30)
  55251. */
  55252. intensity: number;
  55253. /**
  55254. * If the grain should be randomized on every frame
  55255. */
  55256. animated: boolean;
  55257. /**
  55258. * Creates a new instance of @see GrainPostProcess
  55259. * @param name The name of the effect.
  55260. * @param options The required width/height ratio to downsize to before computing the render pass.
  55261. * @param camera The camera to apply the render pass to.
  55262. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55263. * @param engine The engine which the post process will be applied. (default: current engine)
  55264. * @param reusable If the post process can be reused on the same frame. (default: false)
  55265. * @param textureType Type of textures used when performing the post process. (default: 0)
  55266. * @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)
  55267. */
  55268. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55269. }
  55270. }
  55271. declare module "babylonjs/Shaders/highlights.fragment" {
  55272. /** @hidden */
  55273. export var highlightsPixelShader: {
  55274. name: string;
  55275. shader: string;
  55276. };
  55277. }
  55278. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  55279. import { Nullable } from "babylonjs/types";
  55280. import { Camera } from "babylonjs/Cameras/camera";
  55281. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55282. import { Engine } from "babylonjs/Engines/engine";
  55283. import "babylonjs/Shaders/highlights.fragment";
  55284. /**
  55285. * Extracts highlights from the image
  55286. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55287. */
  55288. export class HighlightsPostProcess extends PostProcess {
  55289. /**
  55290. * Extracts highlights from the image
  55291. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55292. * @param name The name of the effect.
  55293. * @param options The required width/height ratio to downsize to before computing the render pass.
  55294. * @param camera The camera to apply the render pass to.
  55295. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55296. * @param engine The engine which the post process will be applied. (default: current engine)
  55297. * @param reusable If the post process can be reused on the same frame. (default: false)
  55298. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  55299. */
  55300. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55301. }
  55302. }
  55303. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  55304. /** @hidden */
  55305. export var mrtFragmentDeclaration: {
  55306. name: string;
  55307. shader: string;
  55308. };
  55309. }
  55310. declare module "babylonjs/Shaders/geometry.fragment" {
  55311. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  55312. /** @hidden */
  55313. export var geometryPixelShader: {
  55314. name: string;
  55315. shader: string;
  55316. };
  55317. }
  55318. declare module "babylonjs/Shaders/geometry.vertex" {
  55319. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55320. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55321. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55322. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55323. /** @hidden */
  55324. export var geometryVertexShader: {
  55325. name: string;
  55326. shader: string;
  55327. };
  55328. }
  55329. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  55330. import { Matrix } from "babylonjs/Maths/math";
  55331. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55332. import { Mesh } from "babylonjs/Meshes/mesh";
  55333. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  55334. import { Effect } from "babylonjs/Materials/effect";
  55335. import { Scene } from "babylonjs/scene";
  55336. import "babylonjs/Shaders/geometry.fragment";
  55337. import "babylonjs/Shaders/geometry.vertex";
  55338. /**
  55339. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  55340. */
  55341. export class GeometryBufferRenderer {
  55342. /**
  55343. * Constant used to retrieve the position texture index in the G-Buffer textures array
  55344. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  55345. */
  55346. static readonly POSITION_TEXTURE_TYPE: number;
  55347. /**
  55348. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  55349. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  55350. */
  55351. static readonly VELOCITY_TEXTURE_TYPE: number;
  55352. /**
  55353. * Dictionary used to store the previous transformation matrices of each rendered mesh
  55354. * in order to compute objects velocities when enableVelocity is set to "true"
  55355. * @hidden
  55356. */
  55357. _previousTransformationMatrices: {
  55358. [index: number]: Matrix;
  55359. };
  55360. private _scene;
  55361. private _multiRenderTarget;
  55362. private _ratio;
  55363. private _enablePosition;
  55364. private _enableVelocity;
  55365. private _positionIndex;
  55366. private _velocityIndex;
  55367. protected _effect: Effect;
  55368. protected _cachedDefines: string;
  55369. /**
  55370. * Set the render list (meshes to be rendered) used in the G buffer.
  55371. */
  55372. renderList: Mesh[];
  55373. /**
  55374. * Gets wether or not G buffer are supported by the running hardware.
  55375. * This requires draw buffer supports
  55376. */
  55377. readonly isSupported: boolean;
  55378. /**
  55379. * Returns the index of the given texture type in the G-Buffer textures array
  55380. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55381. * @returns the index of the given texture type in the G-Buffer textures array
  55382. */
  55383. getTextureIndex(textureType: number): number;
  55384. /**
  55385. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55386. */
  55387. /**
  55388. * Sets whether or not objects positions are enabled for the G buffer.
  55389. */
  55390. enablePosition: boolean;
  55391. /**
  55392. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55393. */
  55394. /**
  55395. * Sets wether or not objects velocities are enabled for the G buffer.
  55396. */
  55397. enableVelocity: boolean;
  55398. /**
  55399. * Gets the scene associated with the buffer.
  55400. */
  55401. readonly scene: Scene;
  55402. /**
  55403. * Gets the ratio used by the buffer during its creation.
  55404. * How big is the buffer related to the main canvas.
  55405. */
  55406. readonly ratio: number;
  55407. /** @hidden */
  55408. static _SceneComponentInitialization: (scene: Scene) => void;
  55409. /**
  55410. * Creates a new G Buffer for the scene
  55411. * @param scene The scene the buffer belongs to
  55412. * @param ratio How big is the buffer related to the main canvas.
  55413. */
  55414. constructor(scene: Scene, ratio?: number);
  55415. /**
  55416. * Checks wether everything is ready to render a submesh to the G buffer.
  55417. * @param subMesh the submesh to check readiness for
  55418. * @param useInstances is the mesh drawn using instance or not
  55419. * @returns true if ready otherwise false
  55420. */
  55421. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55422. /**
  55423. * Gets the current underlying G Buffer.
  55424. * @returns the buffer
  55425. */
  55426. getGBuffer(): MultiRenderTarget;
  55427. /**
  55428. * Gets the number of samples used to render the buffer (anti aliasing).
  55429. */
  55430. /**
  55431. * Sets the number of samples used to render the buffer (anti aliasing).
  55432. */
  55433. samples: number;
  55434. /**
  55435. * Disposes the renderer and frees up associated resources.
  55436. */
  55437. dispose(): void;
  55438. protected _createRenderTargets(): void;
  55439. }
  55440. }
  55441. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  55442. import { Nullable } from "babylonjs/types";
  55443. import { Scene } from "babylonjs/scene";
  55444. import { ISceneComponent } from "babylonjs/sceneComponent";
  55445. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  55446. module "babylonjs/scene" {
  55447. interface Scene {
  55448. /** @hidden (Backing field) */
  55449. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55450. /**
  55451. * Gets or Sets the current geometry buffer associated to the scene.
  55452. */
  55453. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55454. /**
  55455. * Enables a GeometryBufferRender and associates it with the scene
  55456. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55457. * @returns the GeometryBufferRenderer
  55458. */
  55459. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55460. /**
  55461. * Disables the GeometryBufferRender associated with the scene
  55462. */
  55463. disableGeometryBufferRenderer(): void;
  55464. }
  55465. }
  55466. /**
  55467. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55468. * in several rendering techniques.
  55469. */
  55470. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55471. /**
  55472. * The component name helpful to identify the component in the list of scene components.
  55473. */
  55474. readonly name: string;
  55475. /**
  55476. * The scene the component belongs to.
  55477. */
  55478. scene: Scene;
  55479. /**
  55480. * Creates a new instance of the component for the given scene
  55481. * @param scene Defines the scene to register the component in
  55482. */
  55483. constructor(scene: Scene);
  55484. /**
  55485. * Registers the component in a given scene
  55486. */
  55487. register(): void;
  55488. /**
  55489. * Rebuilds the elements related to this component in case of
  55490. * context lost for instance.
  55491. */
  55492. rebuild(): void;
  55493. /**
  55494. * Disposes the component and the associated ressources
  55495. */
  55496. dispose(): void;
  55497. private _gatherRenderTargets;
  55498. }
  55499. }
  55500. declare module "babylonjs/Shaders/motionBlur.fragment" {
  55501. /** @hidden */
  55502. export var motionBlurPixelShader: {
  55503. name: string;
  55504. shader: string;
  55505. };
  55506. }
  55507. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  55508. import { Nullable } from "babylonjs/types";
  55509. import { Camera } from "babylonjs/Cameras/camera";
  55510. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55511. import { Scene } from "babylonjs/scene";
  55512. import "babylonjs/Animations/animatable";
  55513. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55514. import "babylonjs/Shaders/motionBlur.fragment";
  55515. import { Engine } from "babylonjs/Engines/engine";
  55516. /**
  55517. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55518. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55519. * As an example, all you have to do is to create the post-process:
  55520. * var mb = new BABYLON.MotionBlurPostProcess(
  55521. * 'mb', // The name of the effect.
  55522. * scene, // The scene containing the objects to blur according to their velocity.
  55523. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55524. * camera // The camera to apply the render pass to.
  55525. * );
  55526. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55527. */
  55528. export class MotionBlurPostProcess extends PostProcess {
  55529. /**
  55530. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55531. */
  55532. motionStrength: number;
  55533. /**
  55534. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55535. */
  55536. /**
  55537. * Sets the number of iterations to be used for motion blur quality
  55538. */
  55539. motionBlurSamples: number;
  55540. private _motionBlurSamples;
  55541. private _geometryBufferRenderer;
  55542. /**
  55543. * Creates a new instance MotionBlurPostProcess
  55544. * @param name The name of the effect.
  55545. * @param scene The scene containing the objects to blur according to their velocity.
  55546. * @param options The required width/height ratio to downsize to before computing the render pass.
  55547. * @param camera The camera to apply the render pass to.
  55548. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55549. * @param engine The engine which the post process will be applied. (default: current engine)
  55550. * @param reusable If the post process can be reused on the same frame. (default: false)
  55551. * @param textureType Type of textures used when performing the post process. (default: 0)
  55552. * @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)
  55553. */
  55554. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55555. /**
  55556. * Disposes the post process.
  55557. * @param camera The camera to dispose the post process on.
  55558. */
  55559. dispose(camera?: Camera): void;
  55560. }
  55561. }
  55562. declare module "babylonjs/Shaders/refraction.fragment" {
  55563. /** @hidden */
  55564. export var refractionPixelShader: {
  55565. name: string;
  55566. shader: string;
  55567. };
  55568. }
  55569. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  55570. import { Color3 } from "babylonjs/Maths/math";
  55571. import { Camera } from "babylonjs/Cameras/camera";
  55572. import { Texture } from "babylonjs/Materials/Textures/texture";
  55573. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55574. import { Engine } from "babylonjs/Engines/engine";
  55575. import "babylonjs/Shaders/refraction.fragment";
  55576. /**
  55577. * Post process which applies a refractin texture
  55578. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55579. */
  55580. export class RefractionPostProcess extends PostProcess {
  55581. /** the base color of the refraction (used to taint the rendering) */
  55582. color: Color3;
  55583. /** simulated refraction depth */
  55584. depth: number;
  55585. /** the coefficient of the base color (0 to remove base color tainting) */
  55586. colorLevel: number;
  55587. private _refTexture;
  55588. private _ownRefractionTexture;
  55589. /**
  55590. * Gets or sets the refraction texture
  55591. * Please note that you are responsible for disposing the texture if you set it manually
  55592. */
  55593. refractionTexture: Texture;
  55594. /**
  55595. * Initializes the RefractionPostProcess
  55596. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55597. * @param name The name of the effect.
  55598. * @param refractionTextureUrl Url of the refraction texture to use
  55599. * @param color the base color of the refraction (used to taint the rendering)
  55600. * @param depth simulated refraction depth
  55601. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55602. * @param camera The camera to apply the render pass to.
  55603. * @param options The required width/height ratio to downsize to before computing the render pass.
  55604. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55605. * @param engine The engine which the post process will be applied. (default: current engine)
  55606. * @param reusable If the post process can be reused on the same frame. (default: false)
  55607. */
  55608. constructor(name: string, refractionTextureUrl: string,
  55609. /** the base color of the refraction (used to taint the rendering) */
  55610. color: Color3,
  55611. /** simulated refraction depth */
  55612. depth: number,
  55613. /** the coefficient of the base color (0 to remove base color tainting) */
  55614. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55615. /**
  55616. * Disposes of the post process
  55617. * @param camera Camera to dispose post process on
  55618. */
  55619. dispose(camera: Camera): void;
  55620. }
  55621. }
  55622. declare module "babylonjs/Shaders/sharpen.fragment" {
  55623. /** @hidden */
  55624. export var sharpenPixelShader: {
  55625. name: string;
  55626. shader: string;
  55627. };
  55628. }
  55629. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  55630. import { Nullable } from "babylonjs/types";
  55631. import { Camera } from "babylonjs/Cameras/camera";
  55632. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55633. import "babylonjs/Shaders/sharpen.fragment";
  55634. import { Engine } from "babylonjs/Engines/engine";
  55635. /**
  55636. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55637. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55638. */
  55639. export class SharpenPostProcess extends PostProcess {
  55640. /**
  55641. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55642. */
  55643. colorAmount: number;
  55644. /**
  55645. * How much sharpness should be applied (default: 0.3)
  55646. */
  55647. edgeAmount: number;
  55648. /**
  55649. * Creates a new instance ConvolutionPostProcess
  55650. * @param name The name of the effect.
  55651. * @param options The required width/height ratio to downsize to before computing the render pass.
  55652. * @param camera The camera to apply the render pass to.
  55653. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55654. * @param engine The engine which the post process will be applied. (default: current engine)
  55655. * @param reusable If the post process can be reused on the same frame. (default: false)
  55656. * @param textureType Type of textures used when performing the post process. (default: 0)
  55657. * @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)
  55658. */
  55659. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55660. }
  55661. }
  55662. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  55663. import { Nullable } from "babylonjs/types";
  55664. import { Camera } from "babylonjs/Cameras/camera";
  55665. import { Engine } from "babylonjs/Engines/engine";
  55666. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55667. import { IInspectable } from "babylonjs/Misc/iInspectable";
  55668. /**
  55669. * PostProcessRenderPipeline
  55670. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55671. */
  55672. export class PostProcessRenderPipeline {
  55673. private engine;
  55674. private _renderEffects;
  55675. private _renderEffectsForIsolatedPass;
  55676. /**
  55677. * List of inspectable custom properties (used by the Inspector)
  55678. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55679. */
  55680. inspectableCustomProperties: IInspectable[];
  55681. /**
  55682. * @hidden
  55683. */
  55684. protected _cameras: Camera[];
  55685. /** @hidden */
  55686. _name: string;
  55687. /**
  55688. * Gets pipeline name
  55689. */
  55690. readonly name: string;
  55691. /**
  55692. * Initializes a PostProcessRenderPipeline
  55693. * @param engine engine to add the pipeline to
  55694. * @param name name of the pipeline
  55695. */
  55696. constructor(engine: Engine, name: string);
  55697. /**
  55698. * Gets the class name
  55699. * @returns "PostProcessRenderPipeline"
  55700. */
  55701. getClassName(): string;
  55702. /**
  55703. * If all the render effects in the pipeline are supported
  55704. */
  55705. readonly isSupported: boolean;
  55706. /**
  55707. * Adds an effect to the pipeline
  55708. * @param renderEffect the effect to add
  55709. */
  55710. addEffect(renderEffect: PostProcessRenderEffect): void;
  55711. /** @hidden */
  55712. _rebuild(): void;
  55713. /** @hidden */
  55714. _enableEffect(renderEffectName: string, cameras: Camera): void;
  55715. /** @hidden */
  55716. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55717. /** @hidden */
  55718. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55719. /** @hidden */
  55720. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55721. /** @hidden */
  55722. _attachCameras(cameras: Camera, unique: boolean): void;
  55723. /** @hidden */
  55724. _attachCameras(cameras: Camera[], unique: boolean): void;
  55725. /** @hidden */
  55726. _detachCameras(cameras: Camera): void;
  55727. /** @hidden */
  55728. _detachCameras(cameras: Nullable<Camera[]>): void;
  55729. /** @hidden */
  55730. _update(): void;
  55731. /** @hidden */
  55732. _reset(): void;
  55733. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55734. /**
  55735. * Disposes of the pipeline
  55736. */
  55737. dispose(): void;
  55738. }
  55739. }
  55740. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  55741. import { Camera } from "babylonjs/Cameras/camera";
  55742. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55743. /**
  55744. * PostProcessRenderPipelineManager class
  55745. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55746. */
  55747. export class PostProcessRenderPipelineManager {
  55748. private _renderPipelines;
  55749. /**
  55750. * Initializes a PostProcessRenderPipelineManager
  55751. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55752. */
  55753. constructor();
  55754. /**
  55755. * Gets the list of supported render pipelines
  55756. */
  55757. readonly supportedPipelines: PostProcessRenderPipeline[];
  55758. /**
  55759. * Adds a pipeline to the manager
  55760. * @param renderPipeline The pipeline to add
  55761. */
  55762. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55763. /**
  55764. * Attaches a camera to the pipeline
  55765. * @param renderPipelineName The name of the pipeline to attach to
  55766. * @param cameras the camera to attach
  55767. * @param unique if the camera can be attached multiple times to the pipeline
  55768. */
  55769. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55770. /**
  55771. * Detaches a camera from the pipeline
  55772. * @param renderPipelineName The name of the pipeline to detach from
  55773. * @param cameras the camera to detach
  55774. */
  55775. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55776. /**
  55777. * Enables an effect by name on a pipeline
  55778. * @param renderPipelineName the name of the pipeline to enable the effect in
  55779. * @param renderEffectName the name of the effect to enable
  55780. * @param cameras the cameras that the effect should be enabled on
  55781. */
  55782. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55783. /**
  55784. * Disables an effect by name on a pipeline
  55785. * @param renderPipelineName the name of the pipeline to disable the effect in
  55786. * @param renderEffectName the name of the effect to disable
  55787. * @param cameras the cameras that the effect should be disabled on
  55788. */
  55789. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55790. /**
  55791. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55792. */
  55793. update(): void;
  55794. /** @hidden */
  55795. _rebuild(): void;
  55796. /**
  55797. * Disposes of the manager and pipelines
  55798. */
  55799. dispose(): void;
  55800. }
  55801. }
  55802. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  55803. import { ISceneComponent } from "babylonjs/sceneComponent";
  55804. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  55805. import { Scene } from "babylonjs/scene";
  55806. module "babylonjs/scene" {
  55807. interface Scene {
  55808. /** @hidden (Backing field) */
  55809. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55810. /**
  55811. * Gets the postprocess render pipeline manager
  55812. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55813. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55814. */
  55815. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55816. }
  55817. }
  55818. /**
  55819. * Defines the Render Pipeline scene component responsible to rendering pipelines
  55820. */
  55821. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  55822. /**
  55823. * The component name helpfull to identify the component in the list of scene components.
  55824. */
  55825. readonly name: string;
  55826. /**
  55827. * The scene the component belongs to.
  55828. */
  55829. scene: Scene;
  55830. /**
  55831. * Creates a new instance of the component for the given scene
  55832. * @param scene Defines the scene to register the component in
  55833. */
  55834. constructor(scene: Scene);
  55835. /**
  55836. * Registers the component in a given scene
  55837. */
  55838. register(): void;
  55839. /**
  55840. * Rebuilds the elements related to this component in case of
  55841. * context lost for instance.
  55842. */
  55843. rebuild(): void;
  55844. /**
  55845. * Disposes the component and the associated ressources
  55846. */
  55847. dispose(): void;
  55848. private _gatherRenderTargets;
  55849. }
  55850. }
  55851. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  55852. import { IAnimatable } from "babylonjs/Misc/tools";
  55853. import { Camera } from "babylonjs/Cameras/camera";
  55854. import { IDisposable } from "babylonjs/scene";
  55855. import { Scene } from "babylonjs/scene";
  55856. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  55857. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  55858. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  55859. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  55860. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  55861. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55862. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  55863. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  55864. import { Animation } from "babylonjs/Animations/animation";
  55865. /**
  55866. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  55867. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55868. */
  55869. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55870. private _scene;
  55871. private _camerasToBeAttached;
  55872. /**
  55873. * ID of the sharpen post process,
  55874. */
  55875. private readonly SharpenPostProcessId;
  55876. /**
  55877. * @ignore
  55878. * ID of the image processing post process;
  55879. */
  55880. readonly ImageProcessingPostProcessId: string;
  55881. /**
  55882. * @ignore
  55883. * ID of the Fast Approximate Anti-Aliasing post process;
  55884. */
  55885. readonly FxaaPostProcessId: string;
  55886. /**
  55887. * ID of the chromatic aberration post process,
  55888. */
  55889. private readonly ChromaticAberrationPostProcessId;
  55890. /**
  55891. * ID of the grain post process
  55892. */
  55893. private readonly GrainPostProcessId;
  55894. /**
  55895. * Sharpen post process which will apply a sharpen convolution to enhance edges
  55896. */
  55897. sharpen: SharpenPostProcess;
  55898. private _sharpenEffect;
  55899. private bloom;
  55900. /**
  55901. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  55902. */
  55903. depthOfField: DepthOfFieldEffect;
  55904. /**
  55905. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55906. */
  55907. fxaa: FxaaPostProcess;
  55908. /**
  55909. * Image post processing pass used to perform operations such as tone mapping or color grading.
  55910. */
  55911. imageProcessing: ImageProcessingPostProcess;
  55912. /**
  55913. * Chromatic aberration post process which will shift rgb colors in the image
  55914. */
  55915. chromaticAberration: ChromaticAberrationPostProcess;
  55916. private _chromaticAberrationEffect;
  55917. /**
  55918. * Grain post process which add noise to the image
  55919. */
  55920. grain: GrainPostProcess;
  55921. private _grainEffect;
  55922. /**
  55923. * Glow post process which adds a glow to emissive areas of the image
  55924. */
  55925. private _glowLayer;
  55926. /**
  55927. * Animations which can be used to tweak settings over a period of time
  55928. */
  55929. animations: Animation[];
  55930. private _imageProcessingConfigurationObserver;
  55931. private _sharpenEnabled;
  55932. private _bloomEnabled;
  55933. private _depthOfFieldEnabled;
  55934. private _depthOfFieldBlurLevel;
  55935. private _fxaaEnabled;
  55936. private _imageProcessingEnabled;
  55937. private _defaultPipelineTextureType;
  55938. private _bloomScale;
  55939. private _chromaticAberrationEnabled;
  55940. private _grainEnabled;
  55941. private _buildAllowed;
  55942. /**
  55943. * Gets active scene
  55944. */
  55945. readonly scene: Scene;
  55946. /**
  55947. * Enable or disable the sharpen process from the pipeline
  55948. */
  55949. sharpenEnabled: boolean;
  55950. private _resizeObserver;
  55951. private _hardwareScaleLevel;
  55952. private _bloomKernel;
  55953. /**
  55954. * Specifies the size of the bloom blur kernel, relative to the final output size
  55955. */
  55956. bloomKernel: number;
  55957. /**
  55958. * Specifies the weight of the bloom in the final rendering
  55959. */
  55960. private _bloomWeight;
  55961. /**
  55962. * Specifies the luma threshold for the area that will be blurred by the bloom
  55963. */
  55964. private _bloomThreshold;
  55965. private _hdr;
  55966. /**
  55967. * The strength of the bloom.
  55968. */
  55969. bloomWeight: number;
  55970. /**
  55971. * The strength of the bloom.
  55972. */
  55973. bloomThreshold: number;
  55974. /**
  55975. * The scale of the bloom, lower value will provide better performance.
  55976. */
  55977. bloomScale: number;
  55978. /**
  55979. * Enable or disable the bloom from the pipeline
  55980. */
  55981. bloomEnabled: boolean;
  55982. private _rebuildBloom;
  55983. /**
  55984. * If the depth of field is enabled.
  55985. */
  55986. depthOfFieldEnabled: boolean;
  55987. /**
  55988. * Blur level of the depth of field effect. (Higher blur will effect performance)
  55989. */
  55990. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  55991. /**
  55992. * If the anti aliasing is enabled.
  55993. */
  55994. fxaaEnabled: boolean;
  55995. private _samples;
  55996. /**
  55997. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55998. */
  55999. samples: number;
  56000. /**
  56001. * If image processing is enabled.
  56002. */
  56003. imageProcessingEnabled: boolean;
  56004. /**
  56005. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  56006. */
  56007. glowLayerEnabled: boolean;
  56008. /**
  56009. * Enable or disable the chromaticAberration process from the pipeline
  56010. */
  56011. chromaticAberrationEnabled: boolean;
  56012. /**
  56013. * Enable or disable the grain process from the pipeline
  56014. */
  56015. grainEnabled: boolean;
  56016. /**
  56017. * @constructor
  56018. * @param name - The rendering pipeline name (default: "")
  56019. * @param hdr - If high dynamic range textures should be used (default: true)
  56020. * @param scene - The scene linked to this pipeline (default: the last created scene)
  56021. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  56022. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  56023. */
  56024. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  56025. /**
  56026. * Get the class name
  56027. * @returns "DefaultRenderingPipeline"
  56028. */
  56029. getClassName(): string;
  56030. /**
  56031. * Force the compilation of the entire pipeline.
  56032. */
  56033. prepare(): void;
  56034. private _hasCleared;
  56035. private _prevPostProcess;
  56036. private _prevPrevPostProcess;
  56037. private _setAutoClearAndTextureSharing;
  56038. private _depthOfFieldSceneObserver;
  56039. private _buildPipeline;
  56040. private _disposePostProcesses;
  56041. /**
  56042. * Adds a camera to the pipeline
  56043. * @param camera the camera to be added
  56044. */
  56045. addCamera(camera: Camera): void;
  56046. /**
  56047. * Removes a camera from the pipeline
  56048. * @param camera the camera to remove
  56049. */
  56050. removeCamera(camera: Camera): void;
  56051. /**
  56052. * Dispose of the pipeline and stop all post processes
  56053. */
  56054. dispose(): void;
  56055. /**
  56056. * Serialize the rendering pipeline (Used when exporting)
  56057. * @returns the serialized object
  56058. */
  56059. serialize(): any;
  56060. /**
  56061. * Parse the serialized pipeline
  56062. * @param source Source pipeline.
  56063. * @param scene The scene to load the pipeline to.
  56064. * @param rootUrl The URL of the serialized pipeline.
  56065. * @returns An instantiated pipeline from the serialized object.
  56066. */
  56067. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  56068. }
  56069. }
  56070. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  56071. /** @hidden */
  56072. export var lensHighlightsPixelShader: {
  56073. name: string;
  56074. shader: string;
  56075. };
  56076. }
  56077. declare module "babylonjs/Shaders/depthOfField.fragment" {
  56078. /** @hidden */
  56079. export var depthOfFieldPixelShader: {
  56080. name: string;
  56081. shader: string;
  56082. };
  56083. }
  56084. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  56085. import { Camera } from "babylonjs/Cameras/camera";
  56086. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56087. import { Scene } from "babylonjs/scene";
  56088. import "babylonjs/Shaders/chromaticAberration.fragment";
  56089. import "babylonjs/Shaders/lensHighlights.fragment";
  56090. import "babylonjs/Shaders/depthOfField.fragment";
  56091. /**
  56092. * BABYLON.JS Chromatic Aberration GLSL Shader
  56093. * Author: Olivier Guyot
  56094. * Separates very slightly R, G and B colors on the edges of the screen
  56095. * Inspired by Francois Tarlier & Martins Upitis
  56096. */
  56097. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  56098. /**
  56099. * @ignore
  56100. * The chromatic aberration PostProcess id in the pipeline
  56101. */
  56102. LensChromaticAberrationEffect: string;
  56103. /**
  56104. * @ignore
  56105. * The highlights enhancing PostProcess id in the pipeline
  56106. */
  56107. HighlightsEnhancingEffect: string;
  56108. /**
  56109. * @ignore
  56110. * The depth-of-field PostProcess id in the pipeline
  56111. */
  56112. LensDepthOfFieldEffect: string;
  56113. private _scene;
  56114. private _depthTexture;
  56115. private _grainTexture;
  56116. private _chromaticAberrationPostProcess;
  56117. private _highlightsPostProcess;
  56118. private _depthOfFieldPostProcess;
  56119. private _edgeBlur;
  56120. private _grainAmount;
  56121. private _chromaticAberration;
  56122. private _distortion;
  56123. private _highlightsGain;
  56124. private _highlightsThreshold;
  56125. private _dofDistance;
  56126. private _dofAperture;
  56127. private _dofDarken;
  56128. private _dofPentagon;
  56129. private _blurNoise;
  56130. /**
  56131. * @constructor
  56132. *
  56133. * Effect parameters are as follow:
  56134. * {
  56135. * chromatic_aberration: number; // from 0 to x (1 for realism)
  56136. * edge_blur: number; // from 0 to x (1 for realism)
  56137. * distortion: number; // from 0 to x (1 for realism)
  56138. * grain_amount: number; // from 0 to 1
  56139. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  56140. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  56141. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  56142. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  56143. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  56144. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  56145. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  56146. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  56147. * }
  56148. * Note: if an effect parameter is unset, effect is disabled
  56149. *
  56150. * @param name The rendering pipeline name
  56151. * @param parameters - An object containing all parameters (see above)
  56152. * @param scene The scene linked to this pipeline
  56153. * @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)
  56154. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56155. */
  56156. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  56157. /**
  56158. * Get the class name
  56159. * @returns "LensRenderingPipeline"
  56160. */
  56161. getClassName(): string;
  56162. /**
  56163. * Gets associated scene
  56164. */
  56165. readonly scene: Scene;
  56166. /**
  56167. * Gets or sets the edge blur
  56168. */
  56169. edgeBlur: number;
  56170. /**
  56171. * Gets or sets the grain amount
  56172. */
  56173. grainAmount: number;
  56174. /**
  56175. * Gets or sets the chromatic aberration amount
  56176. */
  56177. chromaticAberration: number;
  56178. /**
  56179. * Gets or sets the depth of field aperture
  56180. */
  56181. dofAperture: number;
  56182. /**
  56183. * Gets or sets the edge distortion
  56184. */
  56185. edgeDistortion: number;
  56186. /**
  56187. * Gets or sets the depth of field distortion
  56188. */
  56189. dofDistortion: number;
  56190. /**
  56191. * Gets or sets the darken out of focus amount
  56192. */
  56193. darkenOutOfFocus: number;
  56194. /**
  56195. * Gets or sets a boolean indicating if blur noise is enabled
  56196. */
  56197. blurNoise: boolean;
  56198. /**
  56199. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  56200. */
  56201. pentagonBokeh: boolean;
  56202. /**
  56203. * Gets or sets the highlight grain amount
  56204. */
  56205. highlightsGain: number;
  56206. /**
  56207. * Gets or sets the highlight threshold
  56208. */
  56209. highlightsThreshold: number;
  56210. /**
  56211. * Sets the amount of blur at the edges
  56212. * @param amount blur amount
  56213. */
  56214. setEdgeBlur(amount: number): void;
  56215. /**
  56216. * Sets edge blur to 0
  56217. */
  56218. disableEdgeBlur(): void;
  56219. /**
  56220. * Sets the amout of grain
  56221. * @param amount Amount of grain
  56222. */
  56223. setGrainAmount(amount: number): void;
  56224. /**
  56225. * Set grain amount to 0
  56226. */
  56227. disableGrain(): void;
  56228. /**
  56229. * Sets the chromatic aberration amount
  56230. * @param amount amount of chromatic aberration
  56231. */
  56232. setChromaticAberration(amount: number): void;
  56233. /**
  56234. * Sets chromatic aberration amount to 0
  56235. */
  56236. disableChromaticAberration(): void;
  56237. /**
  56238. * Sets the EdgeDistortion amount
  56239. * @param amount amount of EdgeDistortion
  56240. */
  56241. setEdgeDistortion(amount: number): void;
  56242. /**
  56243. * Sets edge distortion to 0
  56244. */
  56245. disableEdgeDistortion(): void;
  56246. /**
  56247. * Sets the FocusDistance amount
  56248. * @param amount amount of FocusDistance
  56249. */
  56250. setFocusDistance(amount: number): void;
  56251. /**
  56252. * Disables depth of field
  56253. */
  56254. disableDepthOfField(): void;
  56255. /**
  56256. * Sets the Aperture amount
  56257. * @param amount amount of Aperture
  56258. */
  56259. setAperture(amount: number): void;
  56260. /**
  56261. * Sets the DarkenOutOfFocus amount
  56262. * @param amount amount of DarkenOutOfFocus
  56263. */
  56264. setDarkenOutOfFocus(amount: number): void;
  56265. private _pentagonBokehIsEnabled;
  56266. /**
  56267. * Creates a pentagon bokeh effect
  56268. */
  56269. enablePentagonBokeh(): void;
  56270. /**
  56271. * Disables the pentagon bokeh effect
  56272. */
  56273. disablePentagonBokeh(): void;
  56274. /**
  56275. * Enables noise blur
  56276. */
  56277. enableNoiseBlur(): void;
  56278. /**
  56279. * Disables noise blur
  56280. */
  56281. disableNoiseBlur(): void;
  56282. /**
  56283. * Sets the HighlightsGain amount
  56284. * @param amount amount of HighlightsGain
  56285. */
  56286. setHighlightsGain(amount: number): void;
  56287. /**
  56288. * Sets the HighlightsThreshold amount
  56289. * @param amount amount of HighlightsThreshold
  56290. */
  56291. setHighlightsThreshold(amount: number): void;
  56292. /**
  56293. * Disables highlights
  56294. */
  56295. disableHighlights(): void;
  56296. /**
  56297. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  56298. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  56299. */
  56300. dispose(disableDepthRender?: boolean): void;
  56301. private _createChromaticAberrationPostProcess;
  56302. private _createHighlightsPostProcess;
  56303. private _createDepthOfFieldPostProcess;
  56304. private _createGrainTexture;
  56305. }
  56306. }
  56307. declare module "babylonjs/Shaders/ssao2.fragment" {
  56308. /** @hidden */
  56309. export var ssao2PixelShader: {
  56310. name: string;
  56311. shader: string;
  56312. };
  56313. }
  56314. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  56315. /** @hidden */
  56316. export var ssaoCombinePixelShader: {
  56317. name: string;
  56318. shader: string;
  56319. };
  56320. }
  56321. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  56322. import { Camera } from "babylonjs/Cameras/camera";
  56323. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56324. import { Scene } from "babylonjs/scene";
  56325. import "babylonjs/Shaders/ssao2.fragment";
  56326. import "babylonjs/Shaders/ssaoCombine.fragment";
  56327. /**
  56328. * Render pipeline to produce ssao effect
  56329. */
  56330. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  56331. /**
  56332. * @ignore
  56333. * The PassPostProcess id in the pipeline that contains the original scene color
  56334. */
  56335. SSAOOriginalSceneColorEffect: string;
  56336. /**
  56337. * @ignore
  56338. * The SSAO PostProcess id in the pipeline
  56339. */
  56340. SSAORenderEffect: string;
  56341. /**
  56342. * @ignore
  56343. * The horizontal blur PostProcess id in the pipeline
  56344. */
  56345. SSAOBlurHRenderEffect: string;
  56346. /**
  56347. * @ignore
  56348. * The vertical blur PostProcess id in the pipeline
  56349. */
  56350. SSAOBlurVRenderEffect: string;
  56351. /**
  56352. * @ignore
  56353. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56354. */
  56355. SSAOCombineRenderEffect: string;
  56356. /**
  56357. * The output strength of the SSAO post-process. Default value is 1.0.
  56358. */
  56359. totalStrength: number;
  56360. /**
  56361. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  56362. */
  56363. maxZ: number;
  56364. /**
  56365. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  56366. */
  56367. minZAspect: number;
  56368. private _samples;
  56369. /**
  56370. * Number of samples used for the SSAO calculations. Default value is 8
  56371. */
  56372. samples: number;
  56373. private _textureSamples;
  56374. /**
  56375. * Number of samples to use for antialiasing
  56376. */
  56377. textureSamples: number;
  56378. /**
  56379. * Ratio object used for SSAO ratio and blur ratio
  56380. */
  56381. private _ratio;
  56382. /**
  56383. * Dynamically generated sphere sampler.
  56384. */
  56385. private _sampleSphere;
  56386. /**
  56387. * Blur filter offsets
  56388. */
  56389. private _samplerOffsets;
  56390. private _expensiveBlur;
  56391. /**
  56392. * If bilateral blur should be used
  56393. */
  56394. expensiveBlur: boolean;
  56395. /**
  56396. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56397. */
  56398. radius: number;
  56399. /**
  56400. * The base color of the SSAO post-process
  56401. * The final result is "base + ssao" between [0, 1]
  56402. */
  56403. base: number;
  56404. /**
  56405. * Support test.
  56406. */
  56407. static readonly IsSupported: boolean;
  56408. private _scene;
  56409. private _depthTexture;
  56410. private _normalTexture;
  56411. private _randomTexture;
  56412. private _originalColorPostProcess;
  56413. private _ssaoPostProcess;
  56414. private _blurHPostProcess;
  56415. private _blurVPostProcess;
  56416. private _ssaoCombinePostProcess;
  56417. private _firstUpdate;
  56418. /**
  56419. * Gets active scene
  56420. */
  56421. readonly scene: Scene;
  56422. /**
  56423. * @constructor
  56424. * @param name The rendering pipeline name
  56425. * @param scene The scene linked to this pipeline
  56426. * @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 }
  56427. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56428. */
  56429. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56430. /**
  56431. * Get the class name
  56432. * @returns "SSAO2RenderingPipeline"
  56433. */
  56434. getClassName(): string;
  56435. /**
  56436. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56437. */
  56438. dispose(disableGeometryBufferRenderer?: boolean): void;
  56439. private _createBlurPostProcess;
  56440. /** @hidden */
  56441. _rebuild(): void;
  56442. private _bits;
  56443. private _radicalInverse_VdC;
  56444. private _hammersley;
  56445. private _hemisphereSample_uniform;
  56446. private _generateHemisphere;
  56447. private _createSSAOPostProcess;
  56448. private _createSSAOCombinePostProcess;
  56449. private _createRandomTexture;
  56450. /**
  56451. * Serialize the rendering pipeline (Used when exporting)
  56452. * @returns the serialized object
  56453. */
  56454. serialize(): any;
  56455. /**
  56456. * Parse the serialized pipeline
  56457. * @param source Source pipeline.
  56458. * @param scene The scene to load the pipeline to.
  56459. * @param rootUrl The URL of the serialized pipeline.
  56460. * @returns An instantiated pipeline from the serialized object.
  56461. */
  56462. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56463. }
  56464. }
  56465. declare module "babylonjs/Shaders/ssao.fragment" {
  56466. /** @hidden */
  56467. export var ssaoPixelShader: {
  56468. name: string;
  56469. shader: string;
  56470. };
  56471. }
  56472. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  56473. import { Camera } from "babylonjs/Cameras/camera";
  56474. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56475. import { Scene } from "babylonjs/scene";
  56476. import "babylonjs/Shaders/ssao.fragment";
  56477. import "babylonjs/Shaders/ssaoCombine.fragment";
  56478. /**
  56479. * Render pipeline to produce ssao effect
  56480. */
  56481. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56482. /**
  56483. * @ignore
  56484. * The PassPostProcess id in the pipeline that contains the original scene color
  56485. */
  56486. SSAOOriginalSceneColorEffect: string;
  56487. /**
  56488. * @ignore
  56489. * The SSAO PostProcess id in the pipeline
  56490. */
  56491. SSAORenderEffect: string;
  56492. /**
  56493. * @ignore
  56494. * The horizontal blur PostProcess id in the pipeline
  56495. */
  56496. SSAOBlurHRenderEffect: string;
  56497. /**
  56498. * @ignore
  56499. * The vertical blur PostProcess id in the pipeline
  56500. */
  56501. SSAOBlurVRenderEffect: string;
  56502. /**
  56503. * @ignore
  56504. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56505. */
  56506. SSAOCombineRenderEffect: string;
  56507. /**
  56508. * The output strength of the SSAO post-process. Default value is 1.0.
  56509. */
  56510. totalStrength: number;
  56511. /**
  56512. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56513. */
  56514. radius: number;
  56515. /**
  56516. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56517. * Must not be equal to fallOff and superior to fallOff.
  56518. * Default value is 0.0075
  56519. */
  56520. area: number;
  56521. /**
  56522. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56523. * Must not be equal to area and inferior to area.
  56524. * Default value is 0.000001
  56525. */
  56526. fallOff: number;
  56527. /**
  56528. * The base color of the SSAO post-process
  56529. * The final result is "base + ssao" between [0, 1]
  56530. */
  56531. base: number;
  56532. private _scene;
  56533. private _depthTexture;
  56534. private _randomTexture;
  56535. private _originalColorPostProcess;
  56536. private _ssaoPostProcess;
  56537. private _blurHPostProcess;
  56538. private _blurVPostProcess;
  56539. private _ssaoCombinePostProcess;
  56540. private _firstUpdate;
  56541. /**
  56542. * Gets active scene
  56543. */
  56544. readonly scene: Scene;
  56545. /**
  56546. * @constructor
  56547. * @param name - The rendering pipeline name
  56548. * @param scene - The scene linked to this pipeline
  56549. * @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 }
  56550. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56551. */
  56552. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56553. /**
  56554. * Get the class name
  56555. * @returns "SSAORenderingPipeline"
  56556. */
  56557. getClassName(): string;
  56558. /**
  56559. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56560. */
  56561. dispose(disableDepthRender?: boolean): void;
  56562. private _createBlurPostProcess;
  56563. /** @hidden */
  56564. _rebuild(): void;
  56565. private _createSSAOPostProcess;
  56566. private _createSSAOCombinePostProcess;
  56567. private _createRandomTexture;
  56568. }
  56569. }
  56570. declare module "babylonjs/Shaders/standard.fragment" {
  56571. /** @hidden */
  56572. export var standardPixelShader: {
  56573. name: string;
  56574. shader: string;
  56575. };
  56576. }
  56577. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  56578. import { Nullable } from "babylonjs/types";
  56579. import { IAnimatable } from "babylonjs/Misc/tools";
  56580. import { Camera } from "babylonjs/Cameras/camera";
  56581. import { Texture } from "babylonjs/Materials/Textures/texture";
  56582. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56583. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56584. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  56585. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56586. import { IDisposable } from "babylonjs/scene";
  56587. import { SpotLight } from "babylonjs/Lights/spotLight";
  56588. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56589. import { Scene } from "babylonjs/scene";
  56590. import { Animation } from "babylonjs/Animations/animation";
  56591. import "babylonjs/Shaders/standard.fragment";
  56592. /**
  56593. * Standard rendering pipeline
  56594. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56595. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56596. */
  56597. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56598. /**
  56599. * Public members
  56600. */
  56601. /**
  56602. * Post-process which contains the original scene color before the pipeline applies all the effects
  56603. */
  56604. originalPostProcess: Nullable<PostProcess>;
  56605. /**
  56606. * Post-process used to down scale an image x4
  56607. */
  56608. downSampleX4PostProcess: Nullable<PostProcess>;
  56609. /**
  56610. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56611. */
  56612. brightPassPostProcess: Nullable<PostProcess>;
  56613. /**
  56614. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56615. */
  56616. blurHPostProcesses: PostProcess[];
  56617. /**
  56618. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56619. */
  56620. blurVPostProcesses: PostProcess[];
  56621. /**
  56622. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56623. */
  56624. textureAdderPostProcess: Nullable<PostProcess>;
  56625. /**
  56626. * Post-process used to create volumetric lighting effect
  56627. */
  56628. volumetricLightPostProcess: Nullable<PostProcess>;
  56629. /**
  56630. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56631. */
  56632. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56633. /**
  56634. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56635. */
  56636. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56637. /**
  56638. * Post-process used to merge the volumetric light effect and the real scene color
  56639. */
  56640. volumetricLightMergePostProces: Nullable<PostProcess>;
  56641. /**
  56642. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56643. */
  56644. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56645. /**
  56646. * Base post-process used to calculate the average luminance of the final image for HDR
  56647. */
  56648. luminancePostProcess: Nullable<PostProcess>;
  56649. /**
  56650. * Post-processes used to create down sample post-processes in order to get
  56651. * the average luminance of the final image for HDR
  56652. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56653. */
  56654. luminanceDownSamplePostProcesses: PostProcess[];
  56655. /**
  56656. * Post-process used to create a HDR effect (light adaptation)
  56657. */
  56658. hdrPostProcess: Nullable<PostProcess>;
  56659. /**
  56660. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56661. */
  56662. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56663. /**
  56664. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56665. */
  56666. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56667. /**
  56668. * Post-process used to merge the final HDR post-process and the real scene color
  56669. */
  56670. hdrFinalPostProcess: Nullable<PostProcess>;
  56671. /**
  56672. * Post-process used to create a lens flare effect
  56673. */
  56674. lensFlarePostProcess: Nullable<PostProcess>;
  56675. /**
  56676. * Post-process that merges the result of the lens flare post-process and the real scene color
  56677. */
  56678. lensFlareComposePostProcess: Nullable<PostProcess>;
  56679. /**
  56680. * Post-process used to create a motion blur effect
  56681. */
  56682. motionBlurPostProcess: Nullable<PostProcess>;
  56683. /**
  56684. * Post-process used to create a depth of field effect
  56685. */
  56686. depthOfFieldPostProcess: Nullable<PostProcess>;
  56687. /**
  56688. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56689. */
  56690. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56691. /**
  56692. * Represents the brightness threshold in order to configure the illuminated surfaces
  56693. */
  56694. brightThreshold: number;
  56695. /**
  56696. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56697. */
  56698. blurWidth: number;
  56699. /**
  56700. * Sets if the blur for highlighted surfaces must be only horizontal
  56701. */
  56702. horizontalBlur: boolean;
  56703. /**
  56704. * Gets the overall exposure used by the pipeline
  56705. */
  56706. /**
  56707. * Sets the overall exposure used by the pipeline
  56708. */
  56709. exposure: number;
  56710. /**
  56711. * Texture used typically to simulate "dirty" on camera lens
  56712. */
  56713. lensTexture: Nullable<Texture>;
  56714. /**
  56715. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56716. */
  56717. volumetricLightCoefficient: number;
  56718. /**
  56719. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56720. */
  56721. volumetricLightPower: number;
  56722. /**
  56723. * Used the set the blur intensity to smooth the volumetric lights
  56724. */
  56725. volumetricLightBlurScale: number;
  56726. /**
  56727. * Light (spot or directional) used to generate the volumetric lights rays
  56728. * The source light must have a shadow generate so the pipeline can get its
  56729. * depth map
  56730. */
  56731. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56732. /**
  56733. * For eye adaptation, represents the minimum luminance the eye can see
  56734. */
  56735. hdrMinimumLuminance: number;
  56736. /**
  56737. * For eye adaptation, represents the decrease luminance speed
  56738. */
  56739. hdrDecreaseRate: number;
  56740. /**
  56741. * For eye adaptation, represents the increase luminance speed
  56742. */
  56743. hdrIncreaseRate: number;
  56744. /**
  56745. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56746. */
  56747. /**
  56748. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56749. */
  56750. hdrAutoExposure: boolean;
  56751. /**
  56752. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56753. */
  56754. lensColorTexture: Nullable<Texture>;
  56755. /**
  56756. * The overall strengh for the lens flare effect
  56757. */
  56758. lensFlareStrength: number;
  56759. /**
  56760. * Dispersion coefficient for lens flare ghosts
  56761. */
  56762. lensFlareGhostDispersal: number;
  56763. /**
  56764. * Main lens flare halo width
  56765. */
  56766. lensFlareHaloWidth: number;
  56767. /**
  56768. * Based on the lens distortion effect, defines how much the lens flare result
  56769. * is distorted
  56770. */
  56771. lensFlareDistortionStrength: number;
  56772. /**
  56773. * Lens star texture must be used to simulate rays on the flares and is available
  56774. * in the documentation
  56775. */
  56776. lensStarTexture: Nullable<Texture>;
  56777. /**
  56778. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56779. * flare effect by taking account of the dirt texture
  56780. */
  56781. lensFlareDirtTexture: Nullable<Texture>;
  56782. /**
  56783. * Represents the focal length for the depth of field effect
  56784. */
  56785. depthOfFieldDistance: number;
  56786. /**
  56787. * Represents the blur intensity for the blurred part of the depth of field effect
  56788. */
  56789. depthOfFieldBlurWidth: number;
  56790. /**
  56791. * For motion blur, defines how much the image is blurred by the movement
  56792. */
  56793. motionStrength: number;
  56794. /**
  56795. * List of animations for the pipeline (IAnimatable implementation)
  56796. */
  56797. animations: Animation[];
  56798. /**
  56799. * Private members
  56800. */
  56801. private _scene;
  56802. private _currentDepthOfFieldSource;
  56803. private _basePostProcess;
  56804. private _fixedExposure;
  56805. private _currentExposure;
  56806. private _hdrAutoExposure;
  56807. private _hdrCurrentLuminance;
  56808. private _floatTextureType;
  56809. private _ratio;
  56810. private _bloomEnabled;
  56811. private _depthOfFieldEnabled;
  56812. private _vlsEnabled;
  56813. private _lensFlareEnabled;
  56814. private _hdrEnabled;
  56815. private _motionBlurEnabled;
  56816. private _fxaaEnabled;
  56817. private _motionBlurSamples;
  56818. private _volumetricLightStepsCount;
  56819. private _samples;
  56820. /**
  56821. * @ignore
  56822. * Specifies if the bloom pipeline is enabled
  56823. */
  56824. BloomEnabled: boolean;
  56825. /**
  56826. * @ignore
  56827. * Specifies if the depth of field pipeline is enabed
  56828. */
  56829. DepthOfFieldEnabled: boolean;
  56830. /**
  56831. * @ignore
  56832. * Specifies if the lens flare pipeline is enabed
  56833. */
  56834. LensFlareEnabled: boolean;
  56835. /**
  56836. * @ignore
  56837. * Specifies if the HDR pipeline is enabled
  56838. */
  56839. HDREnabled: boolean;
  56840. /**
  56841. * @ignore
  56842. * Specifies if the volumetric lights scattering effect is enabled
  56843. */
  56844. VLSEnabled: boolean;
  56845. /**
  56846. * @ignore
  56847. * Specifies if the motion blur effect is enabled
  56848. */
  56849. MotionBlurEnabled: boolean;
  56850. /**
  56851. * Specifies if anti-aliasing is enabled
  56852. */
  56853. fxaaEnabled: boolean;
  56854. /**
  56855. * Specifies the number of steps used to calculate the volumetric lights
  56856. * Typically in interval [50, 200]
  56857. */
  56858. volumetricLightStepsCount: number;
  56859. /**
  56860. * Specifies the number of samples used for the motion blur effect
  56861. * Typically in interval [16, 64]
  56862. */
  56863. motionBlurSamples: number;
  56864. /**
  56865. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56866. */
  56867. samples: number;
  56868. /**
  56869. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56870. * @constructor
  56871. * @param name The rendering pipeline name
  56872. * @param scene The scene linked to this pipeline
  56873. * @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)
  56874. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  56875. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56876. */
  56877. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  56878. private _buildPipeline;
  56879. private _createDownSampleX4PostProcess;
  56880. private _createBrightPassPostProcess;
  56881. private _createBlurPostProcesses;
  56882. private _createTextureAdderPostProcess;
  56883. private _createVolumetricLightPostProcess;
  56884. private _createLuminancePostProcesses;
  56885. private _createHdrPostProcess;
  56886. private _createLensFlarePostProcess;
  56887. private _createDepthOfFieldPostProcess;
  56888. private _createMotionBlurPostProcess;
  56889. private _getDepthTexture;
  56890. private _disposePostProcesses;
  56891. /**
  56892. * Dispose of the pipeline and stop all post processes
  56893. */
  56894. dispose(): void;
  56895. /**
  56896. * Serialize the rendering pipeline (Used when exporting)
  56897. * @returns the serialized object
  56898. */
  56899. serialize(): any;
  56900. /**
  56901. * Parse the serialized pipeline
  56902. * @param source Source pipeline.
  56903. * @param scene The scene to load the pipeline to.
  56904. * @param rootUrl The URL of the serialized pipeline.
  56905. * @returns An instantiated pipeline from the serialized object.
  56906. */
  56907. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  56908. /**
  56909. * Luminance steps
  56910. */
  56911. static LuminanceSteps: number;
  56912. }
  56913. }
  56914. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  56915. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  56916. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  56917. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  56918. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  56919. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  56920. }
  56921. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  56922. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  56923. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  56924. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56925. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  56926. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  56927. }
  56928. declare module "babylonjs/Shaders/tonemap.fragment" {
  56929. /** @hidden */
  56930. export var tonemapPixelShader: {
  56931. name: string;
  56932. shader: string;
  56933. };
  56934. }
  56935. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  56936. import { Camera } from "babylonjs/Cameras/camera";
  56937. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56938. import "babylonjs/Shaders/tonemap.fragment";
  56939. import { Engine } from "babylonjs/Engines/engine";
  56940. /** Defines operator used for tonemapping */
  56941. export enum TonemappingOperator {
  56942. /** Hable */
  56943. Hable = 0,
  56944. /** Reinhard */
  56945. Reinhard = 1,
  56946. /** HejiDawson */
  56947. HejiDawson = 2,
  56948. /** Photographic */
  56949. Photographic = 3
  56950. }
  56951. /**
  56952. * Defines a post process to apply tone mapping
  56953. */
  56954. export class TonemapPostProcess extends PostProcess {
  56955. private _operator;
  56956. /** Defines the required exposure adjustement */
  56957. exposureAdjustment: number;
  56958. /**
  56959. * Creates a new TonemapPostProcess
  56960. * @param name defines the name of the postprocess
  56961. * @param _operator defines the operator to use
  56962. * @param exposureAdjustment defines the required exposure adjustement
  56963. * @param camera defines the camera to use (can be null)
  56964. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  56965. * @param engine defines the hosting engine (can be ignore if camera is set)
  56966. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56967. */
  56968. constructor(name: string, _operator: TonemappingOperator,
  56969. /** Defines the required exposure adjustement */
  56970. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  56971. }
  56972. }
  56973. declare module "babylonjs/Shaders/depth.vertex" {
  56974. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56975. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56976. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56977. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56978. /** @hidden */
  56979. export var depthVertexShader: {
  56980. name: string;
  56981. shader: string;
  56982. };
  56983. }
  56984. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  56985. /** @hidden */
  56986. export var volumetricLightScatteringPixelShader: {
  56987. name: string;
  56988. shader: string;
  56989. };
  56990. }
  56991. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  56992. /** @hidden */
  56993. export var volumetricLightScatteringPassPixelShader: {
  56994. name: string;
  56995. shader: string;
  56996. };
  56997. }
  56998. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  56999. import { Vector3 } from "babylonjs/Maths/math";
  57000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57001. import { Mesh } from "babylonjs/Meshes/mesh";
  57002. import { Camera } from "babylonjs/Cameras/camera";
  57003. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57004. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57005. import { Scene } from "babylonjs/scene";
  57006. import "babylonjs/Meshes/Builders/planeBuilder";
  57007. import "babylonjs/Shaders/depth.vertex";
  57008. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  57009. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  57010. import { Engine } from "babylonjs/Engines/engine";
  57011. /**
  57012. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  57013. */
  57014. export class VolumetricLightScatteringPostProcess extends PostProcess {
  57015. private _volumetricLightScatteringPass;
  57016. private _volumetricLightScatteringRTT;
  57017. private _viewPort;
  57018. private _screenCoordinates;
  57019. private _cachedDefines;
  57020. /**
  57021. * If not undefined, the mesh position is computed from the attached node position
  57022. */
  57023. attachedNode: {
  57024. position: Vector3;
  57025. };
  57026. /**
  57027. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  57028. */
  57029. customMeshPosition: Vector3;
  57030. /**
  57031. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  57032. */
  57033. useCustomMeshPosition: boolean;
  57034. /**
  57035. * If the post-process should inverse the light scattering direction
  57036. */
  57037. invert: boolean;
  57038. /**
  57039. * The internal mesh used by the post-process
  57040. */
  57041. mesh: Mesh;
  57042. /**
  57043. * @hidden
  57044. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  57045. */
  57046. useDiffuseColor: boolean;
  57047. /**
  57048. * Array containing the excluded meshes not rendered in the internal pass
  57049. */
  57050. excludedMeshes: AbstractMesh[];
  57051. /**
  57052. * Controls the overall intensity of the post-process
  57053. */
  57054. exposure: number;
  57055. /**
  57056. * Dissipates each sample's contribution in range [0, 1]
  57057. */
  57058. decay: number;
  57059. /**
  57060. * Controls the overall intensity of each sample
  57061. */
  57062. weight: number;
  57063. /**
  57064. * Controls the density of each sample
  57065. */
  57066. density: number;
  57067. /**
  57068. * @constructor
  57069. * @param name The post-process name
  57070. * @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)
  57071. * @param camera The camera that the post-process will be attached to
  57072. * @param mesh The mesh used to create the light scattering
  57073. * @param samples The post-process quality, default 100
  57074. * @param samplingModeThe post-process filtering mode
  57075. * @param engine The babylon engine
  57076. * @param reusable If the post-process is reusable
  57077. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  57078. */
  57079. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  57080. /**
  57081. * Returns the string "VolumetricLightScatteringPostProcess"
  57082. * @returns "VolumetricLightScatteringPostProcess"
  57083. */
  57084. getClassName(): string;
  57085. private _isReady;
  57086. /**
  57087. * Sets the new light position for light scattering effect
  57088. * @param position The new custom light position
  57089. */
  57090. setCustomMeshPosition(position: Vector3): void;
  57091. /**
  57092. * Returns the light position for light scattering effect
  57093. * @return Vector3 The custom light position
  57094. */
  57095. getCustomMeshPosition(): Vector3;
  57096. /**
  57097. * Disposes the internal assets and detaches the post-process from the camera
  57098. */
  57099. dispose(camera: Camera): void;
  57100. /**
  57101. * Returns the render target texture used by the post-process
  57102. * @return the render target texture used by the post-process
  57103. */
  57104. getPass(): RenderTargetTexture;
  57105. private _meshExcluded;
  57106. private _createPass;
  57107. private _updateMeshScreenCoordinates;
  57108. /**
  57109. * Creates a default mesh for the Volumeric Light Scattering post-process
  57110. * @param name The mesh name
  57111. * @param scene The scene where to create the mesh
  57112. * @return the default mesh
  57113. */
  57114. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  57115. }
  57116. }
  57117. declare module "babylonjs/PostProcesses/index" {
  57118. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  57119. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  57120. export * from "babylonjs/PostProcesses/bloomEffect";
  57121. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  57122. export * from "babylonjs/PostProcesses/blurPostProcess";
  57123. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  57124. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  57125. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  57126. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  57127. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  57128. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  57129. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  57130. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  57131. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57132. export * from "babylonjs/PostProcesses/filterPostProcess";
  57133. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  57134. export * from "babylonjs/PostProcesses/grainPostProcess";
  57135. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  57136. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  57137. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  57138. export * from "babylonjs/PostProcesses/passPostProcess";
  57139. export * from "babylonjs/PostProcesses/postProcess";
  57140. export * from "babylonjs/PostProcesses/postProcessManager";
  57141. export * from "babylonjs/PostProcesses/refractionPostProcess";
  57142. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  57143. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  57144. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  57145. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  57146. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  57147. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  57148. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  57149. }
  57150. declare module "babylonjs/Probes/index" {
  57151. export * from "babylonjs/Probes/reflectionProbe";
  57152. }
  57153. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  57154. import { Scene } from "babylonjs/scene";
  57155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57156. import { Color3 } from "babylonjs/Maths/math";
  57157. import { SmartArray } from "babylonjs/Misc/smartArray";
  57158. import { ISceneComponent } from "babylonjs/sceneComponent";
  57159. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  57160. import "babylonjs/Meshes/Builders/boxBuilder";
  57161. import "babylonjs/Shaders/color.fragment";
  57162. import "babylonjs/Shaders/color.vertex";
  57163. module "babylonjs/scene" {
  57164. interface Scene {
  57165. /** @hidden (Backing field) */
  57166. _boundingBoxRenderer: BoundingBoxRenderer;
  57167. /** @hidden (Backing field) */
  57168. _forceShowBoundingBoxes: boolean;
  57169. /**
  57170. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  57171. */
  57172. forceShowBoundingBoxes: boolean;
  57173. /**
  57174. * Gets the bounding box renderer associated with the scene
  57175. * @returns a BoundingBoxRenderer
  57176. */
  57177. getBoundingBoxRenderer(): BoundingBoxRenderer;
  57178. }
  57179. }
  57180. module "babylonjs/Meshes/abstractMesh" {
  57181. interface AbstractMesh {
  57182. /** @hidden (Backing field) */
  57183. _showBoundingBox: boolean;
  57184. /**
  57185. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  57186. */
  57187. showBoundingBox: boolean;
  57188. }
  57189. }
  57190. /**
  57191. * Component responsible of rendering the bounding box of the meshes in a scene.
  57192. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  57193. */
  57194. export class BoundingBoxRenderer implements ISceneComponent {
  57195. /**
  57196. * The component name helpfull to identify the component in the list of scene components.
  57197. */
  57198. readonly name: string;
  57199. /**
  57200. * The scene the component belongs to.
  57201. */
  57202. scene: Scene;
  57203. /**
  57204. * Color of the bounding box lines placed in front of an object
  57205. */
  57206. frontColor: Color3;
  57207. /**
  57208. * Color of the bounding box lines placed behind an object
  57209. */
  57210. backColor: Color3;
  57211. /**
  57212. * Defines if the renderer should show the back lines or not
  57213. */
  57214. showBackLines: boolean;
  57215. /**
  57216. * @hidden
  57217. */
  57218. renderList: SmartArray<BoundingBox>;
  57219. private _colorShader;
  57220. private _vertexBuffers;
  57221. private _indexBuffer;
  57222. /**
  57223. * Instantiates a new bounding box renderer in a scene.
  57224. * @param scene the scene the renderer renders in
  57225. */
  57226. constructor(scene: Scene);
  57227. /**
  57228. * Registers the component in a given scene
  57229. */
  57230. register(): void;
  57231. private _evaluateSubMesh;
  57232. private _activeMesh;
  57233. private _prepareRessources;
  57234. private _createIndexBuffer;
  57235. /**
  57236. * Rebuilds the elements related to this component in case of
  57237. * context lost for instance.
  57238. */
  57239. rebuild(): void;
  57240. /**
  57241. * @hidden
  57242. */
  57243. reset(): void;
  57244. /**
  57245. * Render the bounding boxes of a specific rendering group
  57246. * @param renderingGroupId defines the rendering group to render
  57247. */
  57248. render(renderingGroupId: number): void;
  57249. /**
  57250. * In case of occlusion queries, we can render the occlusion bounding box through this method
  57251. * @param mesh Define the mesh to render the occlusion bounding box for
  57252. */
  57253. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  57254. /**
  57255. * Dispose and release the resources attached to this renderer.
  57256. */
  57257. dispose(): void;
  57258. }
  57259. }
  57260. declare module "babylonjs/Shaders/depth.fragment" {
  57261. /** @hidden */
  57262. export var depthPixelShader: {
  57263. name: string;
  57264. shader: string;
  57265. };
  57266. }
  57267. declare module "babylonjs/Rendering/depthRenderer" {
  57268. import { Nullable } from "babylonjs/types";
  57269. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57270. import { Scene } from "babylonjs/scene";
  57271. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57272. import { Camera } from "babylonjs/Cameras/camera";
  57273. import "babylonjs/Shaders/depth.fragment";
  57274. import "babylonjs/Shaders/depth.vertex";
  57275. /**
  57276. * This represents a depth renderer in Babylon.
  57277. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57278. */
  57279. export class DepthRenderer {
  57280. private _scene;
  57281. private _depthMap;
  57282. private _effect;
  57283. private _cachedDefines;
  57284. private _camera;
  57285. /**
  57286. * Specifiess that the depth renderer will only be used within
  57287. * the camera it is created for.
  57288. * This can help forcing its rendering during the camera processing.
  57289. */
  57290. useOnlyInActiveCamera: boolean;
  57291. /** @hidden */
  57292. static _SceneComponentInitialization: (scene: Scene) => void;
  57293. /**
  57294. * Instantiates a depth renderer
  57295. * @param scene The scene the renderer belongs to
  57296. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57297. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57298. */
  57299. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  57300. /**
  57301. * Creates the depth rendering effect and checks if the effect is ready.
  57302. * @param subMesh The submesh to be used to render the depth map of
  57303. * @param useInstances If multiple world instances should be used
  57304. * @returns if the depth renderer is ready to render the depth map
  57305. */
  57306. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57307. /**
  57308. * Gets the texture which the depth map will be written to.
  57309. * @returns The depth map texture
  57310. */
  57311. getDepthMap(): RenderTargetTexture;
  57312. /**
  57313. * Disposes of the depth renderer.
  57314. */
  57315. dispose(): void;
  57316. }
  57317. }
  57318. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  57319. import { Nullable } from "babylonjs/types";
  57320. import { Scene } from "babylonjs/scene";
  57321. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57322. import { Camera } from "babylonjs/Cameras/camera";
  57323. import { ISceneComponent } from "babylonjs/sceneComponent";
  57324. module "babylonjs/scene" {
  57325. interface Scene {
  57326. /** @hidden (Backing field) */
  57327. _depthRenderer: {
  57328. [id: string]: DepthRenderer;
  57329. };
  57330. /**
  57331. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  57332. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  57333. * @returns the created depth renderer
  57334. */
  57335. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  57336. /**
  57337. * Disables a depth renderer for a given camera
  57338. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  57339. */
  57340. disableDepthRenderer(camera?: Nullable<Camera>): void;
  57341. }
  57342. }
  57343. /**
  57344. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  57345. * in several rendering techniques.
  57346. */
  57347. export class DepthRendererSceneComponent implements ISceneComponent {
  57348. /**
  57349. * The component name helpfull to identify the component in the list of scene components.
  57350. */
  57351. readonly name: string;
  57352. /**
  57353. * The scene the component belongs to.
  57354. */
  57355. scene: Scene;
  57356. /**
  57357. * Creates a new instance of the component for the given scene
  57358. * @param scene Defines the scene to register the component in
  57359. */
  57360. constructor(scene: Scene);
  57361. /**
  57362. * Registers the component in a given scene
  57363. */
  57364. register(): void;
  57365. /**
  57366. * Rebuilds the elements related to this component in case of
  57367. * context lost for instance.
  57368. */
  57369. rebuild(): void;
  57370. /**
  57371. * Disposes the component and the associated ressources
  57372. */
  57373. dispose(): void;
  57374. private _gatherRenderTargets;
  57375. private _gatherActiveCameraRenderTargets;
  57376. }
  57377. }
  57378. declare module "babylonjs/Shaders/outline.fragment" {
  57379. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57380. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57381. /** @hidden */
  57382. export var outlinePixelShader: {
  57383. name: string;
  57384. shader: string;
  57385. };
  57386. }
  57387. declare module "babylonjs/Shaders/outline.vertex" {
  57388. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57389. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57390. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57391. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57392. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57393. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57394. /** @hidden */
  57395. export var outlineVertexShader: {
  57396. name: string;
  57397. shader: string;
  57398. };
  57399. }
  57400. declare module "babylonjs/Rendering/outlineRenderer" {
  57401. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57402. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  57403. import { Scene } from "babylonjs/scene";
  57404. import { ISceneComponent } from "babylonjs/sceneComponent";
  57405. import "babylonjs/Shaders/outline.fragment";
  57406. import "babylonjs/Shaders/outline.vertex";
  57407. module "babylonjs/scene" {
  57408. interface Scene {
  57409. /** @hidden */
  57410. _outlineRenderer: OutlineRenderer;
  57411. /**
  57412. * Gets the outline renderer associated with the scene
  57413. * @returns a OutlineRenderer
  57414. */
  57415. getOutlineRenderer(): OutlineRenderer;
  57416. }
  57417. }
  57418. module "babylonjs/Meshes/abstractMesh" {
  57419. interface AbstractMesh {
  57420. /** @hidden (Backing field) */
  57421. _renderOutline: boolean;
  57422. /**
  57423. * Gets or sets a boolean indicating if the outline must be rendered as well
  57424. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57425. */
  57426. renderOutline: boolean;
  57427. /** @hidden (Backing field) */
  57428. _renderOverlay: boolean;
  57429. /**
  57430. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57431. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57432. */
  57433. renderOverlay: boolean;
  57434. }
  57435. }
  57436. /**
  57437. * This class is responsible to draw bothe outline/overlay of meshes.
  57438. * It should not be used directly but through the available method on mesh.
  57439. */
  57440. export class OutlineRenderer implements ISceneComponent {
  57441. /**
  57442. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57443. */
  57444. private static _StencilReference;
  57445. /**
  57446. * The name of the component. Each component must have a unique name.
  57447. */
  57448. name: string;
  57449. /**
  57450. * The scene the component belongs to.
  57451. */
  57452. scene: Scene;
  57453. /**
  57454. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57455. */
  57456. zOffset: number;
  57457. private _engine;
  57458. private _effect;
  57459. private _cachedDefines;
  57460. private _savedDepthWrite;
  57461. /**
  57462. * Instantiates a new outline renderer. (There could be only one per scene).
  57463. * @param scene Defines the scene it belongs to
  57464. */
  57465. constructor(scene: Scene);
  57466. /**
  57467. * Register the component to one instance of a scene.
  57468. */
  57469. register(): void;
  57470. /**
  57471. * Rebuilds the elements related to this component in case of
  57472. * context lost for instance.
  57473. */
  57474. rebuild(): void;
  57475. /**
  57476. * Disposes the component and the associated ressources.
  57477. */
  57478. dispose(): void;
  57479. /**
  57480. * Renders the outline in the canvas.
  57481. * @param subMesh Defines the sumesh to render
  57482. * @param batch Defines the batch of meshes in case of instances
  57483. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57484. */
  57485. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57486. /**
  57487. * Returns whether or not the outline renderer is ready for a given submesh.
  57488. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57489. * @param subMesh Defines the submesh to check readyness for
  57490. * @param useInstances Defines wheter wee are trying to render instances or not
  57491. * @returns true if ready otherwise false
  57492. */
  57493. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57494. private _beforeRenderingMesh;
  57495. private _afterRenderingMesh;
  57496. }
  57497. }
  57498. declare module "babylonjs/Rendering/index" {
  57499. export * from "babylonjs/Rendering/boundingBoxRenderer";
  57500. export * from "babylonjs/Rendering/depthRenderer";
  57501. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  57502. export * from "babylonjs/Rendering/edgesRenderer";
  57503. export * from "babylonjs/Rendering/geometryBufferRenderer";
  57504. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  57505. export * from "babylonjs/Rendering/outlineRenderer";
  57506. export * from "babylonjs/Rendering/renderingGroup";
  57507. export * from "babylonjs/Rendering/renderingManager";
  57508. export * from "babylonjs/Rendering/utilityLayerRenderer";
  57509. }
  57510. declare module "babylonjs/Sprites/index" {
  57511. export * from "babylonjs/Sprites/sprite";
  57512. export * from "babylonjs/Sprites/spriteManager";
  57513. export * from "babylonjs/Sprites/spriteSceneComponent";
  57514. }
  57515. declare module "babylonjs/Misc/assetsManager" {
  57516. import { Scene } from "babylonjs/scene";
  57517. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57518. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57519. import { Skeleton } from "babylonjs/Bones/skeleton";
  57520. import { Observable } from "babylonjs/Misc/observable";
  57521. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57522. import { Texture } from "babylonjs/Materials/Textures/texture";
  57523. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57524. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  57525. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57526. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  57527. /**
  57528. * Defines the list of states available for a task inside a AssetsManager
  57529. */
  57530. export enum AssetTaskState {
  57531. /**
  57532. * Initialization
  57533. */
  57534. INIT = 0,
  57535. /**
  57536. * Running
  57537. */
  57538. RUNNING = 1,
  57539. /**
  57540. * Done
  57541. */
  57542. DONE = 2,
  57543. /**
  57544. * Error
  57545. */
  57546. ERROR = 3
  57547. }
  57548. /**
  57549. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57550. */
  57551. export abstract class AbstractAssetTask {
  57552. /**
  57553. * Task name
  57554. */ name: string;
  57555. /**
  57556. * Callback called when the task is successful
  57557. */
  57558. onSuccess: (task: any) => void;
  57559. /**
  57560. * Callback called when the task is not successful
  57561. */
  57562. onError: (task: any, message?: string, exception?: any) => void;
  57563. /**
  57564. * Creates a new AssetsManager
  57565. * @param name defines the name of the task
  57566. */
  57567. constructor(
  57568. /**
  57569. * Task name
  57570. */ name: string);
  57571. private _isCompleted;
  57572. private _taskState;
  57573. private _errorObject;
  57574. /**
  57575. * Get if the task is completed
  57576. */
  57577. readonly isCompleted: boolean;
  57578. /**
  57579. * Gets the current state of the task
  57580. */
  57581. readonly taskState: AssetTaskState;
  57582. /**
  57583. * Gets the current error object (if task is in error)
  57584. */
  57585. readonly errorObject: {
  57586. message?: string;
  57587. exception?: any;
  57588. };
  57589. /**
  57590. * Internal only
  57591. * @hidden
  57592. */
  57593. _setErrorObject(message?: string, exception?: any): void;
  57594. /**
  57595. * Execute the current task
  57596. * @param scene defines the scene where you want your assets to be loaded
  57597. * @param onSuccess is a callback called when the task is successfully executed
  57598. * @param onError is a callback called if an error occurs
  57599. */
  57600. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57601. /**
  57602. * Execute the current task
  57603. * @param scene defines the scene where you want your assets to be loaded
  57604. * @param onSuccess is a callback called when the task is successfully executed
  57605. * @param onError is a callback called if an error occurs
  57606. */
  57607. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57608. /**
  57609. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57610. * This can be used with failed tasks that have the reason for failure fixed.
  57611. */
  57612. reset(): void;
  57613. private onErrorCallback;
  57614. private onDoneCallback;
  57615. }
  57616. /**
  57617. * Define the interface used by progress events raised during assets loading
  57618. */
  57619. export interface IAssetsProgressEvent {
  57620. /**
  57621. * Defines the number of remaining tasks to process
  57622. */
  57623. remainingCount: number;
  57624. /**
  57625. * Defines the total number of tasks
  57626. */
  57627. totalCount: number;
  57628. /**
  57629. * Defines the task that was just processed
  57630. */
  57631. task: AbstractAssetTask;
  57632. }
  57633. /**
  57634. * Class used to share progress information about assets loading
  57635. */
  57636. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57637. /**
  57638. * Defines the number of remaining tasks to process
  57639. */
  57640. remainingCount: number;
  57641. /**
  57642. * Defines the total number of tasks
  57643. */
  57644. totalCount: number;
  57645. /**
  57646. * Defines the task that was just processed
  57647. */
  57648. task: AbstractAssetTask;
  57649. /**
  57650. * Creates a AssetsProgressEvent
  57651. * @param remainingCount defines the number of remaining tasks to process
  57652. * @param totalCount defines the total number of tasks
  57653. * @param task defines the task that was just processed
  57654. */
  57655. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57656. }
  57657. /**
  57658. * Define a task used by AssetsManager to load meshes
  57659. */
  57660. export class MeshAssetTask extends AbstractAssetTask {
  57661. /**
  57662. * Defines the name of the task
  57663. */
  57664. name: string;
  57665. /**
  57666. * Defines the list of mesh's names you want to load
  57667. */
  57668. meshesNames: any;
  57669. /**
  57670. * Defines the root url to use as a base to load your meshes and associated resources
  57671. */
  57672. rootUrl: string;
  57673. /**
  57674. * Defines the filename of the scene to load from
  57675. */
  57676. sceneFilename: string;
  57677. /**
  57678. * Gets the list of loaded meshes
  57679. */
  57680. loadedMeshes: Array<AbstractMesh>;
  57681. /**
  57682. * Gets the list of loaded particle systems
  57683. */
  57684. loadedParticleSystems: Array<IParticleSystem>;
  57685. /**
  57686. * Gets the list of loaded skeletons
  57687. */
  57688. loadedSkeletons: Array<Skeleton>;
  57689. /**
  57690. * Gets the list of loaded animation groups
  57691. */
  57692. loadedAnimationGroups: Array<AnimationGroup>;
  57693. /**
  57694. * Callback called when the task is successful
  57695. */
  57696. onSuccess: (task: MeshAssetTask) => void;
  57697. /**
  57698. * Callback called when the task is successful
  57699. */
  57700. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57701. /**
  57702. * Creates a new MeshAssetTask
  57703. * @param name defines the name of the task
  57704. * @param meshesNames defines the list of mesh's names you want to load
  57705. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57706. * @param sceneFilename defines the filename of the scene to load from
  57707. */
  57708. constructor(
  57709. /**
  57710. * Defines the name of the task
  57711. */
  57712. name: string,
  57713. /**
  57714. * Defines the list of mesh's names you want to load
  57715. */
  57716. meshesNames: any,
  57717. /**
  57718. * Defines the root url to use as a base to load your meshes and associated resources
  57719. */
  57720. rootUrl: string,
  57721. /**
  57722. * Defines the filename of the scene to load from
  57723. */
  57724. sceneFilename: string);
  57725. /**
  57726. * Execute the current task
  57727. * @param scene defines the scene where you want your assets to be loaded
  57728. * @param onSuccess is a callback called when the task is successfully executed
  57729. * @param onError is a callback called if an error occurs
  57730. */
  57731. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57732. }
  57733. /**
  57734. * Define a task used by AssetsManager to load text content
  57735. */
  57736. export class TextFileAssetTask extends AbstractAssetTask {
  57737. /**
  57738. * Defines the name of the task
  57739. */
  57740. name: string;
  57741. /**
  57742. * Defines the location of the file to load
  57743. */
  57744. url: string;
  57745. /**
  57746. * Gets the loaded text string
  57747. */
  57748. text: string;
  57749. /**
  57750. * Callback called when the task is successful
  57751. */
  57752. onSuccess: (task: TextFileAssetTask) => void;
  57753. /**
  57754. * Callback called when the task is successful
  57755. */
  57756. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57757. /**
  57758. * Creates a new TextFileAssetTask object
  57759. * @param name defines the name of the task
  57760. * @param url defines the location of the file to load
  57761. */
  57762. constructor(
  57763. /**
  57764. * Defines the name of the task
  57765. */
  57766. name: string,
  57767. /**
  57768. * Defines the location of the file to load
  57769. */
  57770. url: string);
  57771. /**
  57772. * Execute the current task
  57773. * @param scene defines the scene where you want your assets to be loaded
  57774. * @param onSuccess is a callback called when the task is successfully executed
  57775. * @param onError is a callback called if an error occurs
  57776. */
  57777. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57778. }
  57779. /**
  57780. * Define a task used by AssetsManager to load binary data
  57781. */
  57782. export class BinaryFileAssetTask extends AbstractAssetTask {
  57783. /**
  57784. * Defines the name of the task
  57785. */
  57786. name: string;
  57787. /**
  57788. * Defines the location of the file to load
  57789. */
  57790. url: string;
  57791. /**
  57792. * Gets the lodaded data (as an array buffer)
  57793. */
  57794. data: ArrayBuffer;
  57795. /**
  57796. * Callback called when the task is successful
  57797. */
  57798. onSuccess: (task: BinaryFileAssetTask) => void;
  57799. /**
  57800. * Callback called when the task is successful
  57801. */
  57802. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  57803. /**
  57804. * Creates a new BinaryFileAssetTask object
  57805. * @param name defines the name of the new task
  57806. * @param url defines the location of the file to load
  57807. */
  57808. constructor(
  57809. /**
  57810. * Defines the name of the task
  57811. */
  57812. name: string,
  57813. /**
  57814. * Defines the location of the file to load
  57815. */
  57816. url: string);
  57817. /**
  57818. * Execute the current task
  57819. * @param scene defines the scene where you want your assets to be loaded
  57820. * @param onSuccess is a callback called when the task is successfully executed
  57821. * @param onError is a callback called if an error occurs
  57822. */
  57823. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57824. }
  57825. /**
  57826. * Define a task used by AssetsManager to load images
  57827. */
  57828. export class ImageAssetTask extends AbstractAssetTask {
  57829. /**
  57830. * Defines the name of the task
  57831. */
  57832. name: string;
  57833. /**
  57834. * Defines the location of the image to load
  57835. */
  57836. url: string;
  57837. /**
  57838. * Gets the loaded images
  57839. */
  57840. image: HTMLImageElement;
  57841. /**
  57842. * Callback called when the task is successful
  57843. */
  57844. onSuccess: (task: ImageAssetTask) => void;
  57845. /**
  57846. * Callback called when the task is successful
  57847. */
  57848. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  57849. /**
  57850. * Creates a new ImageAssetTask
  57851. * @param name defines the name of the task
  57852. * @param url defines the location of the image to load
  57853. */
  57854. constructor(
  57855. /**
  57856. * Defines the name of the task
  57857. */
  57858. name: string,
  57859. /**
  57860. * Defines the location of the image to load
  57861. */
  57862. url: string);
  57863. /**
  57864. * Execute the current task
  57865. * @param scene defines the scene where you want your assets to be loaded
  57866. * @param onSuccess is a callback called when the task is successfully executed
  57867. * @param onError is a callback called if an error occurs
  57868. */
  57869. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57870. }
  57871. /**
  57872. * Defines the interface used by texture loading tasks
  57873. */
  57874. export interface ITextureAssetTask<TEX extends BaseTexture> {
  57875. /**
  57876. * Gets the loaded texture
  57877. */
  57878. texture: TEX;
  57879. }
  57880. /**
  57881. * Define a task used by AssetsManager to load 2D textures
  57882. */
  57883. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  57884. /**
  57885. * Defines the name of the task
  57886. */
  57887. name: string;
  57888. /**
  57889. * Defines the location of the file to load
  57890. */
  57891. url: string;
  57892. /**
  57893. * Defines if mipmap should not be generated (default is false)
  57894. */
  57895. noMipmap?: boolean | undefined;
  57896. /**
  57897. * Defines if texture must be inverted on Y axis (default is false)
  57898. */
  57899. invertY?: boolean | undefined;
  57900. /**
  57901. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57902. */
  57903. samplingMode: number;
  57904. /**
  57905. * Gets the loaded texture
  57906. */
  57907. texture: Texture;
  57908. /**
  57909. * Callback called when the task is successful
  57910. */
  57911. onSuccess: (task: TextureAssetTask) => void;
  57912. /**
  57913. * Callback called when the task is successful
  57914. */
  57915. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  57916. /**
  57917. * Creates a new TextureAssetTask object
  57918. * @param name defines the name of the task
  57919. * @param url defines the location of the file to load
  57920. * @param noMipmap defines if mipmap should not be generated (default is false)
  57921. * @param invertY defines if texture must be inverted on Y axis (default is false)
  57922. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57923. */
  57924. constructor(
  57925. /**
  57926. * Defines the name of the task
  57927. */
  57928. name: string,
  57929. /**
  57930. * Defines the location of the file to load
  57931. */
  57932. url: string,
  57933. /**
  57934. * Defines if mipmap should not be generated (default is false)
  57935. */
  57936. noMipmap?: boolean | undefined,
  57937. /**
  57938. * Defines if texture must be inverted on Y axis (default is false)
  57939. */
  57940. invertY?: boolean | undefined,
  57941. /**
  57942. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57943. */
  57944. samplingMode?: number);
  57945. /**
  57946. * Execute the current task
  57947. * @param scene defines the scene where you want your assets to be loaded
  57948. * @param onSuccess is a callback called when the task is successfully executed
  57949. * @param onError is a callback called if an error occurs
  57950. */
  57951. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57952. }
  57953. /**
  57954. * Define a task used by AssetsManager to load cube textures
  57955. */
  57956. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  57957. /**
  57958. * Defines the name of the task
  57959. */
  57960. name: string;
  57961. /**
  57962. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57963. */
  57964. url: string;
  57965. /**
  57966. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57967. */
  57968. extensions?: string[] | undefined;
  57969. /**
  57970. * Defines if mipmaps should not be generated (default is false)
  57971. */
  57972. noMipmap?: boolean | undefined;
  57973. /**
  57974. * Defines the explicit list of files (undefined by default)
  57975. */
  57976. files?: string[] | undefined;
  57977. /**
  57978. * Gets the loaded texture
  57979. */
  57980. texture: CubeTexture;
  57981. /**
  57982. * Callback called when the task is successful
  57983. */
  57984. onSuccess: (task: CubeTextureAssetTask) => void;
  57985. /**
  57986. * Callback called when the task is successful
  57987. */
  57988. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  57989. /**
  57990. * Creates a new CubeTextureAssetTask
  57991. * @param name defines the name of the task
  57992. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57993. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57994. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57995. * @param files defines the explicit list of files (undefined by default)
  57996. */
  57997. constructor(
  57998. /**
  57999. * Defines the name of the task
  58000. */
  58001. name: string,
  58002. /**
  58003. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58004. */
  58005. url: string,
  58006. /**
  58007. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58008. */
  58009. extensions?: string[] | undefined,
  58010. /**
  58011. * Defines if mipmaps should not be generated (default is false)
  58012. */
  58013. noMipmap?: boolean | undefined,
  58014. /**
  58015. * Defines the explicit list of files (undefined by default)
  58016. */
  58017. files?: string[] | undefined);
  58018. /**
  58019. * Execute the current task
  58020. * @param scene defines the scene where you want your assets to be loaded
  58021. * @param onSuccess is a callback called when the task is successfully executed
  58022. * @param onError is a callback called if an error occurs
  58023. */
  58024. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58025. }
  58026. /**
  58027. * Define a task used by AssetsManager to load HDR cube textures
  58028. */
  58029. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  58030. /**
  58031. * Defines the name of the task
  58032. */
  58033. name: string;
  58034. /**
  58035. * Defines the location of the file to load
  58036. */
  58037. url: string;
  58038. /**
  58039. * Defines the desired size (the more it increases the longer the generation will be)
  58040. */
  58041. size: number;
  58042. /**
  58043. * Defines if mipmaps should not be generated (default is false)
  58044. */
  58045. noMipmap: boolean;
  58046. /**
  58047. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58048. */
  58049. generateHarmonics: boolean;
  58050. /**
  58051. * 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)
  58052. */
  58053. gammaSpace: boolean;
  58054. /**
  58055. * Internal Use Only
  58056. */
  58057. reserved: boolean;
  58058. /**
  58059. * Gets the loaded texture
  58060. */
  58061. texture: HDRCubeTexture;
  58062. /**
  58063. * Callback called when the task is successful
  58064. */
  58065. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  58066. /**
  58067. * Callback called when the task is successful
  58068. */
  58069. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  58070. /**
  58071. * Creates a new HDRCubeTextureAssetTask object
  58072. * @param name defines the name of the task
  58073. * @param url defines the location of the file to load
  58074. * @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.
  58075. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58076. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58077. * @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)
  58078. * @param reserved Internal use only
  58079. */
  58080. constructor(
  58081. /**
  58082. * Defines the name of the task
  58083. */
  58084. name: string,
  58085. /**
  58086. * Defines the location of the file to load
  58087. */
  58088. url: string,
  58089. /**
  58090. * Defines the desired size (the more it increases the longer the generation will be)
  58091. */
  58092. size: number,
  58093. /**
  58094. * Defines if mipmaps should not be generated (default is false)
  58095. */
  58096. noMipmap?: boolean,
  58097. /**
  58098. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58099. */
  58100. generateHarmonics?: boolean,
  58101. /**
  58102. * 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)
  58103. */
  58104. gammaSpace?: boolean,
  58105. /**
  58106. * Internal Use Only
  58107. */
  58108. reserved?: boolean);
  58109. /**
  58110. * Execute the current task
  58111. * @param scene defines the scene where you want your assets to be loaded
  58112. * @param onSuccess is a callback called when the task is successfully executed
  58113. * @param onError is a callback called if an error occurs
  58114. */
  58115. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58116. }
  58117. /**
  58118. * Define a task used by AssetsManager to load Equirectangular cube textures
  58119. */
  58120. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  58121. /**
  58122. * Defines the name of the task
  58123. */
  58124. name: string;
  58125. /**
  58126. * Defines the location of the file to load
  58127. */
  58128. url: string;
  58129. /**
  58130. * Defines the desired size (the more it increases the longer the generation will be)
  58131. */
  58132. size: number;
  58133. /**
  58134. * Defines if mipmaps should not be generated (default is false)
  58135. */
  58136. noMipmap: boolean;
  58137. /**
  58138. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58139. * but the standard material would require them in Gamma space) (default is true)
  58140. */
  58141. gammaSpace: boolean;
  58142. /**
  58143. * Gets the loaded texture
  58144. */
  58145. texture: EquiRectangularCubeTexture;
  58146. /**
  58147. * Callback called when the task is successful
  58148. */
  58149. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  58150. /**
  58151. * Callback called when the task is successful
  58152. */
  58153. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  58154. /**
  58155. * Creates a new EquiRectangularCubeTextureAssetTask object
  58156. * @param name defines the name of the task
  58157. * @param url defines the location of the file to load
  58158. * @param size defines the desired size (the more it increases the longer the generation will be)
  58159. * If the size is omitted this implies you are using a preprocessed cubemap.
  58160. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58161. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  58162. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  58163. * (default is true)
  58164. */
  58165. constructor(
  58166. /**
  58167. * Defines the name of the task
  58168. */
  58169. name: string,
  58170. /**
  58171. * Defines the location of the file to load
  58172. */
  58173. url: string,
  58174. /**
  58175. * Defines the desired size (the more it increases the longer the generation will be)
  58176. */
  58177. size: number,
  58178. /**
  58179. * Defines if mipmaps should not be generated (default is false)
  58180. */
  58181. noMipmap?: boolean,
  58182. /**
  58183. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58184. * but the standard material would require them in Gamma space) (default is true)
  58185. */
  58186. gammaSpace?: boolean);
  58187. /**
  58188. * Execute the current task
  58189. * @param scene defines the scene where you want your assets to be loaded
  58190. * @param onSuccess is a callback called when the task is successfully executed
  58191. * @param onError is a callback called if an error occurs
  58192. */
  58193. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58194. }
  58195. /**
  58196. * This class can be used to easily import assets into a scene
  58197. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  58198. */
  58199. export class AssetsManager {
  58200. private _scene;
  58201. private _isLoading;
  58202. protected _tasks: AbstractAssetTask[];
  58203. protected _waitingTasksCount: number;
  58204. protected _totalTasksCount: number;
  58205. /**
  58206. * Callback called when all tasks are processed
  58207. */
  58208. onFinish: (tasks: AbstractAssetTask[]) => void;
  58209. /**
  58210. * Callback called when a task is successful
  58211. */
  58212. onTaskSuccess: (task: AbstractAssetTask) => void;
  58213. /**
  58214. * Callback called when a task had an error
  58215. */
  58216. onTaskError: (task: AbstractAssetTask) => void;
  58217. /**
  58218. * Callback called when a task is done (whatever the result is)
  58219. */
  58220. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  58221. /**
  58222. * Observable called when all tasks are processed
  58223. */
  58224. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  58225. /**
  58226. * Observable called when a task had an error
  58227. */
  58228. onTaskErrorObservable: Observable<AbstractAssetTask>;
  58229. /**
  58230. * Observable called when all tasks were executed
  58231. */
  58232. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  58233. /**
  58234. * Observable called when a task is done (whatever the result is)
  58235. */
  58236. onProgressObservable: Observable<IAssetsProgressEvent>;
  58237. /**
  58238. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  58239. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  58240. */
  58241. useDefaultLoadingScreen: boolean;
  58242. /**
  58243. * Creates a new AssetsManager
  58244. * @param scene defines the scene to work on
  58245. */
  58246. constructor(scene: Scene);
  58247. /**
  58248. * Add a MeshAssetTask to the list of active tasks
  58249. * @param taskName defines the name of the new task
  58250. * @param meshesNames defines the name of meshes to load
  58251. * @param rootUrl defines the root url to use to locate files
  58252. * @param sceneFilename defines the filename of the scene file
  58253. * @returns a new MeshAssetTask object
  58254. */
  58255. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  58256. /**
  58257. * Add a TextFileAssetTask to the list of active tasks
  58258. * @param taskName defines the name of the new task
  58259. * @param url defines the url of the file to load
  58260. * @returns a new TextFileAssetTask object
  58261. */
  58262. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  58263. /**
  58264. * Add a BinaryFileAssetTask to the list of active tasks
  58265. * @param taskName defines the name of the new task
  58266. * @param url defines the url of the file to load
  58267. * @returns a new BinaryFileAssetTask object
  58268. */
  58269. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  58270. /**
  58271. * Add a ImageAssetTask to the list of active tasks
  58272. * @param taskName defines the name of the new task
  58273. * @param url defines the url of the file to load
  58274. * @returns a new ImageAssetTask object
  58275. */
  58276. addImageTask(taskName: string, url: string): ImageAssetTask;
  58277. /**
  58278. * Add a TextureAssetTask to the list of active tasks
  58279. * @param taskName defines the name of the new task
  58280. * @param url defines the url of the file to load
  58281. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58282. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  58283. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58284. * @returns a new TextureAssetTask object
  58285. */
  58286. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  58287. /**
  58288. * Add a CubeTextureAssetTask to the list of active tasks
  58289. * @param taskName defines the name of the new task
  58290. * @param url defines the url of the file to load
  58291. * @param extensions defines the extension to use to load the cube map (can be null)
  58292. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58293. * @param files defines the list of files to load (can be null)
  58294. * @returns a new CubeTextureAssetTask object
  58295. */
  58296. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  58297. /**
  58298. *
  58299. * Add a HDRCubeTextureAssetTask to the list of active tasks
  58300. * @param taskName defines the name of the new task
  58301. * @param url defines the url of the file to load
  58302. * @param size defines the size you want for the cubemap (can be null)
  58303. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58304. * @param generateHarmonics defines if you want to automatically generate (true by default)
  58305. * @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)
  58306. * @param reserved Internal use only
  58307. * @returns a new HDRCubeTextureAssetTask object
  58308. */
  58309. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  58310. /**
  58311. *
  58312. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  58313. * @param taskName defines the name of the new task
  58314. * @param url defines the url of the file to load
  58315. * @param size defines the size you want for the cubemap (can be null)
  58316. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58317. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58318. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58319. * @returns a new EquiRectangularCubeTextureAssetTask object
  58320. */
  58321. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  58322. /**
  58323. * Remove a task from the assets manager.
  58324. * @param task the task to remove
  58325. */
  58326. removeTask(task: AbstractAssetTask): void;
  58327. private _decreaseWaitingTasksCount;
  58328. private _runTask;
  58329. /**
  58330. * Reset the AssetsManager and remove all tasks
  58331. * @return the current instance of the AssetsManager
  58332. */
  58333. reset(): AssetsManager;
  58334. /**
  58335. * Start the loading process
  58336. * @return the current instance of the AssetsManager
  58337. */
  58338. load(): AssetsManager;
  58339. /**
  58340. * Start the loading process as an async operation
  58341. * @return a promise returning the list of failed tasks
  58342. */
  58343. loadAsync(): Promise<void>;
  58344. }
  58345. }
  58346. declare module "babylonjs/Misc/deferred" {
  58347. /**
  58348. * Wrapper class for promise with external resolve and reject.
  58349. */
  58350. export class Deferred<T> {
  58351. /**
  58352. * The promise associated with this deferred object.
  58353. */
  58354. readonly promise: Promise<T>;
  58355. private _resolve;
  58356. private _reject;
  58357. /**
  58358. * The resolve method of the promise associated with this deferred object.
  58359. */
  58360. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  58361. /**
  58362. * The reject method of the promise associated with this deferred object.
  58363. */
  58364. readonly reject: (reason?: any) => void;
  58365. /**
  58366. * Constructor for this deferred object.
  58367. */
  58368. constructor();
  58369. }
  58370. }
  58371. declare module "babylonjs/Misc/meshExploder" {
  58372. import { Mesh } from "babylonjs/Meshes/mesh";
  58373. /**
  58374. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58375. */
  58376. export class MeshExploder {
  58377. private _centerMesh;
  58378. private _meshes;
  58379. private _meshesOrigins;
  58380. private _toCenterVectors;
  58381. private _scaledDirection;
  58382. private _newPosition;
  58383. private _centerPosition;
  58384. /**
  58385. * Explodes meshes from a center mesh.
  58386. * @param meshes The meshes to explode.
  58387. * @param centerMesh The mesh to be center of explosion.
  58388. */
  58389. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58390. private _setCenterMesh;
  58391. /**
  58392. * Get class name
  58393. * @returns "MeshExploder"
  58394. */
  58395. getClassName(): string;
  58396. /**
  58397. * "Exploded meshes"
  58398. * @returns Array of meshes with the centerMesh at index 0.
  58399. */
  58400. getMeshes(): Array<Mesh>;
  58401. /**
  58402. * Explodes meshes giving a specific direction
  58403. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58404. */
  58405. explode(direction?: number): void;
  58406. }
  58407. }
  58408. declare module "babylonjs/Misc/filesInput" {
  58409. import { Engine } from "babylonjs/Engines/engine";
  58410. import { Scene } from "babylonjs/scene";
  58411. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  58412. /**
  58413. * Class used to help managing file picking and drag'n'drop
  58414. */
  58415. export class FilesInput {
  58416. /**
  58417. * List of files ready to be loaded
  58418. */
  58419. static readonly FilesToLoad: {
  58420. [key: string]: File;
  58421. };
  58422. /**
  58423. * Callback called when a file is processed
  58424. */
  58425. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58426. private _engine;
  58427. private _currentScene;
  58428. private _sceneLoadedCallback;
  58429. private _progressCallback;
  58430. private _additionalRenderLoopLogicCallback;
  58431. private _textureLoadingCallback;
  58432. private _startingProcessingFilesCallback;
  58433. private _onReloadCallback;
  58434. private _errorCallback;
  58435. private _elementToMonitor;
  58436. private _sceneFileToLoad;
  58437. private _filesToLoad;
  58438. /**
  58439. * Creates a new FilesInput
  58440. * @param engine defines the rendering engine
  58441. * @param scene defines the hosting scene
  58442. * @param sceneLoadedCallback callback called when scene is loaded
  58443. * @param progressCallback callback called to track progress
  58444. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58445. * @param textureLoadingCallback callback called when a texture is loading
  58446. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58447. * @param onReloadCallback callback called when a reload is requested
  58448. * @param errorCallback callback call if an error occurs
  58449. */
  58450. 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);
  58451. private _dragEnterHandler;
  58452. private _dragOverHandler;
  58453. private _dropHandler;
  58454. /**
  58455. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58456. * @param elementToMonitor defines the DOM element to track
  58457. */
  58458. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58459. /**
  58460. * Release all associated resources
  58461. */
  58462. dispose(): void;
  58463. private renderFunction;
  58464. private drag;
  58465. private drop;
  58466. private _traverseFolder;
  58467. private _processFiles;
  58468. /**
  58469. * Load files from a drop event
  58470. * @param event defines the drop event to use as source
  58471. */
  58472. loadFiles(event: any): void;
  58473. private _processReload;
  58474. /**
  58475. * Reload the current scene from the loaded files
  58476. */
  58477. reload(): void;
  58478. }
  58479. }
  58480. declare module "babylonjs/Misc/HighDynamicRange/index" {
  58481. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  58482. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  58483. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  58484. }
  58485. declare module "babylonjs/Misc/sceneOptimizer" {
  58486. import { Scene, IDisposable } from "babylonjs/scene";
  58487. import { Observable } from "babylonjs/Misc/observable";
  58488. /**
  58489. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58490. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58491. */
  58492. export class SceneOptimization {
  58493. /**
  58494. * Defines the priority of this optimization (0 by default which means first in the list)
  58495. */
  58496. priority: number;
  58497. /**
  58498. * Gets a string describing the action executed by the current optimization
  58499. * @returns description string
  58500. */
  58501. getDescription(): string;
  58502. /**
  58503. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58504. * @param scene defines the current scene where to apply this optimization
  58505. * @param optimizer defines the current optimizer
  58506. * @returns true if everything that can be done was applied
  58507. */
  58508. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58509. /**
  58510. * Creates the SceneOptimization object
  58511. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58512. * @param desc defines the description associated with the optimization
  58513. */
  58514. constructor(
  58515. /**
  58516. * Defines the priority of this optimization (0 by default which means first in the list)
  58517. */
  58518. priority?: number);
  58519. }
  58520. /**
  58521. * Defines an optimization used to reduce the size of render target textures
  58522. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58523. */
  58524. export class TextureOptimization extends SceneOptimization {
  58525. /**
  58526. * Defines the priority of this optimization (0 by default which means first in the list)
  58527. */
  58528. priority: number;
  58529. /**
  58530. * 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
  58531. */
  58532. maximumSize: number;
  58533. /**
  58534. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58535. */
  58536. step: number;
  58537. /**
  58538. * Gets a string describing the action executed by the current optimization
  58539. * @returns description string
  58540. */
  58541. getDescription(): string;
  58542. /**
  58543. * Creates the TextureOptimization object
  58544. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58545. * @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
  58546. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58547. */
  58548. constructor(
  58549. /**
  58550. * Defines the priority of this optimization (0 by default which means first in the list)
  58551. */
  58552. priority?: number,
  58553. /**
  58554. * 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
  58555. */
  58556. maximumSize?: number,
  58557. /**
  58558. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58559. */
  58560. step?: number);
  58561. /**
  58562. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58563. * @param scene defines the current scene where to apply this optimization
  58564. * @param optimizer defines the current optimizer
  58565. * @returns true if everything that can be done was applied
  58566. */
  58567. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58568. }
  58569. /**
  58570. * Defines an optimization used to increase or decrease the rendering resolution
  58571. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58572. */
  58573. export class HardwareScalingOptimization extends SceneOptimization {
  58574. /**
  58575. * Defines the priority of this optimization (0 by default which means first in the list)
  58576. */
  58577. priority: number;
  58578. /**
  58579. * Defines the maximum scale to use (2 by default)
  58580. */
  58581. maximumScale: number;
  58582. /**
  58583. * Defines the step to use between two passes (0.5 by default)
  58584. */
  58585. step: number;
  58586. private _currentScale;
  58587. private _directionOffset;
  58588. /**
  58589. * Gets a string describing the action executed by the current optimization
  58590. * @return description string
  58591. */
  58592. getDescription(): string;
  58593. /**
  58594. * Creates the HardwareScalingOptimization object
  58595. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58596. * @param maximumScale defines the maximum scale to use (2 by default)
  58597. * @param step defines the step to use between two passes (0.5 by default)
  58598. */
  58599. constructor(
  58600. /**
  58601. * Defines the priority of this optimization (0 by default which means first in the list)
  58602. */
  58603. priority?: number,
  58604. /**
  58605. * Defines the maximum scale to use (2 by default)
  58606. */
  58607. maximumScale?: number,
  58608. /**
  58609. * Defines the step to use between two passes (0.5 by default)
  58610. */
  58611. step?: number);
  58612. /**
  58613. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58614. * @param scene defines the current scene where to apply this optimization
  58615. * @param optimizer defines the current optimizer
  58616. * @returns true if everything that can be done was applied
  58617. */
  58618. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58619. }
  58620. /**
  58621. * Defines an optimization used to remove shadows
  58622. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58623. */
  58624. export class ShadowsOptimization extends SceneOptimization {
  58625. /**
  58626. * Gets a string describing the action executed by the current optimization
  58627. * @return description string
  58628. */
  58629. getDescription(): string;
  58630. /**
  58631. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58632. * @param scene defines the current scene where to apply this optimization
  58633. * @param optimizer defines the current optimizer
  58634. * @returns true if everything that can be done was applied
  58635. */
  58636. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58637. }
  58638. /**
  58639. * Defines an optimization used to turn post-processes off
  58640. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58641. */
  58642. export class PostProcessesOptimization extends SceneOptimization {
  58643. /**
  58644. * Gets a string describing the action executed by the current optimization
  58645. * @return description string
  58646. */
  58647. getDescription(): string;
  58648. /**
  58649. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58650. * @param scene defines the current scene where to apply this optimization
  58651. * @param optimizer defines the current optimizer
  58652. * @returns true if everything that can be done was applied
  58653. */
  58654. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58655. }
  58656. /**
  58657. * Defines an optimization used to turn lens flares off
  58658. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58659. */
  58660. export class LensFlaresOptimization extends SceneOptimization {
  58661. /**
  58662. * Gets a string describing the action executed by the current optimization
  58663. * @return description string
  58664. */
  58665. getDescription(): string;
  58666. /**
  58667. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58668. * @param scene defines the current scene where to apply this optimization
  58669. * @param optimizer defines the current optimizer
  58670. * @returns true if everything that can be done was applied
  58671. */
  58672. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58673. }
  58674. /**
  58675. * Defines an optimization based on user defined callback.
  58676. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58677. */
  58678. export class CustomOptimization extends SceneOptimization {
  58679. /**
  58680. * Callback called to apply the custom optimization.
  58681. */
  58682. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58683. /**
  58684. * Callback called to get custom description
  58685. */
  58686. onGetDescription: () => string;
  58687. /**
  58688. * Gets a string describing the action executed by the current optimization
  58689. * @returns description string
  58690. */
  58691. getDescription(): string;
  58692. /**
  58693. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58694. * @param scene defines the current scene where to apply this optimization
  58695. * @param optimizer defines the current optimizer
  58696. * @returns true if everything that can be done was applied
  58697. */
  58698. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58699. }
  58700. /**
  58701. * Defines an optimization used to turn particles off
  58702. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58703. */
  58704. export class ParticlesOptimization extends SceneOptimization {
  58705. /**
  58706. * Gets a string describing the action executed by the current optimization
  58707. * @return description string
  58708. */
  58709. getDescription(): string;
  58710. /**
  58711. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58712. * @param scene defines the current scene where to apply this optimization
  58713. * @param optimizer defines the current optimizer
  58714. * @returns true if everything that can be done was applied
  58715. */
  58716. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58717. }
  58718. /**
  58719. * Defines an optimization used to turn render targets off
  58720. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58721. */
  58722. export class RenderTargetsOptimization extends SceneOptimization {
  58723. /**
  58724. * Gets a string describing the action executed by the current optimization
  58725. * @return description string
  58726. */
  58727. getDescription(): string;
  58728. /**
  58729. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58730. * @param scene defines the current scene where to apply this optimization
  58731. * @param optimizer defines the current optimizer
  58732. * @returns true if everything that can be done was applied
  58733. */
  58734. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58735. }
  58736. /**
  58737. * Defines an optimization used to merge meshes with compatible materials
  58738. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58739. */
  58740. export class MergeMeshesOptimization extends SceneOptimization {
  58741. private static _UpdateSelectionTree;
  58742. /**
  58743. * Gets or sets a boolean which defines if optimization octree has to be updated
  58744. */
  58745. /**
  58746. * Gets or sets a boolean which defines if optimization octree has to be updated
  58747. */
  58748. static UpdateSelectionTree: boolean;
  58749. /**
  58750. * Gets a string describing the action executed by the current optimization
  58751. * @return description string
  58752. */
  58753. getDescription(): string;
  58754. private _canBeMerged;
  58755. /**
  58756. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58757. * @param scene defines the current scene where to apply this optimization
  58758. * @param optimizer defines the current optimizer
  58759. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58760. * @returns true if everything that can be done was applied
  58761. */
  58762. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58763. }
  58764. /**
  58765. * Defines a list of options used by SceneOptimizer
  58766. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58767. */
  58768. export class SceneOptimizerOptions {
  58769. /**
  58770. * Defines the target frame rate to reach (60 by default)
  58771. */
  58772. targetFrameRate: number;
  58773. /**
  58774. * Defines the interval between two checkes (2000ms by default)
  58775. */
  58776. trackerDuration: number;
  58777. /**
  58778. * Gets the list of optimizations to apply
  58779. */
  58780. optimizations: SceneOptimization[];
  58781. /**
  58782. * Creates a new list of options used by SceneOptimizer
  58783. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58784. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58785. */
  58786. constructor(
  58787. /**
  58788. * Defines the target frame rate to reach (60 by default)
  58789. */
  58790. targetFrameRate?: number,
  58791. /**
  58792. * Defines the interval between two checkes (2000ms by default)
  58793. */
  58794. trackerDuration?: number);
  58795. /**
  58796. * Add a new optimization
  58797. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  58798. * @returns the current SceneOptimizerOptions
  58799. */
  58800. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  58801. /**
  58802. * Add a new custom optimization
  58803. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  58804. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  58805. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58806. * @returns the current SceneOptimizerOptions
  58807. */
  58808. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  58809. /**
  58810. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  58811. * @param targetFrameRate defines the target frame rate (60 by default)
  58812. * @returns a SceneOptimizerOptions object
  58813. */
  58814. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58815. /**
  58816. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  58817. * @param targetFrameRate defines the target frame rate (60 by default)
  58818. * @returns a SceneOptimizerOptions object
  58819. */
  58820. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58821. /**
  58822. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  58823. * @param targetFrameRate defines the target frame rate (60 by default)
  58824. * @returns a SceneOptimizerOptions object
  58825. */
  58826. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58827. }
  58828. /**
  58829. * Class used to run optimizations in order to reach a target frame rate
  58830. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58831. */
  58832. export class SceneOptimizer implements IDisposable {
  58833. private _isRunning;
  58834. private _options;
  58835. private _scene;
  58836. private _currentPriorityLevel;
  58837. private _targetFrameRate;
  58838. private _trackerDuration;
  58839. private _currentFrameRate;
  58840. private _sceneDisposeObserver;
  58841. private _improvementMode;
  58842. /**
  58843. * Defines an observable called when the optimizer reaches the target frame rate
  58844. */
  58845. onSuccessObservable: Observable<SceneOptimizer>;
  58846. /**
  58847. * Defines an observable called when the optimizer enables an optimization
  58848. */
  58849. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  58850. /**
  58851. * Defines an observable called when the optimizer is not able to reach the target frame rate
  58852. */
  58853. onFailureObservable: Observable<SceneOptimizer>;
  58854. /**
  58855. * Gets a boolean indicating if the optimizer is in improvement mode
  58856. */
  58857. readonly isInImprovementMode: boolean;
  58858. /**
  58859. * Gets the current priority level (0 at start)
  58860. */
  58861. readonly currentPriorityLevel: number;
  58862. /**
  58863. * Gets the current frame rate checked by the SceneOptimizer
  58864. */
  58865. readonly currentFrameRate: number;
  58866. /**
  58867. * Gets or sets the current target frame rate (60 by default)
  58868. */
  58869. /**
  58870. * Gets or sets the current target frame rate (60 by default)
  58871. */
  58872. targetFrameRate: number;
  58873. /**
  58874. * Gets or sets the current interval between two checks (every 2000ms by default)
  58875. */
  58876. /**
  58877. * Gets or sets the current interval between two checks (every 2000ms by default)
  58878. */
  58879. trackerDuration: number;
  58880. /**
  58881. * Gets the list of active optimizations
  58882. */
  58883. readonly optimizations: SceneOptimization[];
  58884. /**
  58885. * Creates a new SceneOptimizer
  58886. * @param scene defines the scene to work on
  58887. * @param options defines the options to use with the SceneOptimizer
  58888. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  58889. * @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)
  58890. */
  58891. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  58892. /**
  58893. * Stops the current optimizer
  58894. */
  58895. stop(): void;
  58896. /**
  58897. * Reset the optimizer to initial step (current priority level = 0)
  58898. */
  58899. reset(): void;
  58900. /**
  58901. * Start the optimizer. By default it will try to reach a specific framerate
  58902. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  58903. */
  58904. start(): void;
  58905. private _checkCurrentState;
  58906. /**
  58907. * Release all resources
  58908. */
  58909. dispose(): void;
  58910. /**
  58911. * Helper function to create a SceneOptimizer with one single line of code
  58912. * @param scene defines the scene to work on
  58913. * @param options defines the options to use with the SceneOptimizer
  58914. * @param onSuccess defines a callback to call on success
  58915. * @param onFailure defines a callback to call on failure
  58916. * @returns the new SceneOptimizer object
  58917. */
  58918. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  58919. }
  58920. }
  58921. declare module "babylonjs/Misc/sceneSerializer" {
  58922. import { Scene } from "babylonjs/scene";
  58923. /**
  58924. * Class used to serialize a scene into a string
  58925. */
  58926. export class SceneSerializer {
  58927. /**
  58928. * Clear cache used by a previous serialization
  58929. */
  58930. static ClearCache(): void;
  58931. /**
  58932. * Serialize a scene into a JSON compatible object
  58933. * @param scene defines the scene to serialize
  58934. * @returns a JSON compatible object
  58935. */
  58936. static Serialize(scene: Scene): any;
  58937. /**
  58938. * Serialize a mesh into a JSON compatible object
  58939. * @param toSerialize defines the mesh to serialize
  58940. * @param withParents defines if parents must be serialized as well
  58941. * @param withChildren defines if children must be serialized as well
  58942. * @returns a JSON compatible object
  58943. */
  58944. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  58945. }
  58946. }
  58947. declare module "babylonjs/Misc/textureTools" {
  58948. import { Texture } from "babylonjs/Materials/Textures/texture";
  58949. /**
  58950. * Class used to host texture specific utilities
  58951. */
  58952. export class TextureTools {
  58953. /**
  58954. * Uses the GPU to create a copy texture rescaled at a given size
  58955. * @param texture Texture to copy from
  58956. * @param width defines the desired width
  58957. * @param height defines the desired height
  58958. * @param useBilinearMode defines if bilinear mode has to be used
  58959. * @return the generated texture
  58960. */
  58961. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  58962. }
  58963. }
  58964. declare module "babylonjs/Misc/videoRecorder" {
  58965. import { Nullable } from "babylonjs/types";
  58966. import { Engine } from "babylonjs/Engines/engine";
  58967. /**
  58968. * This represents the different options avilable for the video capture.
  58969. */
  58970. export interface VideoRecorderOptions {
  58971. /** Defines the mime type of the video */
  58972. mimeType: string;
  58973. /** Defines the video the video should be recorded at */
  58974. fps: number;
  58975. /** Defines the chunk size for the recording data */
  58976. recordChunckSize: number;
  58977. /** The audio tracks to attach to the record */
  58978. audioTracks?: MediaStreamTrack[];
  58979. }
  58980. /**
  58981. * This can helps recording videos from BabylonJS.
  58982. * This is based on the available WebRTC functionalities of the browser.
  58983. *
  58984. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  58985. */
  58986. export class VideoRecorder {
  58987. private static readonly _defaultOptions;
  58988. /**
  58989. * Returns wehther or not the VideoRecorder is available in your browser.
  58990. * @param engine Defines the Babylon Engine to check the support for
  58991. * @returns true if supported otherwise false
  58992. */
  58993. static IsSupported(engine: Engine): boolean;
  58994. private readonly _options;
  58995. private _canvas;
  58996. private _mediaRecorder;
  58997. private _recordedChunks;
  58998. private _fileName;
  58999. private _resolve;
  59000. private _reject;
  59001. /**
  59002. * True wether a recording is already in progress.
  59003. */
  59004. readonly isRecording: boolean;
  59005. /**
  59006. * Create a new VideoCapture object which can help converting what you see in Babylon to
  59007. * a video file.
  59008. * @param engine Defines the BabylonJS Engine you wish to record
  59009. * @param options Defines options that can be used to customized the capture
  59010. */
  59011. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  59012. /**
  59013. * Stops the current recording before the default capture timeout passed in the startRecording
  59014. * functions.
  59015. */
  59016. stopRecording(): void;
  59017. /**
  59018. * Starts recording the canvas for a max duration specified in parameters.
  59019. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  59020. * @param maxDuration Defines the maximum recording time in seconds.
  59021. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  59022. * @return a promise callback at the end of the recording with the video data in Blob.
  59023. */
  59024. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  59025. /**
  59026. * Releases internal resources used during the recording.
  59027. */
  59028. dispose(): void;
  59029. private _handleDataAvailable;
  59030. private _handleError;
  59031. private _handleStop;
  59032. }
  59033. }
  59034. declare module "babylonjs/Misc/screenshotTools" {
  59035. import { Camera } from "babylonjs/Cameras/camera";
  59036. import { Engine } from "babylonjs/Engines/engine";
  59037. /**
  59038. * Class containing a set of static utilities functions for screenshots
  59039. */
  59040. export class ScreenshotTools {
  59041. /**
  59042. * Captures a screenshot of the current rendering
  59043. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59044. * @param engine defines the rendering engine
  59045. * @param camera defines the source camera
  59046. * @param size This parameter can be set to a single number or to an object with the
  59047. * following (optional) properties: precision, width, height. If a single number is passed,
  59048. * it will be used for both width and height. If an object is passed, the screenshot size
  59049. * will be derived from the parameters. The precision property is a multiplier allowing
  59050. * rendering at a higher or lower resolution
  59051. * @param successCallback defines the callback receives a single parameter which contains the
  59052. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59053. * src parameter of an <img> to display it
  59054. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  59055. * Check your browser for supported MIME types
  59056. */
  59057. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  59058. /**
  59059. * Generates an image screenshot from the specified camera.
  59060. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59061. * @param engine The engine to use for rendering
  59062. * @param camera The camera to use for rendering
  59063. * @param size This parameter can be set to a single number or to an object with the
  59064. * following (optional) properties: precision, width, height. If a single number is passed,
  59065. * it will be used for both width and height. If an object is passed, the screenshot size
  59066. * will be derived from the parameters. The precision property is a multiplier allowing
  59067. * rendering at a higher or lower resolution
  59068. * @param successCallback The callback receives a single parameter which contains the
  59069. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59070. * src parameter of an <img> to display it
  59071. * @param mimeType The MIME type of the screenshot image (default: image/png).
  59072. * Check your browser for supported MIME types
  59073. * @param samples Texture samples (default: 1)
  59074. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  59075. * @param fileName A name for for the downloaded file.
  59076. */
  59077. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  59078. }
  59079. }
  59080. declare module "babylonjs/Misc/index" {
  59081. export * from "babylonjs/Misc/andOrNotEvaluator";
  59082. export * from "babylonjs/Misc/assetsManager";
  59083. export * from "babylonjs/Misc/dds";
  59084. export * from "babylonjs/Misc/decorators";
  59085. export * from "babylonjs/Misc/deferred";
  59086. export * from "babylonjs/Misc/environmentTextureTools";
  59087. export * from "babylonjs/Misc/meshExploder";
  59088. export * from "babylonjs/Misc/filesInput";
  59089. export * from "babylonjs/Misc/HighDynamicRange/index";
  59090. export * from "babylonjs/Misc/khronosTextureContainer";
  59091. export * from "babylonjs/Misc/observable";
  59092. export * from "babylonjs/Misc/performanceMonitor";
  59093. export * from "babylonjs/Misc/promise";
  59094. export * from "babylonjs/Misc/sceneOptimizer";
  59095. export * from "babylonjs/Misc/sceneSerializer";
  59096. export * from "babylonjs/Misc/smartArray";
  59097. export * from "babylonjs/Misc/stringDictionary";
  59098. export * from "babylonjs/Misc/tags";
  59099. export * from "babylonjs/Misc/textureTools";
  59100. export * from "babylonjs/Misc/tga";
  59101. export * from "babylonjs/Misc/tools";
  59102. export * from "babylonjs/Misc/videoRecorder";
  59103. export * from "babylonjs/Misc/virtualJoystick";
  59104. export * from "babylonjs/Misc/workerPool";
  59105. export * from "babylonjs/Misc/logger";
  59106. export * from "babylonjs/Misc/typeStore";
  59107. export * from "babylonjs/Misc/filesInputStore";
  59108. export * from "babylonjs/Misc/deepCopier";
  59109. export * from "babylonjs/Misc/pivotTools";
  59110. export * from "babylonjs/Misc/precisionDate";
  59111. export * from "babylonjs/Misc/screenshotTools";
  59112. export * from "babylonjs/Misc/typeStore";
  59113. export * from "babylonjs/Misc/webRequest";
  59114. export * from "babylonjs/Misc/iInspectable";
  59115. }
  59116. declare module "babylonjs/index" {
  59117. export * from "babylonjs/abstractScene";
  59118. export * from "babylonjs/Actions/index";
  59119. export * from "babylonjs/Animations/index";
  59120. export * from "babylonjs/assetContainer";
  59121. export * from "babylonjs/Audio/index";
  59122. export * from "babylonjs/Behaviors/index";
  59123. export * from "babylonjs/Bones/index";
  59124. export * from "babylonjs/Cameras/index";
  59125. export * from "babylonjs/Collisions/index";
  59126. export * from "babylonjs/Culling/index";
  59127. export * from "babylonjs/Debug/index";
  59128. export * from "babylonjs/Engines/index";
  59129. export * from "babylonjs/Events/index";
  59130. export * from "babylonjs/Gamepads/index";
  59131. export * from "babylonjs/Gizmos/index";
  59132. export * from "babylonjs/Helpers/index";
  59133. export * from "babylonjs/Instrumentation/index";
  59134. export * from "babylonjs/Layers/index";
  59135. export * from "babylonjs/LensFlares/index";
  59136. export * from "babylonjs/Lights/index";
  59137. export * from "babylonjs/Loading/index";
  59138. export * from "babylonjs/Materials/index";
  59139. export * from "babylonjs/Maths/index";
  59140. export * from "babylonjs/Meshes/index";
  59141. export * from "babylonjs/Morph/index";
  59142. export * from "babylonjs/node";
  59143. export * from "babylonjs/Offline/index";
  59144. export * from "babylonjs/Particles/index";
  59145. export * from "babylonjs/Physics/index";
  59146. export * from "babylonjs/PostProcesses/index";
  59147. export * from "babylonjs/Probes/index";
  59148. export * from "babylonjs/Rendering/index";
  59149. export * from "babylonjs/scene";
  59150. export * from "babylonjs/sceneComponent";
  59151. export * from "babylonjs/Sprites/index";
  59152. export * from "babylonjs/States/index";
  59153. export * from "babylonjs/Misc/index";
  59154. export * from "babylonjs/types";
  59155. }
  59156. declare module "babylonjs/Animations/pathCursor" {
  59157. import { Path2, Vector3 } from "babylonjs/Maths/math";
  59158. /**
  59159. * A cursor which tracks a point on a path
  59160. */
  59161. export class PathCursor {
  59162. private path;
  59163. /**
  59164. * Stores path cursor callbacks for when an onchange event is triggered
  59165. */
  59166. private _onchange;
  59167. /**
  59168. * The value of the path cursor
  59169. */
  59170. value: number;
  59171. /**
  59172. * The animation array of the path cursor
  59173. */
  59174. animations: Animation[];
  59175. /**
  59176. * Initializes the path cursor
  59177. * @param path The path to track
  59178. */
  59179. constructor(path: Path2);
  59180. /**
  59181. * Gets the cursor point on the path
  59182. * @returns A point on the path cursor at the cursor location
  59183. */
  59184. getPoint(): Vector3;
  59185. /**
  59186. * Moves the cursor ahead by the step amount
  59187. * @param step The amount to move the cursor forward
  59188. * @returns This path cursor
  59189. */
  59190. moveAhead(step?: number): PathCursor;
  59191. /**
  59192. * Moves the cursor behind by the step amount
  59193. * @param step The amount to move the cursor back
  59194. * @returns This path cursor
  59195. */
  59196. moveBack(step?: number): PathCursor;
  59197. /**
  59198. * Moves the cursor by the step amount
  59199. * If the step amount is greater than one, an exception is thrown
  59200. * @param step The amount to move the cursor
  59201. * @returns This path cursor
  59202. */
  59203. move(step: number): PathCursor;
  59204. /**
  59205. * Ensures that the value is limited between zero and one
  59206. * @returns This path cursor
  59207. */
  59208. private ensureLimits;
  59209. /**
  59210. * Runs onchange callbacks on change (used by the animation engine)
  59211. * @returns This path cursor
  59212. */
  59213. private raiseOnChange;
  59214. /**
  59215. * Executes a function on change
  59216. * @param f A path cursor onchange callback
  59217. * @returns This path cursor
  59218. */
  59219. onchange(f: (cursor: PathCursor) => void): PathCursor;
  59220. }
  59221. }
  59222. declare module "babylonjs/Legacy/legacy" {
  59223. import * as Babylon from "babylonjs/index";
  59224. export * from "babylonjs/index";
  59225. }
  59226. declare module "babylonjs/Shaders/blur.fragment" {
  59227. /** @hidden */
  59228. export var blurPixelShader: {
  59229. name: string;
  59230. shader: string;
  59231. };
  59232. }
  59233. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  59234. /** @hidden */
  59235. export var bones300Declaration: {
  59236. name: string;
  59237. shader: string;
  59238. };
  59239. }
  59240. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  59241. /** @hidden */
  59242. export var instances300Declaration: {
  59243. name: string;
  59244. shader: string;
  59245. };
  59246. }
  59247. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  59248. /** @hidden */
  59249. export var pointCloudVertexDeclaration: {
  59250. name: string;
  59251. shader: string;
  59252. };
  59253. }
  59254. // Mixins
  59255. interface Window {
  59256. mozIndexedDB: IDBFactory;
  59257. webkitIndexedDB: IDBFactory;
  59258. msIndexedDB: IDBFactory;
  59259. webkitURL: typeof URL;
  59260. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  59261. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  59262. WebGLRenderingContext: WebGLRenderingContext;
  59263. MSGesture: MSGesture;
  59264. CANNON: any;
  59265. AudioContext: AudioContext;
  59266. webkitAudioContext: AudioContext;
  59267. PointerEvent: any;
  59268. Math: Math;
  59269. Uint8Array: Uint8ArrayConstructor;
  59270. Float32Array: Float32ArrayConstructor;
  59271. mozURL: typeof URL;
  59272. msURL: typeof URL;
  59273. VRFrameData: any; // WebVR, from specs 1.1
  59274. DracoDecoderModule: any;
  59275. setImmediate(handler: (...args: any[]) => void): number;
  59276. }
  59277. interface HTMLCanvasElement {
  59278. requestPointerLock(): void;
  59279. msRequestPointerLock?(): void;
  59280. mozRequestPointerLock?(): void;
  59281. webkitRequestPointerLock?(): void;
  59282. /** Track wether a record is in progress */
  59283. isRecording: boolean;
  59284. /** Capture Stream method defined by some browsers */
  59285. captureStream(fps?: number): MediaStream;
  59286. }
  59287. interface CanvasRenderingContext2D {
  59288. msImageSmoothingEnabled: boolean;
  59289. }
  59290. interface MouseEvent {
  59291. mozMovementX: number;
  59292. mozMovementY: number;
  59293. webkitMovementX: number;
  59294. webkitMovementY: number;
  59295. msMovementX: number;
  59296. msMovementY: number;
  59297. }
  59298. interface Navigator {
  59299. mozGetVRDevices: (any: any) => any;
  59300. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59301. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59302. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59303. webkitGetGamepads(): Gamepad[];
  59304. msGetGamepads(): Gamepad[];
  59305. webkitGamepads(): Gamepad[];
  59306. }
  59307. interface HTMLVideoElement {
  59308. mozSrcObject: any;
  59309. }
  59310. interface Math {
  59311. fround(x: number): number;
  59312. imul(a: number, b: number): number;
  59313. }
  59314. interface WebGLRenderingContext {
  59315. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  59316. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  59317. vertexAttribDivisor(index: number, divisor: number): void;
  59318. createVertexArray(): any;
  59319. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  59320. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  59321. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  59322. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  59323. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  59324. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  59325. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  59326. // Queries
  59327. createQuery(): WebGLQuery;
  59328. deleteQuery(query: WebGLQuery): void;
  59329. beginQuery(target: number, query: WebGLQuery): void;
  59330. endQuery(target: number): void;
  59331. getQueryParameter(query: WebGLQuery, pname: number): any;
  59332. getQuery(target: number, pname: number): any;
  59333. MAX_SAMPLES: number;
  59334. RGBA8: number;
  59335. READ_FRAMEBUFFER: number;
  59336. DRAW_FRAMEBUFFER: number;
  59337. UNIFORM_BUFFER: number;
  59338. HALF_FLOAT_OES: number;
  59339. RGBA16F: number;
  59340. RGBA32F: number;
  59341. R32F: number;
  59342. RG32F: number;
  59343. RGB32F: number;
  59344. R16F: number;
  59345. RG16F: number;
  59346. RGB16F: number;
  59347. RED: number;
  59348. RG: number;
  59349. R8: number;
  59350. RG8: number;
  59351. UNSIGNED_INT_24_8: number;
  59352. DEPTH24_STENCIL8: number;
  59353. /* Multiple Render Targets */
  59354. drawBuffers(buffers: number[]): void;
  59355. readBuffer(src: number): void;
  59356. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  59357. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  59358. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  59359. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  59360. // Occlusion Query
  59361. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59362. ANY_SAMPLES_PASSED: number;
  59363. QUERY_RESULT_AVAILABLE: number;
  59364. QUERY_RESULT: number;
  59365. }
  59366. interface WebGLProgram {
  59367. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59368. }
  59369. interface EXT_disjoint_timer_query {
  59370. QUERY_COUNTER_BITS_EXT: number;
  59371. TIME_ELAPSED_EXT: number;
  59372. TIMESTAMP_EXT: number;
  59373. GPU_DISJOINT_EXT: number;
  59374. QUERY_RESULT_EXT: number;
  59375. QUERY_RESULT_AVAILABLE_EXT: number;
  59376. queryCounterEXT(query: WebGLQuery, target: number): void;
  59377. createQueryEXT(): WebGLQuery;
  59378. beginQueryEXT(target: number, query: WebGLQuery): void;
  59379. endQueryEXT(target: number): void;
  59380. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59381. deleteQueryEXT(query: WebGLQuery): void;
  59382. }
  59383. interface WebGLUniformLocation {
  59384. _currentState: any;
  59385. }
  59386. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59387. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59388. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59389. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59390. interface WebGLRenderingContext {
  59391. readonly RASTERIZER_DISCARD: number;
  59392. readonly DEPTH_COMPONENT24: number;
  59393. readonly TEXTURE_3D: number;
  59394. readonly TEXTURE_2D_ARRAY: number;
  59395. readonly TEXTURE_COMPARE_FUNC: number;
  59396. readonly TEXTURE_COMPARE_MODE: number;
  59397. readonly COMPARE_REF_TO_TEXTURE: number;
  59398. readonly TEXTURE_WRAP_R: number;
  59399. readonly HALF_FLOAT: number;
  59400. readonly RGB8: number;
  59401. readonly RED_INTEGER: number;
  59402. readonly RG_INTEGER: number;
  59403. readonly RGB_INTEGER: number;
  59404. readonly RGBA_INTEGER: number;
  59405. readonly R8_SNORM: number;
  59406. readonly RG8_SNORM: number;
  59407. readonly RGB8_SNORM: number;
  59408. readonly RGBA8_SNORM: number;
  59409. readonly R8I: number;
  59410. readonly RG8I: number;
  59411. readonly RGB8I: number;
  59412. readonly RGBA8I: number;
  59413. readonly R8UI: number;
  59414. readonly RG8UI: number;
  59415. readonly RGB8UI: number;
  59416. readonly RGBA8UI: number;
  59417. readonly R16I: number;
  59418. readonly RG16I: number;
  59419. readonly RGB16I: number;
  59420. readonly RGBA16I: number;
  59421. readonly R16UI: number;
  59422. readonly RG16UI: number;
  59423. readonly RGB16UI: number;
  59424. readonly RGBA16UI: number;
  59425. readonly R32I: number;
  59426. readonly RG32I: number;
  59427. readonly RGB32I: number;
  59428. readonly RGBA32I: number;
  59429. readonly R32UI: number;
  59430. readonly RG32UI: number;
  59431. readonly RGB32UI: number;
  59432. readonly RGBA32UI: number;
  59433. readonly RGB10_A2UI: number;
  59434. readonly R11F_G11F_B10F: number;
  59435. readonly RGB9_E5: number;
  59436. readonly RGB10_A2: number;
  59437. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59438. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59439. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59440. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59441. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59442. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59443. 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;
  59444. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59445. readonly TRANSFORM_FEEDBACK: number;
  59446. readonly INTERLEAVED_ATTRIBS: number;
  59447. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59448. createTransformFeedback(): WebGLTransformFeedback;
  59449. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59450. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59451. beginTransformFeedback(primitiveMode: number): void;
  59452. endTransformFeedback(): void;
  59453. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59454. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59455. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59456. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59457. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59458. }
  59459. interface ImageBitmap {
  59460. readonly width: number;
  59461. readonly height: number;
  59462. close(): void;
  59463. }
  59464. interface WebGLQuery extends WebGLObject {
  59465. }
  59466. declare var WebGLQuery: {
  59467. prototype: WebGLQuery;
  59468. new(): WebGLQuery;
  59469. };
  59470. interface WebGLSampler extends WebGLObject {
  59471. }
  59472. declare var WebGLSampler: {
  59473. prototype: WebGLSampler;
  59474. new(): WebGLSampler;
  59475. };
  59476. interface WebGLSync extends WebGLObject {
  59477. }
  59478. declare var WebGLSync: {
  59479. prototype: WebGLSync;
  59480. new(): WebGLSync;
  59481. };
  59482. interface WebGLTransformFeedback extends WebGLObject {
  59483. }
  59484. declare var WebGLTransformFeedback: {
  59485. prototype: WebGLTransformFeedback;
  59486. new(): WebGLTransformFeedback;
  59487. };
  59488. interface WebGLVertexArrayObject extends WebGLObject {
  59489. }
  59490. declare var WebGLVertexArrayObject: {
  59491. prototype: WebGLVertexArrayObject;
  59492. new(): WebGLVertexArrayObject;
  59493. };
  59494. // Type definitions for WebVR API
  59495. // Project: https://w3c.github.io/webvr/
  59496. // Definitions by: six a <https://github.com/lostfictions>
  59497. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59498. interface VRDisplay extends EventTarget {
  59499. /**
  59500. * Dictionary of capabilities describing the VRDisplay.
  59501. */
  59502. readonly capabilities: VRDisplayCapabilities;
  59503. /**
  59504. * z-depth defining the far plane of the eye view frustum
  59505. * enables mapping of values in the render target depth
  59506. * attachment to scene coordinates. Initially set to 10000.0.
  59507. */
  59508. depthFar: number;
  59509. /**
  59510. * z-depth defining the near plane of the eye view frustum
  59511. * enables mapping of values in the render target depth
  59512. * attachment to scene coordinates. Initially set to 0.01.
  59513. */
  59514. depthNear: number;
  59515. /**
  59516. * An identifier for this distinct VRDisplay. Used as an
  59517. * association point in the Gamepad API.
  59518. */
  59519. readonly displayId: number;
  59520. /**
  59521. * A display name, a user-readable name identifying it.
  59522. */
  59523. readonly displayName: string;
  59524. readonly isConnected: boolean;
  59525. readonly isPresenting: boolean;
  59526. /**
  59527. * If this VRDisplay supports room-scale experiences, the optional
  59528. * stage attribute contains details on the room-scale parameters.
  59529. */
  59530. readonly stageParameters: VRStageParameters | null;
  59531. /**
  59532. * Passing the value returned by `requestAnimationFrame` to
  59533. * `cancelAnimationFrame` will unregister the callback.
  59534. * @param handle Define the hanle of the request to cancel
  59535. */
  59536. cancelAnimationFrame(handle: number): void;
  59537. /**
  59538. * Stops presenting to the VRDisplay.
  59539. * @returns a promise to know when it stopped
  59540. */
  59541. exitPresent(): Promise<void>;
  59542. /**
  59543. * Return the current VREyeParameters for the given eye.
  59544. * @param whichEye Define the eye we want the parameter for
  59545. * @returns the eye parameters
  59546. */
  59547. getEyeParameters(whichEye: string): VREyeParameters;
  59548. /**
  59549. * Populates the passed VRFrameData with the information required to render
  59550. * the current frame.
  59551. * @param frameData Define the data structure to populate
  59552. * @returns true if ok otherwise false
  59553. */
  59554. getFrameData(frameData: VRFrameData): boolean;
  59555. /**
  59556. * Get the layers currently being presented.
  59557. * @returns the list of VR layers
  59558. */
  59559. getLayers(): VRLayer[];
  59560. /**
  59561. * Return a VRPose containing the future predicted pose of the VRDisplay
  59562. * when the current frame will be presented. The value returned will not
  59563. * change until JavaScript has returned control to the browser.
  59564. *
  59565. * The VRPose will contain the position, orientation, velocity,
  59566. * and acceleration of each of these properties.
  59567. * @returns the pose object
  59568. */
  59569. getPose(): VRPose;
  59570. /**
  59571. * Return the current instantaneous pose of the VRDisplay, with no
  59572. * prediction applied.
  59573. * @returns the current instantaneous pose
  59574. */
  59575. getImmediatePose(): VRPose;
  59576. /**
  59577. * The callback passed to `requestAnimationFrame` will be called
  59578. * any time a new frame should be rendered. When the VRDisplay is
  59579. * presenting the callback will be called at the native refresh
  59580. * rate of the HMD. When not presenting this function acts
  59581. * identically to how window.requestAnimationFrame acts. Content should
  59582. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59583. * asynchronously from other displays and at differing refresh rates.
  59584. * @param callback Define the eaction to run next frame
  59585. * @returns the request handle it
  59586. */
  59587. requestAnimationFrame(callback: FrameRequestCallback): number;
  59588. /**
  59589. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59590. * Repeat calls while already presenting will update the VRLayers being displayed.
  59591. * @param layers Define the list of layer to present
  59592. * @returns a promise to know when the request has been fulfilled
  59593. */
  59594. requestPresent(layers: VRLayer[]): Promise<void>;
  59595. /**
  59596. * Reset the pose for this display, treating its current position and
  59597. * orientation as the "origin/zero" values. VRPose.position,
  59598. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59599. * updated when calling resetPose(). This should be called in only
  59600. * sitting-space experiences.
  59601. */
  59602. resetPose(): void;
  59603. /**
  59604. * The VRLayer provided to the VRDisplay will be captured and presented
  59605. * in the HMD. Calling this function has the same effect on the source
  59606. * canvas as any other operation that uses its source image, and canvases
  59607. * created without preserveDrawingBuffer set to true will be cleared.
  59608. * @param pose Define the pose to submit
  59609. */
  59610. submitFrame(pose?: VRPose): void;
  59611. }
  59612. declare var VRDisplay: {
  59613. prototype: VRDisplay;
  59614. new(): VRDisplay;
  59615. };
  59616. interface VRLayer {
  59617. leftBounds?: number[] | Float32Array | null;
  59618. rightBounds?: number[] | Float32Array | null;
  59619. source?: HTMLCanvasElement | null;
  59620. }
  59621. interface VRDisplayCapabilities {
  59622. readonly canPresent: boolean;
  59623. readonly hasExternalDisplay: boolean;
  59624. readonly hasOrientation: boolean;
  59625. readonly hasPosition: boolean;
  59626. readonly maxLayers: number;
  59627. }
  59628. interface VREyeParameters {
  59629. /** @deprecated */
  59630. readonly fieldOfView: VRFieldOfView;
  59631. readonly offset: Float32Array;
  59632. readonly renderHeight: number;
  59633. readonly renderWidth: number;
  59634. }
  59635. interface VRFieldOfView {
  59636. readonly downDegrees: number;
  59637. readonly leftDegrees: number;
  59638. readonly rightDegrees: number;
  59639. readonly upDegrees: number;
  59640. }
  59641. interface VRFrameData {
  59642. readonly leftProjectionMatrix: Float32Array;
  59643. readonly leftViewMatrix: Float32Array;
  59644. readonly pose: VRPose;
  59645. readonly rightProjectionMatrix: Float32Array;
  59646. readonly rightViewMatrix: Float32Array;
  59647. readonly timestamp: number;
  59648. }
  59649. interface VRPose {
  59650. readonly angularAcceleration: Float32Array | null;
  59651. readonly angularVelocity: Float32Array | null;
  59652. readonly linearAcceleration: Float32Array | null;
  59653. readonly linearVelocity: Float32Array | null;
  59654. readonly orientation: Float32Array | null;
  59655. readonly position: Float32Array | null;
  59656. readonly timestamp: number;
  59657. }
  59658. interface VRStageParameters {
  59659. sittingToStandingTransform?: Float32Array;
  59660. sizeX?: number;
  59661. sizeY?: number;
  59662. }
  59663. interface Navigator {
  59664. getVRDisplays(): Promise<VRDisplay[]>;
  59665. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59666. }
  59667. interface Window {
  59668. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59669. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59670. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59671. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59672. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59673. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59674. }
  59675. interface Gamepad {
  59676. readonly displayId: number;
  59677. }
  59678. interface XRDevice {
  59679. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59680. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59681. }
  59682. interface XRSession {
  59683. getInputSources(): Array<any>;
  59684. baseLayer: XRWebGLLayer;
  59685. requestFrameOfReference(type: string): Promise<void>;
  59686. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59687. end(): Promise<void>;
  59688. requestAnimationFrame: Function;
  59689. addEventListener: Function;
  59690. }
  59691. interface XRSessionCreationOptions {
  59692. outputContext?: WebGLRenderingContext | null;
  59693. immersive?: boolean;
  59694. environmentIntegration?: boolean;
  59695. }
  59696. interface XRLayer {
  59697. getViewport: Function;
  59698. framebufferWidth: number;
  59699. framebufferHeight: number;
  59700. }
  59701. interface XRView {
  59702. projectionMatrix: Float32Array;
  59703. }
  59704. interface XRFrame {
  59705. getDevicePose: Function;
  59706. getInputPose: Function;
  59707. views: Array<XRView>;
  59708. baseLayer: XRLayer;
  59709. }
  59710. interface XRFrameOfReference {
  59711. }
  59712. interface XRWebGLLayer extends XRLayer {
  59713. framebuffer: WebGLFramebuffer;
  59714. }
  59715. declare var XRWebGLLayer: {
  59716. prototype: XRWebGLLayer;
  59717. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59718. };
  59719. declare module "babylonjs" {
  59720. export * from "babylonjs/Legacy/legacy";
  59721. }
  59722. declare module BABYLON {
  59723. /** Alias type for value that can be null */
  59724. export type Nullable<T> = T | null;
  59725. /**
  59726. * Alias type for number that are floats
  59727. * @ignorenaming
  59728. */
  59729. export type float = number;
  59730. /**
  59731. * Alias type for number that are doubles.
  59732. * @ignorenaming
  59733. */
  59734. export type double = number;
  59735. /**
  59736. * Alias type for number that are integer
  59737. * @ignorenaming
  59738. */
  59739. export type int = number;
  59740. /** Alias type for number array or Float32Array */
  59741. export type FloatArray = number[] | Float32Array;
  59742. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  59743. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  59744. /**
  59745. * Alias for types that can be used by a Buffer or VertexBuffer.
  59746. */
  59747. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  59748. /**
  59749. * Alias type for primitive types
  59750. * @ignorenaming
  59751. */
  59752. type Primitive = undefined | null | boolean | string | number | Function;
  59753. /**
  59754. * Type modifier to make all the properties of an object Readonly
  59755. */
  59756. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  59757. /**
  59758. * Type modifier to make all the properties of an object Readonly recursively
  59759. */
  59760. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  59761. /** @hidden */
  59762. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  59763. }
  59764. /** @hidden */
  59765. /** @hidden */
  59766. type DeepImmutableObject<T> = {
  59767. readonly [K in keyof T]: DeepImmutable<T[K]>;
  59768. };
  59769. }
  59770. declare module BABYLON {
  59771. /**
  59772. * Class containing a set of static utilities functions for arrays.
  59773. */
  59774. export class ArrayTools {
  59775. /**
  59776. * Returns an array of the given size filled with element built from the given constructor and the paramters
  59777. * @param size the number of element to construct and put in the array
  59778. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  59779. * @returns a new array filled with new objects
  59780. */
  59781. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  59782. }
  59783. }
  59784. declare module BABYLON {
  59785. /**
  59786. * Scalar computation library
  59787. */
  59788. export class Scalar {
  59789. /**
  59790. * Two pi constants convenient for computation.
  59791. */
  59792. static TwoPi: number;
  59793. /**
  59794. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59795. * @param a number
  59796. * @param b number
  59797. * @param epsilon (default = 1.401298E-45)
  59798. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59799. */
  59800. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  59801. /**
  59802. * Returns a string : the upper case translation of the number i to hexadecimal.
  59803. * @param i number
  59804. * @returns the upper case translation of the number i to hexadecimal.
  59805. */
  59806. static ToHex(i: number): string;
  59807. /**
  59808. * Returns -1 if value is negative and +1 is value is positive.
  59809. * @param value the value
  59810. * @returns the value itself if it's equal to zero.
  59811. */
  59812. static Sign(value: number): number;
  59813. /**
  59814. * Returns the value itself if it's between min and max.
  59815. * Returns min if the value is lower than min.
  59816. * Returns max if the value is greater than max.
  59817. * @param value the value to clmap
  59818. * @param min the min value to clamp to (default: 0)
  59819. * @param max the max value to clamp to (default: 1)
  59820. * @returns the clamped value
  59821. */
  59822. static Clamp(value: number, min?: number, max?: number): number;
  59823. /**
  59824. * the log2 of value.
  59825. * @param value the value to compute log2 of
  59826. * @returns the log2 of value.
  59827. */
  59828. static Log2(value: number): number;
  59829. /**
  59830. * Loops the value, so that it is never larger than length and never smaller than 0.
  59831. *
  59832. * This is similar to the modulo operator but it works with floating point numbers.
  59833. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  59834. * With t = 5 and length = 2.5, the result would be 0.0.
  59835. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  59836. * @param value the value
  59837. * @param length the length
  59838. * @returns the looped value
  59839. */
  59840. static Repeat(value: number, length: number): number;
  59841. /**
  59842. * Normalize the value between 0.0 and 1.0 using min and max values
  59843. * @param value value to normalize
  59844. * @param min max to normalize between
  59845. * @param max min to normalize between
  59846. * @returns the normalized value
  59847. */
  59848. static Normalize(value: number, min: number, max: number): number;
  59849. /**
  59850. * Denormalize the value from 0.0 and 1.0 using min and max values
  59851. * @param normalized value to denormalize
  59852. * @param min max to denormalize between
  59853. * @param max min to denormalize between
  59854. * @returns the denormalized value
  59855. */
  59856. static Denormalize(normalized: number, min: number, max: number): number;
  59857. /**
  59858. * Calculates the shortest difference between two given angles given in degrees.
  59859. * @param current current angle in degrees
  59860. * @param target target angle in degrees
  59861. * @returns the delta
  59862. */
  59863. static DeltaAngle(current: number, target: number): number;
  59864. /**
  59865. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  59866. * @param tx value
  59867. * @param length length
  59868. * @returns The returned value will move back and forth between 0 and length
  59869. */
  59870. static PingPong(tx: number, length: number): number;
  59871. /**
  59872. * Interpolates between min and max with smoothing at the limits.
  59873. *
  59874. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  59875. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  59876. * @param from from
  59877. * @param to to
  59878. * @param tx value
  59879. * @returns the smooth stepped value
  59880. */
  59881. static SmoothStep(from: number, to: number, tx: number): number;
  59882. /**
  59883. * Moves a value current towards target.
  59884. *
  59885. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  59886. * Negative values of maxDelta pushes the value away from target.
  59887. * @param current current value
  59888. * @param target target value
  59889. * @param maxDelta max distance to move
  59890. * @returns resulting value
  59891. */
  59892. static MoveTowards(current: number, target: number, maxDelta: number): number;
  59893. /**
  59894. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  59895. *
  59896. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  59897. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  59898. * @param current current value
  59899. * @param target target value
  59900. * @param maxDelta max distance to move
  59901. * @returns resulting angle
  59902. */
  59903. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  59904. /**
  59905. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  59906. * @param start start value
  59907. * @param end target value
  59908. * @param amount amount to lerp between
  59909. * @returns the lerped value
  59910. */
  59911. static Lerp(start: number, end: number, amount: number): number;
  59912. /**
  59913. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  59914. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  59915. * @param start start value
  59916. * @param end target value
  59917. * @param amount amount to lerp between
  59918. * @returns the lerped value
  59919. */
  59920. static LerpAngle(start: number, end: number, amount: number): number;
  59921. /**
  59922. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  59923. * @param a start value
  59924. * @param b target value
  59925. * @param value value between a and b
  59926. * @returns the inverseLerp value
  59927. */
  59928. static InverseLerp(a: number, b: number, value: number): number;
  59929. /**
  59930. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  59931. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  59932. * @param value1 spline value
  59933. * @param tangent1 spline value
  59934. * @param value2 spline value
  59935. * @param tangent2 spline value
  59936. * @param amount input value
  59937. * @returns hermite result
  59938. */
  59939. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  59940. /**
  59941. * Returns a random float number between and min and max values
  59942. * @param min min value of random
  59943. * @param max max value of random
  59944. * @returns random value
  59945. */
  59946. static RandomRange(min: number, max: number): number;
  59947. /**
  59948. * This function returns percentage of a number in a given range.
  59949. *
  59950. * RangeToPercent(40,20,60) will return 0.5 (50%)
  59951. * RangeToPercent(34,0,100) will return 0.34 (34%)
  59952. * @param number to convert to percentage
  59953. * @param min min range
  59954. * @param max max range
  59955. * @returns the percentage
  59956. */
  59957. static RangeToPercent(number: number, min: number, max: number): number;
  59958. /**
  59959. * This function returns number that corresponds to the percentage in a given range.
  59960. *
  59961. * PercentToRange(0.34,0,100) will return 34.
  59962. * @param percent to convert to number
  59963. * @param min min range
  59964. * @param max max range
  59965. * @returns the number
  59966. */
  59967. static PercentToRange(percent: number, min: number, max: number): number;
  59968. /**
  59969. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  59970. * @param angle The angle to normalize in radian.
  59971. * @return The converted angle.
  59972. */
  59973. static NormalizeRadians(angle: number): number;
  59974. }
  59975. }
  59976. declare module BABYLON {
  59977. /**
  59978. * Constant used to convert a value to gamma space
  59979. * @ignorenaming
  59980. */
  59981. export const ToGammaSpace: number;
  59982. /**
  59983. * Constant used to convert a value to linear space
  59984. * @ignorenaming
  59985. */
  59986. export const ToLinearSpace = 2.2;
  59987. /**
  59988. * Constant used to define the minimal number value in Babylon.js
  59989. * @ignorenaming
  59990. */
  59991. let Epsilon: number;
  59992. /**
  59993. * Class used to hold a RBG color
  59994. */
  59995. export class Color3 {
  59996. /**
  59997. * Defines the red component (between 0 and 1, default is 0)
  59998. */
  59999. r: number;
  60000. /**
  60001. * Defines the green component (between 0 and 1, default is 0)
  60002. */
  60003. g: number;
  60004. /**
  60005. * Defines the blue component (between 0 and 1, default is 0)
  60006. */
  60007. b: number;
  60008. /**
  60009. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  60010. * @param r defines the red component (between 0 and 1, default is 0)
  60011. * @param g defines the green component (between 0 and 1, default is 0)
  60012. * @param b defines the blue component (between 0 and 1, default is 0)
  60013. */
  60014. constructor(
  60015. /**
  60016. * Defines the red component (between 0 and 1, default is 0)
  60017. */
  60018. r?: number,
  60019. /**
  60020. * Defines the green component (between 0 and 1, default is 0)
  60021. */
  60022. g?: number,
  60023. /**
  60024. * Defines the blue component (between 0 and 1, default is 0)
  60025. */
  60026. b?: number);
  60027. /**
  60028. * Creates a string with the Color3 current values
  60029. * @returns the string representation of the Color3 object
  60030. */
  60031. toString(): string;
  60032. /**
  60033. * Returns the string "Color3"
  60034. * @returns "Color3"
  60035. */
  60036. getClassName(): string;
  60037. /**
  60038. * Compute the Color3 hash code
  60039. * @returns an unique number that can be used to hash Color3 objects
  60040. */
  60041. getHashCode(): number;
  60042. /**
  60043. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  60044. * @param array defines the array where to store the r,g,b components
  60045. * @param index defines an optional index in the target array to define where to start storing values
  60046. * @returns the current Color3 object
  60047. */
  60048. toArray(array: FloatArray, index?: number): Color3;
  60049. /**
  60050. * Returns a new Color4 object from the current Color3 and the given alpha
  60051. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  60052. * @returns a new Color4 object
  60053. */
  60054. toColor4(alpha?: number): Color4;
  60055. /**
  60056. * Returns a new array populated with 3 numeric elements : red, green and blue values
  60057. * @returns the new array
  60058. */
  60059. asArray(): number[];
  60060. /**
  60061. * Returns the luminance value
  60062. * @returns a float value
  60063. */
  60064. toLuminance(): number;
  60065. /**
  60066. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  60067. * @param otherColor defines the second operand
  60068. * @returns the new Color3 object
  60069. */
  60070. multiply(otherColor: DeepImmutable<Color3>): Color3;
  60071. /**
  60072. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  60073. * @param otherColor defines the second operand
  60074. * @param result defines the Color3 object where to store the result
  60075. * @returns the current Color3
  60076. */
  60077. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60078. /**
  60079. * Determines equality between Color3 objects
  60080. * @param otherColor defines the second operand
  60081. * @returns true if the rgb values are equal to the given ones
  60082. */
  60083. equals(otherColor: DeepImmutable<Color3>): boolean;
  60084. /**
  60085. * Determines equality between the current Color3 object and a set of r,b,g values
  60086. * @param r defines the red component to check
  60087. * @param g defines the green component to check
  60088. * @param b defines the blue component to check
  60089. * @returns true if the rgb values are equal to the given ones
  60090. */
  60091. equalsFloats(r: number, g: number, b: number): boolean;
  60092. /**
  60093. * Multiplies in place each rgb value by scale
  60094. * @param scale defines the scaling factor
  60095. * @returns the updated Color3
  60096. */
  60097. scale(scale: number): Color3;
  60098. /**
  60099. * Multiplies the rgb values by scale and stores the result into "result"
  60100. * @param scale defines the scaling factor
  60101. * @param result defines the Color3 object where to store the result
  60102. * @returns the unmodified current Color3
  60103. */
  60104. scaleToRef(scale: number, result: Color3): Color3;
  60105. /**
  60106. * Scale the current Color3 values by a factor and add the result to a given Color3
  60107. * @param scale defines the scale factor
  60108. * @param result defines color to store the result into
  60109. * @returns the unmodified current Color3
  60110. */
  60111. scaleAndAddToRef(scale: number, result: Color3): Color3;
  60112. /**
  60113. * Clamps the rgb values by the min and max values and stores the result into "result"
  60114. * @param min defines minimum clamping value (default is 0)
  60115. * @param max defines maximum clamping value (default is 1)
  60116. * @param result defines color to store the result into
  60117. * @returns the original Color3
  60118. */
  60119. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  60120. /**
  60121. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  60122. * @param otherColor defines the second operand
  60123. * @returns the new Color3
  60124. */
  60125. add(otherColor: DeepImmutable<Color3>): Color3;
  60126. /**
  60127. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  60128. * @param otherColor defines the second operand
  60129. * @param result defines Color3 object to store the result into
  60130. * @returns the unmodified current Color3
  60131. */
  60132. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60133. /**
  60134. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  60135. * @param otherColor defines the second operand
  60136. * @returns the new Color3
  60137. */
  60138. subtract(otherColor: DeepImmutable<Color3>): Color3;
  60139. /**
  60140. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  60141. * @param otherColor defines the second operand
  60142. * @param result defines Color3 object to store the result into
  60143. * @returns the unmodified current Color3
  60144. */
  60145. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60146. /**
  60147. * Copy the current object
  60148. * @returns a new Color3 copied the current one
  60149. */
  60150. clone(): Color3;
  60151. /**
  60152. * Copies the rgb values from the source in the current Color3
  60153. * @param source defines the source Color3 object
  60154. * @returns the updated Color3 object
  60155. */
  60156. copyFrom(source: DeepImmutable<Color3>): Color3;
  60157. /**
  60158. * Updates the Color3 rgb values from the given floats
  60159. * @param r defines the red component to read from
  60160. * @param g defines the green component to read from
  60161. * @param b defines the blue component to read from
  60162. * @returns the current Color3 object
  60163. */
  60164. copyFromFloats(r: number, g: number, b: number): Color3;
  60165. /**
  60166. * Updates the Color3 rgb values from the given floats
  60167. * @param r defines the red component to read from
  60168. * @param g defines the green component to read from
  60169. * @param b defines the blue component to read from
  60170. * @returns the current Color3 object
  60171. */
  60172. set(r: number, g: number, b: number): Color3;
  60173. /**
  60174. * Compute the Color3 hexadecimal code as a string
  60175. * @returns a string containing the hexadecimal representation of the Color3 object
  60176. */
  60177. toHexString(): string;
  60178. /**
  60179. * Computes a new Color3 converted from the current one to linear space
  60180. * @returns a new Color3 object
  60181. */
  60182. toLinearSpace(): Color3;
  60183. /**
  60184. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  60185. * @param convertedColor defines the Color3 object where to store the linear space version
  60186. * @returns the unmodified Color3
  60187. */
  60188. toLinearSpaceToRef(convertedColor: Color3): Color3;
  60189. /**
  60190. * Computes a new Color3 converted from the current one to gamma space
  60191. * @returns a new Color3 object
  60192. */
  60193. toGammaSpace(): Color3;
  60194. /**
  60195. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  60196. * @param convertedColor defines the Color3 object where to store the gamma space version
  60197. * @returns the unmodified Color3
  60198. */
  60199. toGammaSpaceToRef(convertedColor: Color3): Color3;
  60200. private static _BlackReadOnly;
  60201. /**
  60202. * Creates a new Color3 from the string containing valid hexadecimal values
  60203. * @param hex defines a string containing valid hexadecimal values
  60204. * @returns a new Color3 object
  60205. */
  60206. static FromHexString(hex: string): Color3;
  60207. /**
  60208. * Creates a new Color3 from the starting index of the given array
  60209. * @param array defines the source array
  60210. * @param offset defines an offset in the source array
  60211. * @returns a new Color3 object
  60212. */
  60213. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  60214. /**
  60215. * Creates a new Color3 from integer values (< 256)
  60216. * @param r defines the red component to read from (value between 0 and 255)
  60217. * @param g defines the green component to read from (value between 0 and 255)
  60218. * @param b defines the blue component to read from (value between 0 and 255)
  60219. * @returns a new Color3 object
  60220. */
  60221. static FromInts(r: number, g: number, b: number): Color3;
  60222. /**
  60223. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60224. * @param start defines the start Color3 value
  60225. * @param end defines the end Color3 value
  60226. * @param amount defines the gradient value between start and end
  60227. * @returns a new Color3 object
  60228. */
  60229. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  60230. /**
  60231. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60232. * @param left defines the start value
  60233. * @param right defines the end value
  60234. * @param amount defines the gradient factor
  60235. * @param result defines the Color3 object where to store the result
  60236. */
  60237. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  60238. /**
  60239. * Returns a Color3 value containing a red color
  60240. * @returns a new Color3 object
  60241. */
  60242. static Red(): Color3;
  60243. /**
  60244. * Returns a Color3 value containing a green color
  60245. * @returns a new Color3 object
  60246. */
  60247. static Green(): Color3;
  60248. /**
  60249. * Returns a Color3 value containing a blue color
  60250. * @returns a new Color3 object
  60251. */
  60252. static Blue(): Color3;
  60253. /**
  60254. * Returns a Color3 value containing a black color
  60255. * @returns a new Color3 object
  60256. */
  60257. static Black(): Color3;
  60258. /**
  60259. * Gets a Color3 value containing a black color that must not be updated
  60260. */
  60261. static readonly BlackReadOnly: DeepImmutable<Color3>;
  60262. /**
  60263. * Returns a Color3 value containing a white color
  60264. * @returns a new Color3 object
  60265. */
  60266. static White(): Color3;
  60267. /**
  60268. * Returns a Color3 value containing a purple color
  60269. * @returns a new Color3 object
  60270. */
  60271. static Purple(): Color3;
  60272. /**
  60273. * Returns a Color3 value containing a magenta color
  60274. * @returns a new Color3 object
  60275. */
  60276. static Magenta(): Color3;
  60277. /**
  60278. * Returns a Color3 value containing a yellow color
  60279. * @returns a new Color3 object
  60280. */
  60281. static Yellow(): Color3;
  60282. /**
  60283. * Returns a Color3 value containing a gray color
  60284. * @returns a new Color3 object
  60285. */
  60286. static Gray(): Color3;
  60287. /**
  60288. * Returns a Color3 value containing a teal color
  60289. * @returns a new Color3 object
  60290. */
  60291. static Teal(): Color3;
  60292. /**
  60293. * Returns a Color3 value containing a random color
  60294. * @returns a new Color3 object
  60295. */
  60296. static Random(): Color3;
  60297. }
  60298. /**
  60299. * Class used to hold a RBGA color
  60300. */
  60301. export class Color4 {
  60302. /**
  60303. * Defines the red component (between 0 and 1, default is 0)
  60304. */
  60305. r: number;
  60306. /**
  60307. * Defines the green component (between 0 and 1, default is 0)
  60308. */
  60309. g: number;
  60310. /**
  60311. * Defines the blue component (between 0 and 1, default is 0)
  60312. */
  60313. b: number;
  60314. /**
  60315. * Defines the alpha component (between 0 and 1, default is 1)
  60316. */
  60317. a: number;
  60318. /**
  60319. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  60320. * @param r defines the red component (between 0 and 1, default is 0)
  60321. * @param g defines the green component (between 0 and 1, default is 0)
  60322. * @param b defines the blue component (between 0 and 1, default is 0)
  60323. * @param a defines the alpha component (between 0 and 1, default is 1)
  60324. */
  60325. constructor(
  60326. /**
  60327. * Defines the red component (between 0 and 1, default is 0)
  60328. */
  60329. r?: number,
  60330. /**
  60331. * Defines the green component (between 0 and 1, default is 0)
  60332. */
  60333. g?: number,
  60334. /**
  60335. * Defines the blue component (between 0 and 1, default is 0)
  60336. */
  60337. b?: number,
  60338. /**
  60339. * Defines the alpha component (between 0 and 1, default is 1)
  60340. */
  60341. a?: number);
  60342. /**
  60343. * Adds in place the given Color4 values to the current Color4 object
  60344. * @param right defines the second operand
  60345. * @returns the current updated Color4 object
  60346. */
  60347. addInPlace(right: DeepImmutable<Color4>): Color4;
  60348. /**
  60349. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  60350. * @returns the new array
  60351. */
  60352. asArray(): number[];
  60353. /**
  60354. * Stores from the starting index in the given array the Color4 successive values
  60355. * @param array defines the array where to store the r,g,b components
  60356. * @param index defines an optional index in the target array to define where to start storing values
  60357. * @returns the current Color4 object
  60358. */
  60359. toArray(array: number[], index?: number): Color4;
  60360. /**
  60361. * Determines equality between Color4 objects
  60362. * @param otherColor defines the second operand
  60363. * @returns true if the rgba values are equal to the given ones
  60364. */
  60365. equals(otherColor: DeepImmutable<Color4>): boolean;
  60366. /**
  60367. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  60368. * @param right defines the second operand
  60369. * @returns a new Color4 object
  60370. */
  60371. add(right: DeepImmutable<Color4>): Color4;
  60372. /**
  60373. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  60374. * @param right defines the second operand
  60375. * @returns a new Color4 object
  60376. */
  60377. subtract(right: DeepImmutable<Color4>): Color4;
  60378. /**
  60379. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  60380. * @param right defines the second operand
  60381. * @param result defines the Color4 object where to store the result
  60382. * @returns the current Color4 object
  60383. */
  60384. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  60385. /**
  60386. * Creates a new Color4 with the current Color4 values multiplied by scale
  60387. * @param scale defines the scaling factor to apply
  60388. * @returns a new Color4 object
  60389. */
  60390. scale(scale: number): Color4;
  60391. /**
  60392. * Multiplies the current Color4 values by scale and stores the result in "result"
  60393. * @param scale defines the scaling factor to apply
  60394. * @param result defines the Color4 object where to store the result
  60395. * @returns the current unmodified Color4
  60396. */
  60397. scaleToRef(scale: number, result: Color4): Color4;
  60398. /**
  60399. * Scale the current Color4 values by a factor and add the result to a given Color4
  60400. * @param scale defines the scale factor
  60401. * @param result defines the Color4 object where to store the result
  60402. * @returns the unmodified current Color4
  60403. */
  60404. scaleAndAddToRef(scale: number, result: Color4): Color4;
  60405. /**
  60406. * Clamps the rgb values by the min and max values and stores the result into "result"
  60407. * @param min defines minimum clamping value (default is 0)
  60408. * @param max defines maximum clamping value (default is 1)
  60409. * @param result defines color to store the result into.
  60410. * @returns the cuurent Color4
  60411. */
  60412. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  60413. /**
  60414. * Multipy an Color4 value by another and return a new Color4 object
  60415. * @param color defines the Color4 value to multiply by
  60416. * @returns a new Color4 object
  60417. */
  60418. multiply(color: Color4): Color4;
  60419. /**
  60420. * Multipy a Color4 value by another and push the result in a reference value
  60421. * @param color defines the Color4 value to multiply by
  60422. * @param result defines the Color4 to fill the result in
  60423. * @returns the result Color4
  60424. */
  60425. multiplyToRef(color: Color4, result: Color4): Color4;
  60426. /**
  60427. * Creates a string with the Color4 current values
  60428. * @returns the string representation of the Color4 object
  60429. */
  60430. toString(): string;
  60431. /**
  60432. * Returns the string "Color4"
  60433. * @returns "Color4"
  60434. */
  60435. getClassName(): string;
  60436. /**
  60437. * Compute the Color4 hash code
  60438. * @returns an unique number that can be used to hash Color4 objects
  60439. */
  60440. getHashCode(): number;
  60441. /**
  60442. * Creates a new Color4 copied from the current one
  60443. * @returns a new Color4 object
  60444. */
  60445. clone(): Color4;
  60446. /**
  60447. * Copies the given Color4 values into the current one
  60448. * @param source defines the source Color4 object
  60449. * @returns the current updated Color4 object
  60450. */
  60451. copyFrom(source: Color4): Color4;
  60452. /**
  60453. * Copies the given float values into the current one
  60454. * @param r defines the red component to read from
  60455. * @param g defines the green component to read from
  60456. * @param b defines the blue component to read from
  60457. * @param a defines the alpha component to read from
  60458. * @returns the current updated Color4 object
  60459. */
  60460. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  60461. /**
  60462. * Copies the given float values into the current one
  60463. * @param r defines the red component to read from
  60464. * @param g defines the green component to read from
  60465. * @param b defines the blue component to read from
  60466. * @param a defines the alpha component to read from
  60467. * @returns the current updated Color4 object
  60468. */
  60469. set(r: number, g: number, b: number, a: number): Color4;
  60470. /**
  60471. * Compute the Color4 hexadecimal code as a string
  60472. * @returns a string containing the hexadecimal representation of the Color4 object
  60473. */
  60474. toHexString(): string;
  60475. /**
  60476. * Computes a new Color4 converted from the current one to linear space
  60477. * @returns a new Color4 object
  60478. */
  60479. toLinearSpace(): Color4;
  60480. /**
  60481. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  60482. * @param convertedColor defines the Color4 object where to store the linear space version
  60483. * @returns the unmodified Color4
  60484. */
  60485. toLinearSpaceToRef(convertedColor: Color4): Color4;
  60486. /**
  60487. * Computes a new Color4 converted from the current one to gamma space
  60488. * @returns a new Color4 object
  60489. */
  60490. toGammaSpace(): Color4;
  60491. /**
  60492. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  60493. * @param convertedColor defines the Color4 object where to store the gamma space version
  60494. * @returns the unmodified Color4
  60495. */
  60496. toGammaSpaceToRef(convertedColor: Color4): Color4;
  60497. /**
  60498. * Creates a new Color4 from the string containing valid hexadecimal values
  60499. * @param hex defines a string containing valid hexadecimal values
  60500. * @returns a new Color4 object
  60501. */
  60502. static FromHexString(hex: string): Color4;
  60503. /**
  60504. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60505. * @param left defines the start value
  60506. * @param right defines the end value
  60507. * @param amount defines the gradient factor
  60508. * @returns a new Color4 object
  60509. */
  60510. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  60511. /**
  60512. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60513. * @param left defines the start value
  60514. * @param right defines the end value
  60515. * @param amount defines the gradient factor
  60516. * @param result defines the Color4 object where to store data
  60517. */
  60518. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  60519. /**
  60520. * Creates a new Color4 from a Color3 and an alpha value
  60521. * @param color3 defines the source Color3 to read from
  60522. * @param alpha defines the alpha component (1.0 by default)
  60523. * @returns a new Color4 object
  60524. */
  60525. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  60526. /**
  60527. * Creates a new Color4 from the starting index element of the given array
  60528. * @param array defines the source array to read from
  60529. * @param offset defines the offset in the source array
  60530. * @returns a new Color4 object
  60531. */
  60532. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  60533. /**
  60534. * Creates a new Color3 from integer values (< 256)
  60535. * @param r defines the red component to read from (value between 0 and 255)
  60536. * @param g defines the green component to read from (value between 0 and 255)
  60537. * @param b defines the blue component to read from (value between 0 and 255)
  60538. * @param a defines the alpha component to read from (value between 0 and 255)
  60539. * @returns a new Color3 object
  60540. */
  60541. static FromInts(r: number, g: number, b: number, a: number): Color4;
  60542. /**
  60543. * Check the content of a given array and convert it to an array containing RGBA data
  60544. * If the original array was already containing count * 4 values then it is returned directly
  60545. * @param colors defines the array to check
  60546. * @param count defines the number of RGBA data to expect
  60547. * @returns an array containing count * 4 values (RGBA)
  60548. */
  60549. static CheckColors4(colors: number[], count: number): number[];
  60550. }
  60551. /**
  60552. * Class representing a vector containing 2 coordinates
  60553. */
  60554. export class Vector2 {
  60555. /** defines the first coordinate */
  60556. x: number;
  60557. /** defines the second coordinate */
  60558. y: number;
  60559. /**
  60560. * Creates a new Vector2 from the given x and y coordinates
  60561. * @param x defines the first coordinate
  60562. * @param y defines the second coordinate
  60563. */
  60564. constructor(
  60565. /** defines the first coordinate */
  60566. x?: number,
  60567. /** defines the second coordinate */
  60568. y?: number);
  60569. /**
  60570. * Gets a string with the Vector2 coordinates
  60571. * @returns a string with the Vector2 coordinates
  60572. */
  60573. toString(): string;
  60574. /**
  60575. * Gets class name
  60576. * @returns the string "Vector2"
  60577. */
  60578. getClassName(): string;
  60579. /**
  60580. * Gets current vector hash code
  60581. * @returns the Vector2 hash code as a number
  60582. */
  60583. getHashCode(): number;
  60584. /**
  60585. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  60586. * @param array defines the source array
  60587. * @param index defines the offset in source array
  60588. * @returns the current Vector2
  60589. */
  60590. toArray(array: FloatArray, index?: number): Vector2;
  60591. /**
  60592. * Copy the current vector to an array
  60593. * @returns a new array with 2 elements: the Vector2 coordinates.
  60594. */
  60595. asArray(): number[];
  60596. /**
  60597. * Sets the Vector2 coordinates with the given Vector2 coordinates
  60598. * @param source defines the source Vector2
  60599. * @returns the current updated Vector2
  60600. */
  60601. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  60602. /**
  60603. * Sets the Vector2 coordinates with the given floats
  60604. * @param x defines the first coordinate
  60605. * @param y defines the second coordinate
  60606. * @returns the current updated Vector2
  60607. */
  60608. copyFromFloats(x: number, y: number): Vector2;
  60609. /**
  60610. * Sets the Vector2 coordinates with the given floats
  60611. * @param x defines the first coordinate
  60612. * @param y defines the second coordinate
  60613. * @returns the current updated Vector2
  60614. */
  60615. set(x: number, y: number): Vector2;
  60616. /**
  60617. * Add another vector with the current one
  60618. * @param otherVector defines the other vector
  60619. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  60620. */
  60621. add(otherVector: DeepImmutable<Vector2>): Vector2;
  60622. /**
  60623. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  60624. * @param otherVector defines the other vector
  60625. * @param result defines the target vector
  60626. * @returns the unmodified current Vector2
  60627. */
  60628. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60629. /**
  60630. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  60631. * @param otherVector defines the other vector
  60632. * @returns the current updated Vector2
  60633. */
  60634. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60635. /**
  60636. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  60637. * @param otherVector defines the other vector
  60638. * @returns a new Vector2
  60639. */
  60640. addVector3(otherVector: Vector3): Vector2;
  60641. /**
  60642. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  60643. * @param otherVector defines the other vector
  60644. * @returns a new Vector2
  60645. */
  60646. subtract(otherVector: Vector2): Vector2;
  60647. /**
  60648. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  60649. * @param otherVector defines the other vector
  60650. * @param result defines the target vector
  60651. * @returns the unmodified current Vector2
  60652. */
  60653. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60654. /**
  60655. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  60656. * @param otherVector defines the other vector
  60657. * @returns the current updated Vector2
  60658. */
  60659. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60660. /**
  60661. * Multiplies in place the current Vector2 coordinates by the given ones
  60662. * @param otherVector defines the other vector
  60663. * @returns the current updated Vector2
  60664. */
  60665. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60666. /**
  60667. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  60668. * @param otherVector defines the other vector
  60669. * @returns a new Vector2
  60670. */
  60671. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  60672. /**
  60673. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  60674. * @param otherVector defines the other vector
  60675. * @param result defines the target vector
  60676. * @returns the unmodified current Vector2
  60677. */
  60678. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60679. /**
  60680. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  60681. * @param x defines the first coordinate
  60682. * @param y defines the second coordinate
  60683. * @returns a new Vector2
  60684. */
  60685. multiplyByFloats(x: number, y: number): Vector2;
  60686. /**
  60687. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  60688. * @param otherVector defines the other vector
  60689. * @returns a new Vector2
  60690. */
  60691. divide(otherVector: Vector2): Vector2;
  60692. /**
  60693. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  60694. * @param otherVector defines the other vector
  60695. * @param result defines the target vector
  60696. * @returns the unmodified current Vector2
  60697. */
  60698. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60699. /**
  60700. * Divides the current Vector2 coordinates by the given ones
  60701. * @param otherVector defines the other vector
  60702. * @returns the current updated Vector2
  60703. */
  60704. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60705. /**
  60706. * Gets a new Vector2 with current Vector2 negated coordinates
  60707. * @returns a new Vector2
  60708. */
  60709. negate(): Vector2;
  60710. /**
  60711. * Multiply the Vector2 coordinates by scale
  60712. * @param scale defines the scaling factor
  60713. * @returns the current updated Vector2
  60714. */
  60715. scaleInPlace(scale: number): Vector2;
  60716. /**
  60717. * Returns a new Vector2 scaled by "scale" from the current Vector2
  60718. * @param scale defines the scaling factor
  60719. * @returns a new Vector2
  60720. */
  60721. scale(scale: number): Vector2;
  60722. /**
  60723. * Scale the current Vector2 values by a factor to a given Vector2
  60724. * @param scale defines the scale factor
  60725. * @param result defines the Vector2 object where to store the result
  60726. * @returns the unmodified current Vector2
  60727. */
  60728. scaleToRef(scale: number, result: Vector2): Vector2;
  60729. /**
  60730. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  60731. * @param scale defines the scale factor
  60732. * @param result defines the Vector2 object where to store the result
  60733. * @returns the unmodified current Vector2
  60734. */
  60735. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  60736. /**
  60737. * Gets a boolean if two vectors are equals
  60738. * @param otherVector defines the other vector
  60739. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  60740. */
  60741. equals(otherVector: DeepImmutable<Vector2>): boolean;
  60742. /**
  60743. * Gets a boolean if two vectors are equals (using an epsilon value)
  60744. * @param otherVector defines the other vector
  60745. * @param epsilon defines the minimal distance to consider equality
  60746. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  60747. */
  60748. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  60749. /**
  60750. * Gets a new Vector2 from current Vector2 floored values
  60751. * @returns a new Vector2
  60752. */
  60753. floor(): Vector2;
  60754. /**
  60755. * Gets a new Vector2 from current Vector2 floored values
  60756. * @returns a new Vector2
  60757. */
  60758. fract(): Vector2;
  60759. /**
  60760. * Gets the length of the vector
  60761. * @returns the vector length (float)
  60762. */
  60763. length(): number;
  60764. /**
  60765. * Gets the vector squared length
  60766. * @returns the vector squared length (float)
  60767. */
  60768. lengthSquared(): number;
  60769. /**
  60770. * Normalize the vector
  60771. * @returns the current updated Vector2
  60772. */
  60773. normalize(): Vector2;
  60774. /**
  60775. * Gets a new Vector2 copied from the Vector2
  60776. * @returns a new Vector2
  60777. */
  60778. clone(): Vector2;
  60779. /**
  60780. * Gets a new Vector2(0, 0)
  60781. * @returns a new Vector2
  60782. */
  60783. static Zero(): Vector2;
  60784. /**
  60785. * Gets a new Vector2(1, 1)
  60786. * @returns a new Vector2
  60787. */
  60788. static One(): Vector2;
  60789. /**
  60790. * Gets a new Vector2 set from the given index element of the given array
  60791. * @param array defines the data source
  60792. * @param offset defines the offset in the data source
  60793. * @returns a new Vector2
  60794. */
  60795. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  60796. /**
  60797. * Sets "result" from the given index element of the given array
  60798. * @param array defines the data source
  60799. * @param offset defines the offset in the data source
  60800. * @param result defines the target vector
  60801. */
  60802. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  60803. /**
  60804. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  60805. * @param value1 defines 1st point of control
  60806. * @param value2 defines 2nd point of control
  60807. * @param value3 defines 3rd point of control
  60808. * @param value4 defines 4th point of control
  60809. * @param amount defines the interpolation factor
  60810. * @returns a new Vector2
  60811. */
  60812. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  60813. /**
  60814. * 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".
  60815. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  60816. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  60817. * @param value defines the value to clamp
  60818. * @param min defines the lower limit
  60819. * @param max defines the upper limit
  60820. * @returns a new Vector2
  60821. */
  60822. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  60823. /**
  60824. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  60825. * @param value1 defines the 1st control point
  60826. * @param tangent1 defines the outgoing tangent
  60827. * @param value2 defines the 2nd control point
  60828. * @param tangent2 defines the incoming tangent
  60829. * @param amount defines the interpolation factor
  60830. * @returns a new Vector2
  60831. */
  60832. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  60833. /**
  60834. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  60835. * @param start defines the start vector
  60836. * @param end defines the end vector
  60837. * @param amount defines the interpolation factor
  60838. * @returns a new Vector2
  60839. */
  60840. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  60841. /**
  60842. * Gets the dot product of the vector "left" and the vector "right"
  60843. * @param left defines first vector
  60844. * @param right defines second vector
  60845. * @returns the dot product (float)
  60846. */
  60847. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  60848. /**
  60849. * Returns a new Vector2 equal to the normalized given vector
  60850. * @param vector defines the vector to normalize
  60851. * @returns a new Vector2
  60852. */
  60853. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  60854. /**
  60855. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  60856. * @param left defines 1st vector
  60857. * @param right defines 2nd vector
  60858. * @returns a new Vector2
  60859. */
  60860. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  60861. /**
  60862. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  60863. * @param left defines 1st vector
  60864. * @param right defines 2nd vector
  60865. * @returns a new Vector2
  60866. */
  60867. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  60868. /**
  60869. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  60870. * @param vector defines the vector to transform
  60871. * @param transformation defines the matrix to apply
  60872. * @returns a new Vector2
  60873. */
  60874. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  60875. /**
  60876. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  60877. * @param vector defines the vector to transform
  60878. * @param transformation defines the matrix to apply
  60879. * @param result defines the target vector
  60880. */
  60881. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  60882. /**
  60883. * Determines if a given vector is included in a triangle
  60884. * @param p defines the vector to test
  60885. * @param p0 defines 1st triangle point
  60886. * @param p1 defines 2nd triangle point
  60887. * @param p2 defines 3rd triangle point
  60888. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  60889. */
  60890. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  60891. /**
  60892. * Gets the distance between the vectors "value1" and "value2"
  60893. * @param value1 defines first vector
  60894. * @param value2 defines second vector
  60895. * @returns the distance between vectors
  60896. */
  60897. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  60898. /**
  60899. * Returns the squared distance between the vectors "value1" and "value2"
  60900. * @param value1 defines first vector
  60901. * @param value2 defines second vector
  60902. * @returns the squared distance between vectors
  60903. */
  60904. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  60905. /**
  60906. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  60907. * @param value1 defines first vector
  60908. * @param value2 defines second vector
  60909. * @returns a new Vector2
  60910. */
  60911. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  60912. /**
  60913. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  60914. * @param p defines the middle point
  60915. * @param segA defines one point of the segment
  60916. * @param segB defines the other point of the segment
  60917. * @returns the shortest distance
  60918. */
  60919. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  60920. }
  60921. /**
  60922. * Classed used to store (x,y,z) vector representation
  60923. * A Vector3 is the main object used in 3D geometry
  60924. * It can represent etiher the coordinates of a point the space, either a direction
  60925. * Reminder: js uses a left handed forward facing system
  60926. */
  60927. export class Vector3 {
  60928. /**
  60929. * Defines the first coordinates (on X axis)
  60930. */
  60931. x: number;
  60932. /**
  60933. * Defines the second coordinates (on Y axis)
  60934. */
  60935. y: number;
  60936. /**
  60937. * Defines the third coordinates (on Z axis)
  60938. */
  60939. z: number;
  60940. private static _UpReadOnly;
  60941. /**
  60942. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  60943. * @param x defines the first coordinates (on X axis)
  60944. * @param y defines the second coordinates (on Y axis)
  60945. * @param z defines the third coordinates (on Z axis)
  60946. */
  60947. constructor(
  60948. /**
  60949. * Defines the first coordinates (on X axis)
  60950. */
  60951. x?: number,
  60952. /**
  60953. * Defines the second coordinates (on Y axis)
  60954. */
  60955. y?: number,
  60956. /**
  60957. * Defines the third coordinates (on Z axis)
  60958. */
  60959. z?: number);
  60960. /**
  60961. * Creates a string representation of the Vector3
  60962. * @returns a string with the Vector3 coordinates.
  60963. */
  60964. toString(): string;
  60965. /**
  60966. * Gets the class name
  60967. * @returns the string "Vector3"
  60968. */
  60969. getClassName(): string;
  60970. /**
  60971. * Creates the Vector3 hash code
  60972. * @returns a number which tends to be unique between Vector3 instances
  60973. */
  60974. getHashCode(): number;
  60975. /**
  60976. * Creates an array containing three elements : the coordinates of the Vector3
  60977. * @returns a new array of numbers
  60978. */
  60979. asArray(): number[];
  60980. /**
  60981. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  60982. * @param array defines the destination array
  60983. * @param index defines the offset in the destination array
  60984. * @returns the current Vector3
  60985. */
  60986. toArray(array: FloatArray, index?: number): Vector3;
  60987. /**
  60988. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  60989. * @returns a new Quaternion object, computed from the Vector3 coordinates
  60990. */
  60991. toQuaternion(): Quaternion;
  60992. /**
  60993. * Adds the given vector to the current Vector3
  60994. * @param otherVector defines the second operand
  60995. * @returns the current updated Vector3
  60996. */
  60997. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60998. /**
  60999. * Adds the given coordinates to the current Vector3
  61000. * @param x defines the x coordinate of the operand
  61001. * @param y defines the y coordinate of the operand
  61002. * @param z defines the z coordinate of the operand
  61003. * @returns the current updated Vector3
  61004. */
  61005. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61006. /**
  61007. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  61008. * @param otherVector defines the second operand
  61009. * @returns the resulting Vector3
  61010. */
  61011. add(otherVector: DeepImmutable<Vector3>): Vector3;
  61012. /**
  61013. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  61014. * @param otherVector defines the second operand
  61015. * @param result defines the Vector3 object where to store the result
  61016. * @returns the current Vector3
  61017. */
  61018. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61019. /**
  61020. * Subtract the given vector from the current Vector3
  61021. * @param otherVector defines the second operand
  61022. * @returns the current updated Vector3
  61023. */
  61024. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61025. /**
  61026. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  61027. * @param otherVector defines the second operand
  61028. * @returns the resulting Vector3
  61029. */
  61030. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  61031. /**
  61032. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  61033. * @param otherVector defines the second operand
  61034. * @param result defines the Vector3 object where to store the result
  61035. * @returns the current Vector3
  61036. */
  61037. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61038. /**
  61039. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  61040. * @param x defines the x coordinate of the operand
  61041. * @param y defines the y coordinate of the operand
  61042. * @param z defines the z coordinate of the operand
  61043. * @returns the resulting Vector3
  61044. */
  61045. subtractFromFloats(x: number, y: number, z: number): Vector3;
  61046. /**
  61047. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  61048. * @param x defines the x coordinate of the operand
  61049. * @param y defines the y coordinate of the operand
  61050. * @param z defines the z coordinate of the operand
  61051. * @param result defines the Vector3 object where to store the result
  61052. * @returns the current Vector3
  61053. */
  61054. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  61055. /**
  61056. * Gets a new Vector3 set with the current Vector3 negated coordinates
  61057. * @returns a new Vector3
  61058. */
  61059. negate(): Vector3;
  61060. /**
  61061. * Multiplies the Vector3 coordinates by the float "scale"
  61062. * @param scale defines the multiplier factor
  61063. * @returns the current updated Vector3
  61064. */
  61065. scaleInPlace(scale: number): Vector3;
  61066. /**
  61067. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  61068. * @param scale defines the multiplier factor
  61069. * @returns a new Vector3
  61070. */
  61071. scale(scale: number): Vector3;
  61072. /**
  61073. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  61074. * @param scale defines the multiplier factor
  61075. * @param result defines the Vector3 object where to store the result
  61076. * @returns the current Vector3
  61077. */
  61078. scaleToRef(scale: number, result: Vector3): Vector3;
  61079. /**
  61080. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  61081. * @param scale defines the scale factor
  61082. * @param result defines the Vector3 object where to store the result
  61083. * @returns the unmodified current Vector3
  61084. */
  61085. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  61086. /**
  61087. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  61088. * @param otherVector defines the second operand
  61089. * @returns true if both vectors are equals
  61090. */
  61091. equals(otherVector: DeepImmutable<Vector3>): boolean;
  61092. /**
  61093. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  61094. * @param otherVector defines the second operand
  61095. * @param epsilon defines the minimal distance to define values as equals
  61096. * @returns true if both vectors are distant less than epsilon
  61097. */
  61098. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  61099. /**
  61100. * Returns true if the current Vector3 coordinates equals the given floats
  61101. * @param x defines the x coordinate of the operand
  61102. * @param y defines the y coordinate of the operand
  61103. * @param z defines the z coordinate of the operand
  61104. * @returns true if both vectors are equals
  61105. */
  61106. equalsToFloats(x: number, y: number, z: number): boolean;
  61107. /**
  61108. * Multiplies the current Vector3 coordinates by the given ones
  61109. * @param otherVector defines the second operand
  61110. * @returns the current updated Vector3
  61111. */
  61112. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61113. /**
  61114. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  61115. * @param otherVector defines the second operand
  61116. * @returns the new Vector3
  61117. */
  61118. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  61119. /**
  61120. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  61121. * @param otherVector defines the second operand
  61122. * @param result defines the Vector3 object where to store the result
  61123. * @returns the current Vector3
  61124. */
  61125. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61126. /**
  61127. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  61128. * @param x defines the x coordinate of the operand
  61129. * @param y defines the y coordinate of the operand
  61130. * @param z defines the z coordinate of the operand
  61131. * @returns the new Vector3
  61132. */
  61133. multiplyByFloats(x: number, y: number, z: number): Vector3;
  61134. /**
  61135. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  61136. * @param otherVector defines the second operand
  61137. * @returns the new Vector3
  61138. */
  61139. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  61140. /**
  61141. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  61142. * @param otherVector defines the second operand
  61143. * @param result defines the Vector3 object where to store the result
  61144. * @returns the current Vector3
  61145. */
  61146. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61147. /**
  61148. * Divides the current Vector3 coordinates by the given ones.
  61149. * @param otherVector defines the second operand
  61150. * @returns the current updated Vector3
  61151. */
  61152. divideInPlace(otherVector: Vector3): Vector3;
  61153. /**
  61154. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  61155. * @param other defines the second operand
  61156. * @returns the current updated Vector3
  61157. */
  61158. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  61159. /**
  61160. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  61161. * @param other defines the second operand
  61162. * @returns the current updated Vector3
  61163. */
  61164. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  61165. /**
  61166. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  61167. * @param x defines the x coordinate of the operand
  61168. * @param y defines the y coordinate of the operand
  61169. * @param z defines the z coordinate of the operand
  61170. * @returns the current updated Vector3
  61171. */
  61172. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61173. /**
  61174. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  61175. * @param x defines the x coordinate of the operand
  61176. * @param y defines the y coordinate of the operand
  61177. * @param z defines the z coordinate of the operand
  61178. * @returns the current updated Vector3
  61179. */
  61180. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61181. /**
  61182. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  61183. * Check if is non uniform within a certain amount of decimal places to account for this
  61184. * @param epsilon the amount the values can differ
  61185. * @returns if the the vector is non uniform to a certain number of decimal places
  61186. */
  61187. isNonUniformWithinEpsilon(epsilon: number): boolean;
  61188. /**
  61189. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  61190. */
  61191. readonly isNonUniform: boolean;
  61192. /**
  61193. * Gets a new Vector3 from current Vector3 floored values
  61194. * @returns a new Vector3
  61195. */
  61196. floor(): Vector3;
  61197. /**
  61198. * Gets a new Vector3 from current Vector3 floored values
  61199. * @returns a new Vector3
  61200. */
  61201. fract(): Vector3;
  61202. /**
  61203. * Gets the length of the Vector3
  61204. * @returns the length of the Vecto3
  61205. */
  61206. length(): number;
  61207. /**
  61208. * Gets the squared length of the Vector3
  61209. * @returns squared length of the Vector3
  61210. */
  61211. lengthSquared(): number;
  61212. /**
  61213. * Normalize the current Vector3.
  61214. * Please note that this is an in place operation.
  61215. * @returns the current updated Vector3
  61216. */
  61217. normalize(): Vector3;
  61218. /**
  61219. * Reorders the x y z properties of the vector in place
  61220. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  61221. * @returns the current updated vector
  61222. */
  61223. reorderInPlace(order: string): this;
  61224. /**
  61225. * Rotates the vector around 0,0,0 by a quaternion
  61226. * @param quaternion the rotation quaternion
  61227. * @param result vector to store the result
  61228. * @returns the resulting vector
  61229. */
  61230. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  61231. /**
  61232. * Rotates a vector around a given point
  61233. * @param quaternion the rotation quaternion
  61234. * @param point the point to rotate around
  61235. * @param result vector to store the result
  61236. * @returns the resulting vector
  61237. */
  61238. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  61239. /**
  61240. * Normalize the current Vector3 with the given input length.
  61241. * Please note that this is an in place operation.
  61242. * @param len the length of the vector
  61243. * @returns the current updated Vector3
  61244. */
  61245. normalizeFromLength(len: number): Vector3;
  61246. /**
  61247. * Normalize the current Vector3 to a new vector
  61248. * @returns the new Vector3
  61249. */
  61250. normalizeToNew(): Vector3;
  61251. /**
  61252. * Normalize the current Vector3 to the reference
  61253. * @param reference define the Vector3 to update
  61254. * @returns the updated Vector3
  61255. */
  61256. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  61257. /**
  61258. * Creates a new Vector3 copied from the current Vector3
  61259. * @returns the new Vector3
  61260. */
  61261. clone(): Vector3;
  61262. /**
  61263. * Copies the given vector coordinates to the current Vector3 ones
  61264. * @param source defines the source Vector3
  61265. * @returns the current updated Vector3
  61266. */
  61267. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  61268. /**
  61269. * Copies the given floats to the current Vector3 coordinates
  61270. * @param x defines the x coordinate of the operand
  61271. * @param y defines the y coordinate of the operand
  61272. * @param z defines the z coordinate of the operand
  61273. * @returns the current updated Vector3
  61274. */
  61275. copyFromFloats(x: number, y: number, z: number): Vector3;
  61276. /**
  61277. * Copies the given floats to the current Vector3 coordinates
  61278. * @param x defines the x coordinate of the operand
  61279. * @param y defines the y coordinate of the operand
  61280. * @param z defines the z coordinate of the operand
  61281. * @returns the current updated Vector3
  61282. */
  61283. set(x: number, y: number, z: number): Vector3;
  61284. /**
  61285. * Copies the given float to the current Vector3 coordinates
  61286. * @param v defines the x, y and z coordinates of the operand
  61287. * @returns the current updated Vector3
  61288. */
  61289. setAll(v: number): Vector3;
  61290. /**
  61291. * Get the clip factor between two vectors
  61292. * @param vector0 defines the first operand
  61293. * @param vector1 defines the second operand
  61294. * @param axis defines the axis to use
  61295. * @param size defines the size along the axis
  61296. * @returns the clip factor
  61297. */
  61298. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  61299. /**
  61300. * Get angle between two vectors
  61301. * @param vector0 angle between vector0 and vector1
  61302. * @param vector1 angle between vector0 and vector1
  61303. * @param normal direction of the normal
  61304. * @return the angle between vector0 and vector1
  61305. */
  61306. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  61307. /**
  61308. * Returns a new Vector3 set from the index "offset" of the given array
  61309. * @param array defines the source array
  61310. * @param offset defines the offset in the source array
  61311. * @returns the new Vector3
  61312. */
  61313. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  61314. /**
  61315. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  61316. * This function is deprecated. Use FromArray instead
  61317. * @param array defines the source array
  61318. * @param offset defines the offset in the source array
  61319. * @returns the new Vector3
  61320. */
  61321. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  61322. /**
  61323. * Sets the given vector "result" with the element values from the index "offset" of the given array
  61324. * @param array defines the source array
  61325. * @param offset defines the offset in the source array
  61326. * @param result defines the Vector3 where to store the result
  61327. */
  61328. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  61329. /**
  61330. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  61331. * This function is deprecated. Use FromArrayToRef instead.
  61332. * @param array defines the source array
  61333. * @param offset defines the offset in the source array
  61334. * @param result defines the Vector3 where to store the result
  61335. */
  61336. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  61337. /**
  61338. * Sets the given vector "result" with the given floats.
  61339. * @param x defines the x coordinate of the source
  61340. * @param y defines the y coordinate of the source
  61341. * @param z defines the z coordinate of the source
  61342. * @param result defines the Vector3 where to store the result
  61343. */
  61344. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  61345. /**
  61346. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  61347. * @returns a new empty Vector3
  61348. */
  61349. static Zero(): Vector3;
  61350. /**
  61351. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  61352. * @returns a new unit Vector3
  61353. */
  61354. static One(): Vector3;
  61355. /**
  61356. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  61357. * @returns a new up Vector3
  61358. */
  61359. static Up(): Vector3;
  61360. /**
  61361. * Gets a up Vector3 that must not be updated
  61362. */
  61363. static readonly UpReadOnly: DeepImmutable<Vector3>;
  61364. /**
  61365. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  61366. * @returns a new down Vector3
  61367. */
  61368. static Down(): Vector3;
  61369. /**
  61370. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  61371. * @returns a new forward Vector3
  61372. */
  61373. static Forward(): Vector3;
  61374. /**
  61375. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  61376. * @returns a new forward Vector3
  61377. */
  61378. static Backward(): Vector3;
  61379. /**
  61380. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  61381. * @returns a new right Vector3
  61382. */
  61383. static Right(): Vector3;
  61384. /**
  61385. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  61386. * @returns a new left Vector3
  61387. */
  61388. static Left(): Vector3;
  61389. /**
  61390. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  61391. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61392. * @param vector defines the Vector3 to transform
  61393. * @param transformation defines the transformation matrix
  61394. * @returns the transformed Vector3
  61395. */
  61396. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61397. /**
  61398. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  61399. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61400. * @param vector defines the Vector3 to transform
  61401. * @param transformation defines the transformation matrix
  61402. * @param result defines the Vector3 where to store the result
  61403. */
  61404. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61405. /**
  61406. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  61407. * This method computes tranformed coordinates only, not transformed direction vectors
  61408. * @param x define the x coordinate of the source vector
  61409. * @param y define the y coordinate of the source vector
  61410. * @param z define the z coordinate of the source vector
  61411. * @param transformation defines the transformation matrix
  61412. * @param result defines the Vector3 where to store the result
  61413. */
  61414. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61415. /**
  61416. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  61417. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61418. * @param vector defines the Vector3 to transform
  61419. * @param transformation defines the transformation matrix
  61420. * @returns the new Vector3
  61421. */
  61422. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61423. /**
  61424. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  61425. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61426. * @param vector defines the Vector3 to transform
  61427. * @param transformation defines the transformation matrix
  61428. * @param result defines the Vector3 where to store the result
  61429. */
  61430. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61431. /**
  61432. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  61433. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61434. * @param x define the x coordinate of the source vector
  61435. * @param y define the y coordinate of the source vector
  61436. * @param z define the z coordinate of the source vector
  61437. * @param transformation defines the transformation matrix
  61438. * @param result defines the Vector3 where to store the result
  61439. */
  61440. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61441. /**
  61442. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  61443. * @param value1 defines the first control point
  61444. * @param value2 defines the second control point
  61445. * @param value3 defines the third control point
  61446. * @param value4 defines the fourth control point
  61447. * @param amount defines the amount on the spline to use
  61448. * @returns the new Vector3
  61449. */
  61450. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  61451. /**
  61452. * 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"
  61453. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61454. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61455. * @param value defines the current value
  61456. * @param min defines the lower range value
  61457. * @param max defines the upper range value
  61458. * @returns the new Vector3
  61459. */
  61460. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  61461. /**
  61462. * 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"
  61463. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61464. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61465. * @param value defines the current value
  61466. * @param min defines the lower range value
  61467. * @param max defines the upper range value
  61468. * @param result defines the Vector3 where to store the result
  61469. */
  61470. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  61471. /**
  61472. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  61473. * @param value1 defines the first control point
  61474. * @param tangent1 defines the first tangent vector
  61475. * @param value2 defines the second control point
  61476. * @param tangent2 defines the second tangent vector
  61477. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  61478. * @returns the new Vector3
  61479. */
  61480. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  61481. /**
  61482. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  61483. * @param start defines the start value
  61484. * @param end defines the end value
  61485. * @param amount max defines amount between both (between 0 and 1)
  61486. * @returns the new Vector3
  61487. */
  61488. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  61489. /**
  61490. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  61491. * @param start defines the start value
  61492. * @param end defines the end value
  61493. * @param amount max defines amount between both (between 0 and 1)
  61494. * @param result defines the Vector3 where to store the result
  61495. */
  61496. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  61497. /**
  61498. * Returns the dot product (float) between the vectors "left" and "right"
  61499. * @param left defines the left operand
  61500. * @param right defines the right operand
  61501. * @returns the dot product
  61502. */
  61503. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  61504. /**
  61505. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  61506. * The cross product is then orthogonal to both "left" and "right"
  61507. * @param left defines the left operand
  61508. * @param right defines the right operand
  61509. * @returns the cross product
  61510. */
  61511. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61512. /**
  61513. * Sets the given vector "result" with the cross product of "left" and "right"
  61514. * The cross product is then orthogonal to both "left" and "right"
  61515. * @param left defines the left operand
  61516. * @param right defines the right operand
  61517. * @param result defines the Vector3 where to store the result
  61518. */
  61519. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  61520. /**
  61521. * Returns a new Vector3 as the normalization of the given vector
  61522. * @param vector defines the Vector3 to normalize
  61523. * @returns the new Vector3
  61524. */
  61525. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  61526. /**
  61527. * Sets the given vector "result" with the normalization of the given first vector
  61528. * @param vector defines the Vector3 to normalize
  61529. * @param result defines the Vector3 where to store the result
  61530. */
  61531. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  61532. /**
  61533. * Project a Vector3 onto screen space
  61534. * @param vector defines the Vector3 to project
  61535. * @param world defines the world matrix to use
  61536. * @param transform defines the transform (view x projection) matrix to use
  61537. * @param viewport defines the screen viewport to use
  61538. * @returns the new Vector3
  61539. */
  61540. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  61541. /** @hidden */
  61542. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  61543. /**
  61544. * Unproject from screen space to object space
  61545. * @param source defines the screen space Vector3 to use
  61546. * @param viewportWidth defines the current width of the viewport
  61547. * @param viewportHeight defines the current height of the viewport
  61548. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61549. * @param transform defines the transform (view x projection) matrix to use
  61550. * @returns the new Vector3
  61551. */
  61552. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  61553. /**
  61554. * Unproject from screen space to object space
  61555. * @param source defines the screen space Vector3 to use
  61556. * @param viewportWidth defines the current width of the viewport
  61557. * @param viewportHeight defines the current height of the viewport
  61558. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61559. * @param view defines the view matrix to use
  61560. * @param projection defines the projection matrix to use
  61561. * @returns the new Vector3
  61562. */
  61563. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  61564. /**
  61565. * Unproject from screen space to object space
  61566. * @param source defines the screen space Vector3 to use
  61567. * @param viewportWidth defines the current width of the viewport
  61568. * @param viewportHeight defines the current height of the viewport
  61569. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61570. * @param view defines the view matrix to use
  61571. * @param projection defines the projection matrix to use
  61572. * @param result defines the Vector3 where to store the result
  61573. */
  61574. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61575. /**
  61576. * Unproject from screen space to object space
  61577. * @param sourceX defines the screen space x coordinate to use
  61578. * @param sourceY defines the screen space y coordinate to use
  61579. * @param sourceZ defines the screen space z coordinate to use
  61580. * @param viewportWidth defines the current width of the viewport
  61581. * @param viewportHeight defines the current height of the viewport
  61582. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61583. * @param view defines the view matrix to use
  61584. * @param projection defines the projection matrix to use
  61585. * @param result defines the Vector3 where to store the result
  61586. */
  61587. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61588. /**
  61589. * Gets the minimal coordinate values between two Vector3
  61590. * @param left defines the first operand
  61591. * @param right defines the second operand
  61592. * @returns the new Vector3
  61593. */
  61594. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61595. /**
  61596. * Gets the maximal coordinate values between two Vector3
  61597. * @param left defines the first operand
  61598. * @param right defines the second operand
  61599. * @returns the new Vector3
  61600. */
  61601. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61602. /**
  61603. * Returns the distance between the vectors "value1" and "value2"
  61604. * @param value1 defines the first operand
  61605. * @param value2 defines the second operand
  61606. * @returns the distance
  61607. */
  61608. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61609. /**
  61610. * Returns the squared distance between the vectors "value1" and "value2"
  61611. * @param value1 defines the first operand
  61612. * @param value2 defines the second operand
  61613. * @returns the squared distance
  61614. */
  61615. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61616. /**
  61617. * Returns a new Vector3 located at the center between "value1" and "value2"
  61618. * @param value1 defines the first operand
  61619. * @param value2 defines the second operand
  61620. * @returns the new Vector3
  61621. */
  61622. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  61623. /**
  61624. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  61625. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  61626. * to something in order to rotate it from its local system to the given target system
  61627. * Note: axis1, axis2 and axis3 are normalized during this operation
  61628. * @param axis1 defines the first axis
  61629. * @param axis2 defines the second axis
  61630. * @param axis3 defines the third axis
  61631. * @returns a new Vector3
  61632. */
  61633. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  61634. /**
  61635. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  61636. * @param axis1 defines the first axis
  61637. * @param axis2 defines the second axis
  61638. * @param axis3 defines the third axis
  61639. * @param ref defines the Vector3 where to store the result
  61640. */
  61641. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  61642. }
  61643. /**
  61644. * Vector4 class created for EulerAngle class conversion to Quaternion
  61645. */
  61646. export class Vector4 {
  61647. /** x value of the vector */
  61648. x: number;
  61649. /** y value of the vector */
  61650. y: number;
  61651. /** z value of the vector */
  61652. z: number;
  61653. /** w value of the vector */
  61654. w: number;
  61655. /**
  61656. * Creates a Vector4 object from the given floats.
  61657. * @param x x value of the vector
  61658. * @param y y value of the vector
  61659. * @param z z value of the vector
  61660. * @param w w value of the vector
  61661. */
  61662. constructor(
  61663. /** x value of the vector */
  61664. x: number,
  61665. /** y value of the vector */
  61666. y: number,
  61667. /** z value of the vector */
  61668. z: number,
  61669. /** w value of the vector */
  61670. w: number);
  61671. /**
  61672. * Returns the string with the Vector4 coordinates.
  61673. * @returns a string containing all the vector values
  61674. */
  61675. toString(): string;
  61676. /**
  61677. * Returns the string "Vector4".
  61678. * @returns "Vector4"
  61679. */
  61680. getClassName(): string;
  61681. /**
  61682. * Returns the Vector4 hash code.
  61683. * @returns a unique hash code
  61684. */
  61685. getHashCode(): number;
  61686. /**
  61687. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  61688. * @returns the resulting array
  61689. */
  61690. asArray(): number[];
  61691. /**
  61692. * Populates the given array from the given index with the Vector4 coordinates.
  61693. * @param array array to populate
  61694. * @param index index of the array to start at (default: 0)
  61695. * @returns the Vector4.
  61696. */
  61697. toArray(array: FloatArray, index?: number): Vector4;
  61698. /**
  61699. * Adds the given vector to the current Vector4.
  61700. * @param otherVector the vector to add
  61701. * @returns the updated Vector4.
  61702. */
  61703. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61704. /**
  61705. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  61706. * @param otherVector the vector to add
  61707. * @returns the resulting vector
  61708. */
  61709. add(otherVector: DeepImmutable<Vector4>): Vector4;
  61710. /**
  61711. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  61712. * @param otherVector the vector to add
  61713. * @param result the vector to store the result
  61714. * @returns the current Vector4.
  61715. */
  61716. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61717. /**
  61718. * Subtract in place the given vector from the current Vector4.
  61719. * @param otherVector the vector to subtract
  61720. * @returns the updated Vector4.
  61721. */
  61722. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61723. /**
  61724. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  61725. * @param otherVector the vector to add
  61726. * @returns the new vector with the result
  61727. */
  61728. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  61729. /**
  61730. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  61731. * @param otherVector the vector to subtract
  61732. * @param result the vector to store the result
  61733. * @returns the current Vector4.
  61734. */
  61735. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61736. /**
  61737. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61738. */
  61739. /**
  61740. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61741. * @param x value to subtract
  61742. * @param y value to subtract
  61743. * @param z value to subtract
  61744. * @param w value to subtract
  61745. * @returns new vector containing the result
  61746. */
  61747. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61748. /**
  61749. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61750. * @param x value to subtract
  61751. * @param y value to subtract
  61752. * @param z value to subtract
  61753. * @param w value to subtract
  61754. * @param result the vector to store the result in
  61755. * @returns the current Vector4.
  61756. */
  61757. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  61758. /**
  61759. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  61760. * @returns a new vector with the negated values
  61761. */
  61762. negate(): Vector4;
  61763. /**
  61764. * Multiplies the current Vector4 coordinates by scale (float).
  61765. * @param scale the number to scale with
  61766. * @returns the updated Vector4.
  61767. */
  61768. scaleInPlace(scale: number): Vector4;
  61769. /**
  61770. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  61771. * @param scale the number to scale with
  61772. * @returns a new vector with the result
  61773. */
  61774. scale(scale: number): Vector4;
  61775. /**
  61776. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  61777. * @param scale the number to scale with
  61778. * @param result a vector to store the result in
  61779. * @returns the current Vector4.
  61780. */
  61781. scaleToRef(scale: number, result: Vector4): Vector4;
  61782. /**
  61783. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  61784. * @param scale defines the scale factor
  61785. * @param result defines the Vector4 object where to store the result
  61786. * @returns the unmodified current Vector4
  61787. */
  61788. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  61789. /**
  61790. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  61791. * @param otherVector the vector to compare against
  61792. * @returns true if they are equal
  61793. */
  61794. equals(otherVector: DeepImmutable<Vector4>): boolean;
  61795. /**
  61796. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  61797. * @param otherVector vector to compare against
  61798. * @param epsilon (Default: very small number)
  61799. * @returns true if they are equal
  61800. */
  61801. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  61802. /**
  61803. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  61804. * @param x x value to compare against
  61805. * @param y y value to compare against
  61806. * @param z z value to compare against
  61807. * @param w w value to compare against
  61808. * @returns true if equal
  61809. */
  61810. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  61811. /**
  61812. * Multiplies in place the current Vector4 by the given one.
  61813. * @param otherVector vector to multiple with
  61814. * @returns the updated Vector4.
  61815. */
  61816. multiplyInPlace(otherVector: Vector4): Vector4;
  61817. /**
  61818. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  61819. * @param otherVector vector to multiple with
  61820. * @returns resulting new vector
  61821. */
  61822. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  61823. /**
  61824. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  61825. * @param otherVector vector to multiple with
  61826. * @param result vector to store the result
  61827. * @returns the current Vector4.
  61828. */
  61829. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61830. /**
  61831. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  61832. * @param x x value multiply with
  61833. * @param y y value multiply with
  61834. * @param z z value multiply with
  61835. * @param w w value multiply with
  61836. * @returns resulting new vector
  61837. */
  61838. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  61839. /**
  61840. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  61841. * @param otherVector vector to devide with
  61842. * @returns resulting new vector
  61843. */
  61844. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  61845. /**
  61846. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  61847. * @param otherVector vector to devide with
  61848. * @param result vector to store the result
  61849. * @returns the current Vector4.
  61850. */
  61851. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61852. /**
  61853. * Divides the current Vector3 coordinates by the given ones.
  61854. * @param otherVector vector to devide with
  61855. * @returns the updated Vector3.
  61856. */
  61857. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61858. /**
  61859. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  61860. * @param other defines the second operand
  61861. * @returns the current updated Vector4
  61862. */
  61863. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  61864. /**
  61865. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  61866. * @param other defines the second operand
  61867. * @returns the current updated Vector4
  61868. */
  61869. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  61870. /**
  61871. * Gets a new Vector4 from current Vector4 floored values
  61872. * @returns a new Vector4
  61873. */
  61874. floor(): Vector4;
  61875. /**
  61876. * Gets a new Vector4 from current Vector3 floored values
  61877. * @returns a new Vector4
  61878. */
  61879. fract(): Vector4;
  61880. /**
  61881. * Returns the Vector4 length (float).
  61882. * @returns the length
  61883. */
  61884. length(): number;
  61885. /**
  61886. * Returns the Vector4 squared length (float).
  61887. * @returns the length squared
  61888. */
  61889. lengthSquared(): number;
  61890. /**
  61891. * Normalizes in place the Vector4.
  61892. * @returns the updated Vector4.
  61893. */
  61894. normalize(): Vector4;
  61895. /**
  61896. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  61897. * @returns this converted to a new vector3
  61898. */
  61899. toVector3(): Vector3;
  61900. /**
  61901. * Returns a new Vector4 copied from the current one.
  61902. * @returns the new cloned vector
  61903. */
  61904. clone(): Vector4;
  61905. /**
  61906. * Updates the current Vector4 with the given one coordinates.
  61907. * @param source the source vector to copy from
  61908. * @returns the updated Vector4.
  61909. */
  61910. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  61911. /**
  61912. * Updates the current Vector4 coordinates with the given floats.
  61913. * @param x float to copy from
  61914. * @param y float to copy from
  61915. * @param z float to copy from
  61916. * @param w float to copy from
  61917. * @returns the updated Vector4.
  61918. */
  61919. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61920. /**
  61921. * Updates the current Vector4 coordinates with the given floats.
  61922. * @param x float to set from
  61923. * @param y float to set from
  61924. * @param z float to set from
  61925. * @param w float to set from
  61926. * @returns the updated Vector4.
  61927. */
  61928. set(x: number, y: number, z: number, w: number): Vector4;
  61929. /**
  61930. * Copies the given float to the current Vector3 coordinates
  61931. * @param v defines the x, y, z and w coordinates of the operand
  61932. * @returns the current updated Vector3
  61933. */
  61934. setAll(v: number): Vector4;
  61935. /**
  61936. * Returns a new Vector4 set from the starting index of the given array.
  61937. * @param array the array to pull values from
  61938. * @param offset the offset into the array to start at
  61939. * @returns the new vector
  61940. */
  61941. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  61942. /**
  61943. * Updates the given vector "result" from the starting index of the given array.
  61944. * @param array the array to pull values from
  61945. * @param offset the offset into the array to start at
  61946. * @param result the vector to store the result in
  61947. */
  61948. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  61949. /**
  61950. * Updates the given vector "result" from the starting index of the given Float32Array.
  61951. * @param array the array to pull values from
  61952. * @param offset the offset into the array to start at
  61953. * @param result the vector to store the result in
  61954. */
  61955. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  61956. /**
  61957. * Updates the given vector "result" coordinates from the given floats.
  61958. * @param x float to set from
  61959. * @param y float to set from
  61960. * @param z float to set from
  61961. * @param w float to set from
  61962. * @param result the vector to the floats in
  61963. */
  61964. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  61965. /**
  61966. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  61967. * @returns the new vector
  61968. */
  61969. static Zero(): Vector4;
  61970. /**
  61971. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  61972. * @returns the new vector
  61973. */
  61974. static One(): Vector4;
  61975. /**
  61976. * Returns a new normalized Vector4 from the given one.
  61977. * @param vector the vector to normalize
  61978. * @returns the vector
  61979. */
  61980. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  61981. /**
  61982. * Updates the given vector "result" from the normalization of the given one.
  61983. * @param vector the vector to normalize
  61984. * @param result the vector to store the result in
  61985. */
  61986. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  61987. /**
  61988. * Returns a vector with the minimum values from the left and right vectors
  61989. * @param left left vector to minimize
  61990. * @param right right vector to minimize
  61991. * @returns a new vector with the minimum of the left and right vector values
  61992. */
  61993. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  61994. /**
  61995. * Returns a vector with the maximum values from the left and right vectors
  61996. * @param left left vector to maximize
  61997. * @param right right vector to maximize
  61998. * @returns a new vector with the maximum of the left and right vector values
  61999. */
  62000. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  62001. /**
  62002. * Returns the distance (float) between the vectors "value1" and "value2".
  62003. * @param value1 value to calulate the distance between
  62004. * @param value2 value to calulate the distance between
  62005. * @return the distance between the two vectors
  62006. */
  62007. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  62008. /**
  62009. * Returns the squared distance (float) between the vectors "value1" and "value2".
  62010. * @param value1 value to calulate the distance between
  62011. * @param value2 value to calulate the distance between
  62012. * @return the distance between the two vectors squared
  62013. */
  62014. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  62015. /**
  62016. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  62017. * @param value1 value to calulate the center between
  62018. * @param value2 value to calulate the center between
  62019. * @return the center between the two vectors
  62020. */
  62021. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  62022. /**
  62023. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  62024. * This methods computes transformed normalized direction vectors only.
  62025. * @param vector the vector to transform
  62026. * @param transformation the transformation matrix to apply
  62027. * @returns the new vector
  62028. */
  62029. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  62030. /**
  62031. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  62032. * This methods computes transformed normalized direction vectors only.
  62033. * @param vector the vector to transform
  62034. * @param transformation the transformation matrix to apply
  62035. * @param result the vector to store the result in
  62036. */
  62037. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  62038. /**
  62039. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  62040. * This methods computes transformed normalized direction vectors only.
  62041. * @param x value to transform
  62042. * @param y value to transform
  62043. * @param z value to transform
  62044. * @param w value to transform
  62045. * @param transformation the transformation matrix to apply
  62046. * @param result the vector to store the results in
  62047. */
  62048. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  62049. /**
  62050. * Creates a new Vector4 from a Vector3
  62051. * @param source defines the source data
  62052. * @param w defines the 4th component (default is 0)
  62053. * @returns a new Vector4
  62054. */
  62055. static FromVector3(source: Vector3, w?: number): Vector4;
  62056. }
  62057. /**
  62058. * Interface for the size containing width and height
  62059. */
  62060. export interface ISize {
  62061. /**
  62062. * Width
  62063. */
  62064. width: number;
  62065. /**
  62066. * Heighht
  62067. */
  62068. height: number;
  62069. }
  62070. /**
  62071. * Size containing widht and height
  62072. */
  62073. export class Size implements ISize {
  62074. /**
  62075. * Width
  62076. */
  62077. width: number;
  62078. /**
  62079. * Height
  62080. */
  62081. height: number;
  62082. /**
  62083. * Creates a Size object from the given width and height (floats).
  62084. * @param width width of the new size
  62085. * @param height height of the new size
  62086. */
  62087. constructor(width: number, height: number);
  62088. /**
  62089. * Returns a string with the Size width and height
  62090. * @returns a string with the Size width and height
  62091. */
  62092. toString(): string;
  62093. /**
  62094. * "Size"
  62095. * @returns the string "Size"
  62096. */
  62097. getClassName(): string;
  62098. /**
  62099. * Returns the Size hash code.
  62100. * @returns a hash code for a unique width and height
  62101. */
  62102. getHashCode(): number;
  62103. /**
  62104. * Updates the current size from the given one.
  62105. * @param src the given size
  62106. */
  62107. copyFrom(src: Size): void;
  62108. /**
  62109. * Updates in place the current Size from the given floats.
  62110. * @param width width of the new size
  62111. * @param height height of the new size
  62112. * @returns the updated Size.
  62113. */
  62114. copyFromFloats(width: number, height: number): Size;
  62115. /**
  62116. * Updates in place the current Size from the given floats.
  62117. * @param width width to set
  62118. * @param height height to set
  62119. * @returns the updated Size.
  62120. */
  62121. set(width: number, height: number): Size;
  62122. /**
  62123. * Multiplies the width and height by numbers
  62124. * @param w factor to multiple the width by
  62125. * @param h factor to multiple the height by
  62126. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  62127. */
  62128. multiplyByFloats(w: number, h: number): Size;
  62129. /**
  62130. * Clones the size
  62131. * @returns a new Size copied from the given one.
  62132. */
  62133. clone(): Size;
  62134. /**
  62135. * True if the current Size and the given one width and height are strictly equal.
  62136. * @param other the other size to compare against
  62137. * @returns True if the current Size and the given one width and height are strictly equal.
  62138. */
  62139. equals(other: Size): boolean;
  62140. /**
  62141. * The surface of the Size : width * height (float).
  62142. */
  62143. readonly surface: number;
  62144. /**
  62145. * Create a new size of zero
  62146. * @returns a new Size set to (0.0, 0.0)
  62147. */
  62148. static Zero(): Size;
  62149. /**
  62150. * Sums the width and height of two sizes
  62151. * @param otherSize size to add to this size
  62152. * @returns a new Size set as the addition result of the current Size and the given one.
  62153. */
  62154. add(otherSize: Size): Size;
  62155. /**
  62156. * Subtracts the width and height of two
  62157. * @param otherSize size to subtract to this size
  62158. * @returns a new Size set as the subtraction result of the given one from the current Size.
  62159. */
  62160. subtract(otherSize: Size): Size;
  62161. /**
  62162. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  62163. * @param start starting size to lerp between
  62164. * @param end end size to lerp between
  62165. * @param amount amount to lerp between the start and end values
  62166. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  62167. */
  62168. static Lerp(start: Size, end: Size, amount: number): Size;
  62169. }
  62170. /**
  62171. * Class used to store quaternion data
  62172. * @see https://en.wikipedia.org/wiki/Quaternion
  62173. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  62174. */
  62175. export class Quaternion {
  62176. /** defines the first component (0 by default) */
  62177. x: number;
  62178. /** defines the second component (0 by default) */
  62179. y: number;
  62180. /** defines the third component (0 by default) */
  62181. z: number;
  62182. /** defines the fourth component (1.0 by default) */
  62183. w: number;
  62184. /**
  62185. * Creates a new Quaternion from the given floats
  62186. * @param x defines the first component (0 by default)
  62187. * @param y defines the second component (0 by default)
  62188. * @param z defines the third component (0 by default)
  62189. * @param w defines the fourth component (1.0 by default)
  62190. */
  62191. constructor(
  62192. /** defines the first component (0 by default) */
  62193. x?: number,
  62194. /** defines the second component (0 by default) */
  62195. y?: number,
  62196. /** defines the third component (0 by default) */
  62197. z?: number,
  62198. /** defines the fourth component (1.0 by default) */
  62199. w?: number);
  62200. /**
  62201. * Gets a string representation for the current quaternion
  62202. * @returns a string with the Quaternion coordinates
  62203. */
  62204. toString(): string;
  62205. /**
  62206. * Gets the class name of the quaternion
  62207. * @returns the string "Quaternion"
  62208. */
  62209. getClassName(): string;
  62210. /**
  62211. * Gets a hash code for this quaternion
  62212. * @returns the quaternion hash code
  62213. */
  62214. getHashCode(): number;
  62215. /**
  62216. * Copy the quaternion to an array
  62217. * @returns a new array populated with 4 elements from the quaternion coordinates
  62218. */
  62219. asArray(): number[];
  62220. /**
  62221. * Check if two quaternions are equals
  62222. * @param otherQuaternion defines the second operand
  62223. * @return true if the current quaternion and the given one coordinates are strictly equals
  62224. */
  62225. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  62226. /**
  62227. * Clone the current quaternion
  62228. * @returns a new quaternion copied from the current one
  62229. */
  62230. clone(): Quaternion;
  62231. /**
  62232. * Copy a quaternion to the current one
  62233. * @param other defines the other quaternion
  62234. * @returns the updated current quaternion
  62235. */
  62236. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  62237. /**
  62238. * Updates the current quaternion with the given float coordinates
  62239. * @param x defines the x coordinate
  62240. * @param y defines the y coordinate
  62241. * @param z defines the z coordinate
  62242. * @param w defines the w coordinate
  62243. * @returns the updated current quaternion
  62244. */
  62245. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  62246. /**
  62247. * Updates the current quaternion from the given float coordinates
  62248. * @param x defines the x coordinate
  62249. * @param y defines the y coordinate
  62250. * @param z defines the z coordinate
  62251. * @param w defines the w coordinate
  62252. * @returns the updated current quaternion
  62253. */
  62254. set(x: number, y: number, z: number, w: number): Quaternion;
  62255. /**
  62256. * Adds two quaternions
  62257. * @param other defines the second operand
  62258. * @returns a new quaternion as the addition result of the given one and the current quaternion
  62259. */
  62260. add(other: DeepImmutable<Quaternion>): Quaternion;
  62261. /**
  62262. * Add a quaternion to the current one
  62263. * @param other defines the quaternion to add
  62264. * @returns the current quaternion
  62265. */
  62266. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  62267. /**
  62268. * Subtract two quaternions
  62269. * @param other defines the second operand
  62270. * @returns a new quaternion as the subtraction result of the given one from the current one
  62271. */
  62272. subtract(other: Quaternion): Quaternion;
  62273. /**
  62274. * Multiplies the current quaternion by a scale factor
  62275. * @param value defines the scale factor
  62276. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  62277. */
  62278. scale(value: number): Quaternion;
  62279. /**
  62280. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  62281. * @param scale defines the scale factor
  62282. * @param result defines the Quaternion object where to store the result
  62283. * @returns the unmodified current quaternion
  62284. */
  62285. scaleToRef(scale: number, result: Quaternion): Quaternion;
  62286. /**
  62287. * Multiplies in place the current quaternion by a scale factor
  62288. * @param value defines the scale factor
  62289. * @returns the current modified quaternion
  62290. */
  62291. scaleInPlace(value: number): Quaternion;
  62292. /**
  62293. * Scale the current quaternion values by a factor and add the result to a given quaternion
  62294. * @param scale defines the scale factor
  62295. * @param result defines the Quaternion object where to store the result
  62296. * @returns the unmodified current quaternion
  62297. */
  62298. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  62299. /**
  62300. * Multiplies two quaternions
  62301. * @param q1 defines the second operand
  62302. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  62303. */
  62304. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  62305. /**
  62306. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  62307. * @param q1 defines the second operand
  62308. * @param result defines the target quaternion
  62309. * @returns the current quaternion
  62310. */
  62311. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  62312. /**
  62313. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  62314. * @param q1 defines the second operand
  62315. * @returns the currentupdated quaternion
  62316. */
  62317. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  62318. /**
  62319. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  62320. * @param ref defines the target quaternion
  62321. * @returns the current quaternion
  62322. */
  62323. conjugateToRef(ref: Quaternion): Quaternion;
  62324. /**
  62325. * Conjugates in place (1-q) the current quaternion
  62326. * @returns the current updated quaternion
  62327. */
  62328. conjugateInPlace(): Quaternion;
  62329. /**
  62330. * Conjugates in place (1-q) the current quaternion
  62331. * @returns a new quaternion
  62332. */
  62333. conjugate(): Quaternion;
  62334. /**
  62335. * Gets length of current quaternion
  62336. * @returns the quaternion length (float)
  62337. */
  62338. length(): number;
  62339. /**
  62340. * Normalize in place the current quaternion
  62341. * @returns the current updated quaternion
  62342. */
  62343. normalize(): Quaternion;
  62344. /**
  62345. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  62346. * @param order is a reserved parameter and is ignore for now
  62347. * @returns a new Vector3 containing the Euler angles
  62348. */
  62349. toEulerAngles(order?: string): Vector3;
  62350. /**
  62351. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  62352. * @param result defines the vector which will be filled with the Euler angles
  62353. * @param order is a reserved parameter and is ignore for now
  62354. * @returns the current unchanged quaternion
  62355. */
  62356. toEulerAnglesToRef(result: Vector3): Quaternion;
  62357. /**
  62358. * Updates the given rotation matrix with the current quaternion values
  62359. * @param result defines the target matrix
  62360. * @returns the current unchanged quaternion
  62361. */
  62362. toRotationMatrix(result: Matrix): Quaternion;
  62363. /**
  62364. * Updates the current quaternion from the given rotation matrix values
  62365. * @param matrix defines the source matrix
  62366. * @returns the current updated quaternion
  62367. */
  62368. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62369. /**
  62370. * Creates a new quaternion from a rotation matrix
  62371. * @param matrix defines the source matrix
  62372. * @returns a new quaternion created from the given rotation matrix values
  62373. */
  62374. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62375. /**
  62376. * Updates the given quaternion with the given rotation matrix values
  62377. * @param matrix defines the source matrix
  62378. * @param result defines the target quaternion
  62379. */
  62380. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  62381. /**
  62382. * Returns the dot product (float) between the quaternions "left" and "right"
  62383. * @param left defines the left operand
  62384. * @param right defines the right operand
  62385. * @returns the dot product
  62386. */
  62387. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  62388. /**
  62389. * Checks if the two quaternions are close to each other
  62390. * @param quat0 defines the first quaternion to check
  62391. * @param quat1 defines the second quaternion to check
  62392. * @returns true if the two quaternions are close to each other
  62393. */
  62394. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  62395. /**
  62396. * Creates an empty quaternion
  62397. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  62398. */
  62399. static Zero(): Quaternion;
  62400. /**
  62401. * Inverse a given quaternion
  62402. * @param q defines the source quaternion
  62403. * @returns a new quaternion as the inverted current quaternion
  62404. */
  62405. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  62406. /**
  62407. * Inverse a given quaternion
  62408. * @param q defines the source quaternion
  62409. * @param result the quaternion the result will be stored in
  62410. * @returns the result quaternion
  62411. */
  62412. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  62413. /**
  62414. * Creates an identity quaternion
  62415. * @returns the identity quaternion
  62416. */
  62417. static Identity(): Quaternion;
  62418. /**
  62419. * Gets a boolean indicating if the given quaternion is identity
  62420. * @param quaternion defines the quaternion to check
  62421. * @returns true if the quaternion is identity
  62422. */
  62423. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  62424. /**
  62425. * Creates a quaternion from a rotation around an axis
  62426. * @param axis defines the axis to use
  62427. * @param angle defines the angle to use
  62428. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  62429. */
  62430. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  62431. /**
  62432. * Creates a rotation around an axis and stores it into the given quaternion
  62433. * @param axis defines the axis to use
  62434. * @param angle defines the angle to use
  62435. * @param result defines the target quaternion
  62436. * @returns the target quaternion
  62437. */
  62438. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  62439. /**
  62440. * Creates a new quaternion from data stored into an array
  62441. * @param array defines the data source
  62442. * @param offset defines the offset in the source array where the data starts
  62443. * @returns a new quaternion
  62444. */
  62445. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  62446. /**
  62447. * Create a quaternion from Euler rotation angles
  62448. * @param x Pitch
  62449. * @param y Yaw
  62450. * @param z Roll
  62451. * @returns the new Quaternion
  62452. */
  62453. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  62454. /**
  62455. * Updates a quaternion from Euler rotation angles
  62456. * @param x Pitch
  62457. * @param y Yaw
  62458. * @param z Roll
  62459. * @param result the quaternion to store the result
  62460. * @returns the updated quaternion
  62461. */
  62462. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  62463. /**
  62464. * Create a quaternion from Euler rotation vector
  62465. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62466. * @returns the new Quaternion
  62467. */
  62468. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  62469. /**
  62470. * Updates a quaternion from Euler rotation vector
  62471. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62472. * @param result the quaternion to store the result
  62473. * @returns the updated quaternion
  62474. */
  62475. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  62476. /**
  62477. * Creates a new quaternion from the given Euler float angles (y, x, z)
  62478. * @param yaw defines the rotation around Y axis
  62479. * @param pitch defines the rotation around X axis
  62480. * @param roll defines the rotation around Z axis
  62481. * @returns the new quaternion
  62482. */
  62483. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  62484. /**
  62485. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  62486. * @param yaw defines the rotation around Y axis
  62487. * @param pitch defines the rotation around X axis
  62488. * @param roll defines the rotation around Z axis
  62489. * @param result defines the target quaternion
  62490. */
  62491. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  62492. /**
  62493. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  62494. * @param alpha defines the rotation around first axis
  62495. * @param beta defines the rotation around second axis
  62496. * @param gamma defines the rotation around third axis
  62497. * @returns the new quaternion
  62498. */
  62499. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  62500. /**
  62501. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  62502. * @param alpha defines the rotation around first axis
  62503. * @param beta defines the rotation around second axis
  62504. * @param gamma defines the rotation around third axis
  62505. * @param result defines the target quaternion
  62506. */
  62507. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  62508. /**
  62509. * 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)
  62510. * @param axis1 defines the first axis
  62511. * @param axis2 defines the second axis
  62512. * @param axis3 defines the third axis
  62513. * @returns the new quaternion
  62514. */
  62515. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  62516. /**
  62517. * 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
  62518. * @param axis1 defines the first axis
  62519. * @param axis2 defines the second axis
  62520. * @param axis3 defines the third axis
  62521. * @param ref defines the target quaternion
  62522. */
  62523. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  62524. /**
  62525. * Interpolates between two quaternions
  62526. * @param left defines first quaternion
  62527. * @param right defines second quaternion
  62528. * @param amount defines the gradient to use
  62529. * @returns the new interpolated quaternion
  62530. */
  62531. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62532. /**
  62533. * Interpolates between two quaternions and stores it into a target quaternion
  62534. * @param left defines first quaternion
  62535. * @param right defines second quaternion
  62536. * @param amount defines the gradient to use
  62537. * @param result defines the target quaternion
  62538. */
  62539. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  62540. /**
  62541. * Interpolate between two quaternions using Hermite interpolation
  62542. * @param value1 defines first quaternion
  62543. * @param tangent1 defines the incoming tangent
  62544. * @param value2 defines second quaternion
  62545. * @param tangent2 defines the outgoing tangent
  62546. * @param amount defines the target quaternion
  62547. * @returns the new interpolated quaternion
  62548. */
  62549. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62550. }
  62551. /**
  62552. * Class used to store matrix data (4x4)
  62553. */
  62554. export class Matrix {
  62555. private static _updateFlagSeed;
  62556. private static _identityReadOnly;
  62557. private _isIdentity;
  62558. private _isIdentityDirty;
  62559. private _isIdentity3x2;
  62560. private _isIdentity3x2Dirty;
  62561. /**
  62562. * Gets the update flag of the matrix which is an unique number for the matrix.
  62563. * It will be incremented every time the matrix data change.
  62564. * You can use it to speed the comparison between two versions of the same matrix.
  62565. */
  62566. updateFlag: number;
  62567. private readonly _m;
  62568. /**
  62569. * Gets the internal data of the matrix
  62570. */
  62571. readonly m: DeepImmutable<Float32Array>;
  62572. /** @hidden */
  62573. _markAsUpdated(): void;
  62574. /** @hidden */
  62575. private _updateIdentityStatus;
  62576. /**
  62577. * Creates an empty matrix (filled with zeros)
  62578. */
  62579. constructor();
  62580. /**
  62581. * Check if the current matrix is identity
  62582. * @returns true is the matrix is the identity matrix
  62583. */
  62584. isIdentity(): boolean;
  62585. /**
  62586. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  62587. * @returns true is the matrix is the identity matrix
  62588. */
  62589. isIdentityAs3x2(): boolean;
  62590. /**
  62591. * Gets the determinant of the matrix
  62592. * @returns the matrix determinant
  62593. */
  62594. determinant(): number;
  62595. /**
  62596. * Returns the matrix as a Float32Array
  62597. * @returns the matrix underlying array
  62598. */
  62599. toArray(): DeepImmutable<Float32Array>;
  62600. /**
  62601. * Returns the matrix as a Float32Array
  62602. * @returns the matrix underlying array.
  62603. */
  62604. asArray(): DeepImmutable<Float32Array>;
  62605. /**
  62606. * Inverts the current matrix in place
  62607. * @returns the current inverted matrix
  62608. */
  62609. invert(): Matrix;
  62610. /**
  62611. * Sets all the matrix elements to zero
  62612. * @returns the current matrix
  62613. */
  62614. reset(): Matrix;
  62615. /**
  62616. * Adds the current matrix with a second one
  62617. * @param other defines the matrix to add
  62618. * @returns a new matrix as the addition of the current matrix and the given one
  62619. */
  62620. add(other: DeepImmutable<Matrix>): Matrix;
  62621. /**
  62622. * Sets the given matrix "result" to the addition of the current matrix and the given one
  62623. * @param other defines the matrix to add
  62624. * @param result defines the target matrix
  62625. * @returns the current matrix
  62626. */
  62627. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62628. /**
  62629. * Adds in place the given matrix to the current matrix
  62630. * @param other defines the second operand
  62631. * @returns the current updated matrix
  62632. */
  62633. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  62634. /**
  62635. * Sets the given matrix to the current inverted Matrix
  62636. * @param other defines the target matrix
  62637. * @returns the unmodified current matrix
  62638. */
  62639. invertToRef(other: Matrix): Matrix;
  62640. /**
  62641. * add a value at the specified position in the current Matrix
  62642. * @param index the index of the value within the matrix. between 0 and 15.
  62643. * @param value the value to be added
  62644. * @returns the current updated matrix
  62645. */
  62646. addAtIndex(index: number, value: number): Matrix;
  62647. /**
  62648. * mutiply the specified position in the current Matrix by a value
  62649. * @param index the index of the value within the matrix. between 0 and 15.
  62650. * @param value the value to be added
  62651. * @returns the current updated matrix
  62652. */
  62653. multiplyAtIndex(index: number, value: number): Matrix;
  62654. /**
  62655. * Inserts the translation vector (using 3 floats) in the current matrix
  62656. * @param x defines the 1st component of the translation
  62657. * @param y defines the 2nd component of the translation
  62658. * @param z defines the 3rd component of the translation
  62659. * @returns the current updated matrix
  62660. */
  62661. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62662. /**
  62663. * Adds the translation vector (using 3 floats) in the current matrix
  62664. * @param x defines the 1st component of the translation
  62665. * @param y defines the 2nd component of the translation
  62666. * @param z defines the 3rd component of the translation
  62667. * @returns the current updated matrix
  62668. */
  62669. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62670. /**
  62671. * Inserts the translation vector in the current matrix
  62672. * @param vector3 defines the translation to insert
  62673. * @returns the current updated matrix
  62674. */
  62675. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  62676. /**
  62677. * Gets the translation value of the current matrix
  62678. * @returns a new Vector3 as the extracted translation from the matrix
  62679. */
  62680. getTranslation(): Vector3;
  62681. /**
  62682. * Fill a Vector3 with the extracted translation from the matrix
  62683. * @param result defines the Vector3 where to store the translation
  62684. * @returns the current matrix
  62685. */
  62686. getTranslationToRef(result: Vector3): Matrix;
  62687. /**
  62688. * Remove rotation and scaling part from the matrix
  62689. * @returns the updated matrix
  62690. */
  62691. removeRotationAndScaling(): Matrix;
  62692. /**
  62693. * Multiply two matrices
  62694. * @param other defines the second operand
  62695. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  62696. */
  62697. multiply(other: DeepImmutable<Matrix>): Matrix;
  62698. /**
  62699. * Copy the current matrix from the given one
  62700. * @param other defines the source matrix
  62701. * @returns the current updated matrix
  62702. */
  62703. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  62704. /**
  62705. * Populates the given array from the starting index with the current matrix values
  62706. * @param array defines the target array
  62707. * @param offset defines the offset in the target array where to start storing values
  62708. * @returns the current matrix
  62709. */
  62710. copyToArray(array: Float32Array, offset?: number): Matrix;
  62711. /**
  62712. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  62713. * @param other defines the second operand
  62714. * @param result defines the matrix where to store the multiplication
  62715. * @returns the current matrix
  62716. */
  62717. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62718. /**
  62719. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  62720. * @param other defines the second operand
  62721. * @param result defines the array where to store the multiplication
  62722. * @param offset defines the offset in the target array where to start storing values
  62723. * @returns the current matrix
  62724. */
  62725. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  62726. /**
  62727. * Check equality between this matrix and a second one
  62728. * @param value defines the second matrix to compare
  62729. * @returns true is the current matrix and the given one values are strictly equal
  62730. */
  62731. equals(value: DeepImmutable<Matrix>): boolean;
  62732. /**
  62733. * Clone the current matrix
  62734. * @returns a new matrix from the current matrix
  62735. */
  62736. clone(): Matrix;
  62737. /**
  62738. * Returns the name of the current matrix class
  62739. * @returns the string "Matrix"
  62740. */
  62741. getClassName(): string;
  62742. /**
  62743. * Gets the hash code of the current matrix
  62744. * @returns the hash code
  62745. */
  62746. getHashCode(): number;
  62747. /**
  62748. * Decomposes the current Matrix into a translation, rotation and scaling components
  62749. * @param scale defines the scale vector3 given as a reference to update
  62750. * @param rotation defines the rotation quaternion given as a reference to update
  62751. * @param translation defines the translation vector3 given as a reference to update
  62752. * @returns true if operation was successful
  62753. */
  62754. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  62755. /**
  62756. * Gets specific row of the matrix
  62757. * @param index defines the number of the row to get
  62758. * @returns the index-th row of the current matrix as a new Vector4
  62759. */
  62760. getRow(index: number): Nullable<Vector4>;
  62761. /**
  62762. * Sets the index-th row of the current matrix to the vector4 values
  62763. * @param index defines the number of the row to set
  62764. * @param row defines the target vector4
  62765. * @returns the updated current matrix
  62766. */
  62767. setRow(index: number, row: Vector4): Matrix;
  62768. /**
  62769. * Compute the transpose of the matrix
  62770. * @returns the new transposed matrix
  62771. */
  62772. transpose(): Matrix;
  62773. /**
  62774. * Compute the transpose of the matrix and store it in a given matrix
  62775. * @param result defines the target matrix
  62776. * @returns the current matrix
  62777. */
  62778. transposeToRef(result: Matrix): Matrix;
  62779. /**
  62780. * Sets the index-th row of the current matrix with the given 4 x float values
  62781. * @param index defines the row index
  62782. * @param x defines the x component to set
  62783. * @param y defines the y component to set
  62784. * @param z defines the z component to set
  62785. * @param w defines the w component to set
  62786. * @returns the updated current matrix
  62787. */
  62788. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  62789. /**
  62790. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  62791. * @param scale defines the scale factor
  62792. * @returns a new matrix
  62793. */
  62794. scale(scale: number): Matrix;
  62795. /**
  62796. * Scale the current matrix values by a factor to a given result matrix
  62797. * @param scale defines the scale factor
  62798. * @param result defines the matrix to store the result
  62799. * @returns the current matrix
  62800. */
  62801. scaleToRef(scale: number, result: Matrix): Matrix;
  62802. /**
  62803. * Scale the current matrix values by a factor and add the result to a given matrix
  62804. * @param scale defines the scale factor
  62805. * @param result defines the Matrix to store the result
  62806. * @returns the current matrix
  62807. */
  62808. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  62809. /**
  62810. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  62811. * @param ref matrix to store the result
  62812. */
  62813. toNormalMatrix(ref: Matrix): void;
  62814. /**
  62815. * Gets only rotation part of the current matrix
  62816. * @returns a new matrix sets to the extracted rotation matrix from the current one
  62817. */
  62818. getRotationMatrix(): Matrix;
  62819. /**
  62820. * Extracts the rotation matrix from the current one and sets it as the given "result"
  62821. * @param result defines the target matrix to store data to
  62822. * @returns the current matrix
  62823. */
  62824. getRotationMatrixToRef(result: Matrix): Matrix;
  62825. /**
  62826. * Toggles model matrix from being right handed to left handed in place and vice versa
  62827. */
  62828. toggleModelMatrixHandInPlace(): void;
  62829. /**
  62830. * Toggles projection matrix from being right handed to left handed in place and vice versa
  62831. */
  62832. toggleProjectionMatrixHandInPlace(): void;
  62833. /**
  62834. * Creates a matrix from an array
  62835. * @param array defines the source array
  62836. * @param offset defines an offset in the source array
  62837. * @returns a new Matrix set from the starting index of the given array
  62838. */
  62839. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  62840. /**
  62841. * Copy the content of an array into a given matrix
  62842. * @param array defines the source array
  62843. * @param offset defines an offset in the source array
  62844. * @param result defines the target matrix
  62845. */
  62846. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  62847. /**
  62848. * Stores an array into a matrix after having multiplied each component by a given factor
  62849. * @param array defines the source array
  62850. * @param offset defines the offset in the source array
  62851. * @param scale defines the scaling factor
  62852. * @param result defines the target matrix
  62853. */
  62854. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  62855. /**
  62856. * Gets an identity matrix that must not be updated
  62857. */
  62858. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  62859. /**
  62860. * Stores a list of values (16) inside a given matrix
  62861. * @param initialM11 defines 1st value of 1st row
  62862. * @param initialM12 defines 2nd value of 1st row
  62863. * @param initialM13 defines 3rd value of 1st row
  62864. * @param initialM14 defines 4th value of 1st row
  62865. * @param initialM21 defines 1st value of 2nd row
  62866. * @param initialM22 defines 2nd value of 2nd row
  62867. * @param initialM23 defines 3rd value of 2nd row
  62868. * @param initialM24 defines 4th value of 2nd row
  62869. * @param initialM31 defines 1st value of 3rd row
  62870. * @param initialM32 defines 2nd value of 3rd row
  62871. * @param initialM33 defines 3rd value of 3rd row
  62872. * @param initialM34 defines 4th value of 3rd row
  62873. * @param initialM41 defines 1st value of 4th row
  62874. * @param initialM42 defines 2nd value of 4th row
  62875. * @param initialM43 defines 3rd value of 4th row
  62876. * @param initialM44 defines 4th value of 4th row
  62877. * @param result defines the target matrix
  62878. */
  62879. 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;
  62880. /**
  62881. * Creates new matrix from a list of values (16)
  62882. * @param initialM11 defines 1st value of 1st row
  62883. * @param initialM12 defines 2nd value of 1st row
  62884. * @param initialM13 defines 3rd value of 1st row
  62885. * @param initialM14 defines 4th value of 1st row
  62886. * @param initialM21 defines 1st value of 2nd row
  62887. * @param initialM22 defines 2nd value of 2nd row
  62888. * @param initialM23 defines 3rd value of 2nd row
  62889. * @param initialM24 defines 4th value of 2nd row
  62890. * @param initialM31 defines 1st value of 3rd row
  62891. * @param initialM32 defines 2nd value of 3rd row
  62892. * @param initialM33 defines 3rd value of 3rd row
  62893. * @param initialM34 defines 4th value of 3rd row
  62894. * @param initialM41 defines 1st value of 4th row
  62895. * @param initialM42 defines 2nd value of 4th row
  62896. * @param initialM43 defines 3rd value of 4th row
  62897. * @param initialM44 defines 4th value of 4th row
  62898. * @returns the new matrix
  62899. */
  62900. 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;
  62901. /**
  62902. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  62903. * @param scale defines the scale vector3
  62904. * @param rotation defines the rotation quaternion
  62905. * @param translation defines the translation vector3
  62906. * @returns a new matrix
  62907. */
  62908. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  62909. /**
  62910. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  62911. * @param scale defines the scale vector3
  62912. * @param rotation defines the rotation quaternion
  62913. * @param translation defines the translation vector3
  62914. * @param result defines the target matrix
  62915. */
  62916. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  62917. /**
  62918. * Creates a new identity matrix
  62919. * @returns a new identity matrix
  62920. */
  62921. static Identity(): Matrix;
  62922. /**
  62923. * Creates a new identity matrix and stores the result in a given matrix
  62924. * @param result defines the target matrix
  62925. */
  62926. static IdentityToRef(result: Matrix): void;
  62927. /**
  62928. * Creates a new zero matrix
  62929. * @returns a new zero matrix
  62930. */
  62931. static Zero(): Matrix;
  62932. /**
  62933. * Creates a new rotation matrix for "angle" radians around the X axis
  62934. * @param angle defines the angle (in radians) to use
  62935. * @return the new matrix
  62936. */
  62937. static RotationX(angle: number): Matrix;
  62938. /**
  62939. * Creates a new matrix as the invert of a given matrix
  62940. * @param source defines the source matrix
  62941. * @returns the new matrix
  62942. */
  62943. static Invert(source: DeepImmutable<Matrix>): Matrix;
  62944. /**
  62945. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  62946. * @param angle defines the angle (in radians) to use
  62947. * @param result defines the target matrix
  62948. */
  62949. static RotationXToRef(angle: number, result: Matrix): void;
  62950. /**
  62951. * Creates a new rotation matrix for "angle" radians around the Y axis
  62952. * @param angle defines the angle (in radians) to use
  62953. * @return the new matrix
  62954. */
  62955. static RotationY(angle: number): Matrix;
  62956. /**
  62957. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  62958. * @param angle defines the angle (in radians) to use
  62959. * @param result defines the target matrix
  62960. */
  62961. static RotationYToRef(angle: number, result: Matrix): void;
  62962. /**
  62963. * Creates a new rotation matrix for "angle" radians around the Z axis
  62964. * @param angle defines the angle (in radians) to use
  62965. * @return the new matrix
  62966. */
  62967. static RotationZ(angle: number): Matrix;
  62968. /**
  62969. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  62970. * @param angle defines the angle (in radians) to use
  62971. * @param result defines the target matrix
  62972. */
  62973. static RotationZToRef(angle: number, result: Matrix): void;
  62974. /**
  62975. * Creates a new rotation matrix for "angle" radians around the given axis
  62976. * @param axis defines the axis to use
  62977. * @param angle defines the angle (in radians) to use
  62978. * @return the new matrix
  62979. */
  62980. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  62981. /**
  62982. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  62983. * @param axis defines the axis to use
  62984. * @param angle defines the angle (in radians) to use
  62985. * @param result defines the target matrix
  62986. */
  62987. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  62988. /**
  62989. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  62990. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  62991. * @param from defines the vector to align
  62992. * @param to defines the vector to align to
  62993. * @param result defines the target matrix
  62994. */
  62995. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  62996. /**
  62997. * Creates a rotation matrix
  62998. * @param yaw defines the yaw angle in radians (Y axis)
  62999. * @param pitch defines the pitch angle in radians (X axis)
  63000. * @param roll defines the roll angle in radians (X axis)
  63001. * @returns the new rotation matrix
  63002. */
  63003. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  63004. /**
  63005. * Creates a rotation matrix and stores it in a given matrix
  63006. * @param yaw defines the yaw angle in radians (Y axis)
  63007. * @param pitch defines the pitch angle in radians (X axis)
  63008. * @param roll defines the roll angle in radians (X axis)
  63009. * @param result defines the target matrix
  63010. */
  63011. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  63012. /**
  63013. * Creates a scaling matrix
  63014. * @param x defines the scale factor on X axis
  63015. * @param y defines the scale factor on Y axis
  63016. * @param z defines the scale factor on Z axis
  63017. * @returns the new matrix
  63018. */
  63019. static Scaling(x: number, y: number, z: number): Matrix;
  63020. /**
  63021. * Creates a scaling matrix and stores it in a given matrix
  63022. * @param x defines the scale factor on X axis
  63023. * @param y defines the scale factor on Y axis
  63024. * @param z defines the scale factor on Z axis
  63025. * @param result defines the target matrix
  63026. */
  63027. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  63028. /**
  63029. * Creates a translation matrix
  63030. * @param x defines the translation on X axis
  63031. * @param y defines the translation on Y axis
  63032. * @param z defines the translationon Z axis
  63033. * @returns the new matrix
  63034. */
  63035. static Translation(x: number, y: number, z: number): Matrix;
  63036. /**
  63037. * Creates a translation matrix and stores it in a given matrix
  63038. * @param x defines the translation on X axis
  63039. * @param y defines the translation on Y axis
  63040. * @param z defines the translationon Z axis
  63041. * @param result defines the target matrix
  63042. */
  63043. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  63044. /**
  63045. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  63046. * @param startValue defines the start value
  63047. * @param endValue defines the end value
  63048. * @param gradient defines the gradient factor
  63049. * @returns the new matrix
  63050. */
  63051. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  63052. /**
  63053. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  63054. * @param startValue defines the start value
  63055. * @param endValue defines the end value
  63056. * @param gradient defines the gradient factor
  63057. * @param result defines the Matrix object where to store data
  63058. */
  63059. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  63060. /**
  63061. * Builds a new matrix whose values are computed by:
  63062. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  63063. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  63064. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  63065. * @param startValue defines the first matrix
  63066. * @param endValue defines the second matrix
  63067. * @param gradient defines the gradient between the two matrices
  63068. * @returns the new matrix
  63069. */
  63070. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  63071. /**
  63072. * Update a matrix to values which are computed by:
  63073. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  63074. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  63075. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  63076. * @param startValue defines the first matrix
  63077. * @param endValue defines the second matrix
  63078. * @param gradient defines the gradient between the two matrices
  63079. * @param result defines the target matrix
  63080. */
  63081. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  63082. /**
  63083. * 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"
  63084. * This function works in left handed mode
  63085. * @param eye defines the final position of the entity
  63086. * @param target defines where the entity should look at
  63087. * @param up defines the up vector for the entity
  63088. * @returns the new matrix
  63089. */
  63090. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  63091. /**
  63092. * 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".
  63093. * This function works in left handed mode
  63094. * @param eye defines the final position of the entity
  63095. * @param target defines where the entity should look at
  63096. * @param up defines the up vector for the entity
  63097. * @param result defines the target matrix
  63098. */
  63099. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  63100. /**
  63101. * 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"
  63102. * This function works in right handed mode
  63103. * @param eye defines the final position of the entity
  63104. * @param target defines where the entity should look at
  63105. * @param up defines the up vector for the entity
  63106. * @returns the new matrix
  63107. */
  63108. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  63109. /**
  63110. * 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".
  63111. * This function works in right handed mode
  63112. * @param eye defines the final position of the entity
  63113. * @param target defines where the entity should look at
  63114. * @param up defines the up vector for the entity
  63115. * @param result defines the target matrix
  63116. */
  63117. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  63118. /**
  63119. * Create a left-handed orthographic projection matrix
  63120. * @param width defines the viewport width
  63121. * @param height defines the viewport height
  63122. * @param znear defines the near clip plane
  63123. * @param zfar defines the far clip plane
  63124. * @returns a new matrix as a left-handed orthographic projection matrix
  63125. */
  63126. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  63127. /**
  63128. * Store a left-handed orthographic projection to a given matrix
  63129. * @param width defines the viewport width
  63130. * @param height defines the viewport height
  63131. * @param znear defines the near clip plane
  63132. * @param zfar defines the far clip plane
  63133. * @param result defines the target matrix
  63134. */
  63135. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  63136. /**
  63137. * Create a left-handed orthographic projection matrix
  63138. * @param left defines the viewport left coordinate
  63139. * @param right defines the viewport right coordinate
  63140. * @param bottom defines the viewport bottom coordinate
  63141. * @param top defines the viewport top coordinate
  63142. * @param znear defines the near clip plane
  63143. * @param zfar defines the far clip plane
  63144. * @returns a new matrix as a left-handed orthographic projection matrix
  63145. */
  63146. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  63147. /**
  63148. * Stores a left-handed orthographic projection into a given matrix
  63149. * @param left defines the viewport left coordinate
  63150. * @param right defines the viewport right coordinate
  63151. * @param bottom defines the viewport bottom coordinate
  63152. * @param top defines the viewport top coordinate
  63153. * @param znear defines the near clip plane
  63154. * @param zfar defines the far clip plane
  63155. * @param result defines the target matrix
  63156. */
  63157. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  63158. /**
  63159. * Creates a right-handed orthographic projection matrix
  63160. * @param left defines the viewport left coordinate
  63161. * @param right defines the viewport right coordinate
  63162. * @param bottom defines the viewport bottom coordinate
  63163. * @param top defines the viewport top coordinate
  63164. * @param znear defines the near clip plane
  63165. * @param zfar defines the far clip plane
  63166. * @returns a new matrix as a right-handed orthographic projection matrix
  63167. */
  63168. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  63169. /**
  63170. * Stores a right-handed orthographic projection into a given matrix
  63171. * @param left defines the viewport left coordinate
  63172. * @param right defines the viewport right coordinate
  63173. * @param bottom defines the viewport bottom coordinate
  63174. * @param top defines the viewport top coordinate
  63175. * @param znear defines the near clip plane
  63176. * @param zfar defines the far clip plane
  63177. * @param result defines the target matrix
  63178. */
  63179. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  63180. /**
  63181. * Creates a left-handed perspective projection matrix
  63182. * @param width defines the viewport width
  63183. * @param height defines the viewport height
  63184. * @param znear defines the near clip plane
  63185. * @param zfar defines the far clip plane
  63186. * @returns a new matrix as a left-handed perspective projection matrix
  63187. */
  63188. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  63189. /**
  63190. * Creates a left-handed perspective projection matrix
  63191. * @param fov defines the horizontal field of view
  63192. * @param aspect defines the aspect ratio
  63193. * @param znear defines the near clip plane
  63194. * @param zfar defines the far clip plane
  63195. * @returns a new matrix as a left-handed perspective projection matrix
  63196. */
  63197. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63198. /**
  63199. * Stores a left-handed perspective projection into a given matrix
  63200. * @param fov defines the horizontal field of view
  63201. * @param aspect defines the aspect ratio
  63202. * @param znear defines the near clip plane
  63203. * @param zfar defines the far clip plane
  63204. * @param result defines the target matrix
  63205. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63206. */
  63207. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63208. /**
  63209. * Creates a right-handed perspective projection matrix
  63210. * @param fov defines the horizontal field of view
  63211. * @param aspect defines the aspect ratio
  63212. * @param znear defines the near clip plane
  63213. * @param zfar defines the far clip plane
  63214. * @returns a new matrix as a right-handed perspective projection matrix
  63215. */
  63216. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63217. /**
  63218. * Stores a right-handed perspective projection into a given matrix
  63219. * @param fov defines the horizontal field of view
  63220. * @param aspect defines the aspect ratio
  63221. * @param znear defines the near clip plane
  63222. * @param zfar defines the far clip plane
  63223. * @param result defines the target matrix
  63224. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63225. */
  63226. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63227. /**
  63228. * Stores a perspective projection for WebVR info a given matrix
  63229. * @param fov defines the field of view
  63230. * @param znear defines the near clip plane
  63231. * @param zfar defines the far clip plane
  63232. * @param result defines the target matrix
  63233. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  63234. */
  63235. static PerspectiveFovWebVRToRef(fov: {
  63236. upDegrees: number;
  63237. downDegrees: number;
  63238. leftDegrees: number;
  63239. rightDegrees: number;
  63240. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  63241. /**
  63242. * Computes a complete transformation matrix
  63243. * @param viewport defines the viewport to use
  63244. * @param world defines the world matrix
  63245. * @param view defines the view matrix
  63246. * @param projection defines the projection matrix
  63247. * @param zmin defines the near clip plane
  63248. * @param zmax defines the far clip plane
  63249. * @returns the transformation matrix
  63250. */
  63251. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  63252. /**
  63253. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  63254. * @param matrix defines the matrix to use
  63255. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  63256. */
  63257. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  63258. /**
  63259. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  63260. * @param matrix defines the matrix to use
  63261. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  63262. */
  63263. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  63264. /**
  63265. * Compute the transpose of a given matrix
  63266. * @param matrix defines the matrix to transpose
  63267. * @returns the new matrix
  63268. */
  63269. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  63270. /**
  63271. * Compute the transpose of a matrix and store it in a target matrix
  63272. * @param matrix defines the matrix to transpose
  63273. * @param result defines the target matrix
  63274. */
  63275. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  63276. /**
  63277. * Computes a reflection matrix from a plane
  63278. * @param plane defines the reflection plane
  63279. * @returns a new matrix
  63280. */
  63281. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  63282. /**
  63283. * Computes a reflection matrix from a plane
  63284. * @param plane defines the reflection plane
  63285. * @param result defines the target matrix
  63286. */
  63287. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  63288. /**
  63289. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  63290. * @param xaxis defines the value of the 1st axis
  63291. * @param yaxis defines the value of the 2nd axis
  63292. * @param zaxis defines the value of the 3rd axis
  63293. * @param result defines the target matrix
  63294. */
  63295. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  63296. /**
  63297. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  63298. * @param quat defines the quaternion to use
  63299. * @param result defines the target matrix
  63300. */
  63301. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  63302. }
  63303. /**
  63304. * Represens a plane by the equation ax + by + cz + d = 0
  63305. */
  63306. export class Plane {
  63307. /**
  63308. * Normal of the plane (a,b,c)
  63309. */
  63310. normal: Vector3;
  63311. /**
  63312. * d component of the plane
  63313. */
  63314. d: number;
  63315. /**
  63316. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  63317. * @param a a component of the plane
  63318. * @param b b component of the plane
  63319. * @param c c component of the plane
  63320. * @param d d component of the plane
  63321. */
  63322. constructor(a: number, b: number, c: number, d: number);
  63323. /**
  63324. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  63325. */
  63326. asArray(): number[];
  63327. /**
  63328. * @returns a new plane copied from the current Plane.
  63329. */
  63330. clone(): Plane;
  63331. /**
  63332. * @returns the string "Plane".
  63333. */
  63334. getClassName(): string;
  63335. /**
  63336. * @returns the Plane hash code.
  63337. */
  63338. getHashCode(): number;
  63339. /**
  63340. * Normalize the current Plane in place.
  63341. * @returns the updated Plane.
  63342. */
  63343. normalize(): Plane;
  63344. /**
  63345. * Applies a transformation the plane and returns the result
  63346. * @param transformation the transformation matrix to be applied to the plane
  63347. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  63348. */
  63349. transform(transformation: DeepImmutable<Matrix>): Plane;
  63350. /**
  63351. * Calcualtte the dot product between the point and the plane normal
  63352. * @param point point to calculate the dot product with
  63353. * @returns the dot product (float) of the point coordinates and the plane normal.
  63354. */
  63355. dotCoordinate(point: DeepImmutable<Vector3>): number;
  63356. /**
  63357. * Updates the current Plane from the plane defined by the three given points.
  63358. * @param point1 one of the points used to contruct the plane
  63359. * @param point2 one of the points used to contruct the plane
  63360. * @param point3 one of the points used to contruct the plane
  63361. * @returns the updated Plane.
  63362. */
  63363. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63364. /**
  63365. * Checks if the plane is facing a given direction
  63366. * @param direction the direction to check if the plane is facing
  63367. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  63368. * @returns True is the vector "direction" is the same side than the plane normal.
  63369. */
  63370. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  63371. /**
  63372. * Calculates the distance to a point
  63373. * @param point point to calculate distance to
  63374. * @returns the signed distance (float) from the given point to the Plane.
  63375. */
  63376. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  63377. /**
  63378. * Creates a plane from an array
  63379. * @param array the array to create a plane from
  63380. * @returns a new Plane from the given array.
  63381. */
  63382. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  63383. /**
  63384. * Creates a plane from three points
  63385. * @param point1 point used to create the plane
  63386. * @param point2 point used to create the plane
  63387. * @param point3 point used to create the plane
  63388. * @returns a new Plane defined by the three given points.
  63389. */
  63390. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63391. /**
  63392. * Creates a plane from an origin point and a normal
  63393. * @param origin origin of the plane to be constructed
  63394. * @param normal normal of the plane to be constructed
  63395. * @returns a new Plane the normal vector to this plane at the given origin point.
  63396. * Note : the vector "normal" is updated because normalized.
  63397. */
  63398. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  63399. /**
  63400. * Calculates the distance from a plane and a point
  63401. * @param origin origin of the plane to be constructed
  63402. * @param normal normal of the plane to be constructed
  63403. * @param point point to calculate distance to
  63404. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  63405. */
  63406. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  63407. }
  63408. /**
  63409. * Class used to represent a viewport on screen
  63410. */
  63411. export class Viewport {
  63412. /** viewport left coordinate */
  63413. x: number;
  63414. /** viewport top coordinate */
  63415. y: number;
  63416. /**viewport width */
  63417. width: number;
  63418. /** viewport height */
  63419. height: number;
  63420. /**
  63421. * Creates a Viewport object located at (x, y) and sized (width, height)
  63422. * @param x defines viewport left coordinate
  63423. * @param y defines viewport top coordinate
  63424. * @param width defines the viewport width
  63425. * @param height defines the viewport height
  63426. */
  63427. constructor(
  63428. /** viewport left coordinate */
  63429. x: number,
  63430. /** viewport top coordinate */
  63431. y: number,
  63432. /**viewport width */
  63433. width: number,
  63434. /** viewport height */
  63435. height: number);
  63436. /**
  63437. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  63438. * @param renderWidth defines the rendering width
  63439. * @param renderHeight defines the rendering height
  63440. * @returns a new Viewport
  63441. */
  63442. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  63443. /**
  63444. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  63445. * @param renderWidth defines the rendering width
  63446. * @param renderHeight defines the rendering height
  63447. * @param ref defines the target viewport
  63448. * @returns the current viewport
  63449. */
  63450. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  63451. /**
  63452. * Returns a new Viewport copied from the current one
  63453. * @returns a new Viewport
  63454. */
  63455. clone(): Viewport;
  63456. }
  63457. /**
  63458. * Reprasents a camera frustum
  63459. */
  63460. export class Frustum {
  63461. /**
  63462. * Gets the planes representing the frustum
  63463. * @param transform matrix to be applied to the returned planes
  63464. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  63465. */
  63466. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  63467. /**
  63468. * Gets the near frustum plane transformed by the transform matrix
  63469. * @param transform transformation matrix to be applied to the resulting frustum plane
  63470. * @param frustumPlane the resuling frustum plane
  63471. */
  63472. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63473. /**
  63474. * Gets the far frustum plane transformed by the transform matrix
  63475. * @param transform transformation matrix to be applied to the resulting frustum plane
  63476. * @param frustumPlane the resuling frustum plane
  63477. */
  63478. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63479. /**
  63480. * Gets the left frustum plane transformed by the transform matrix
  63481. * @param transform transformation matrix to be applied to the resulting frustum plane
  63482. * @param frustumPlane the resuling frustum plane
  63483. */
  63484. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63485. /**
  63486. * Gets the right frustum plane transformed by the transform matrix
  63487. * @param transform transformation matrix to be applied to the resulting frustum plane
  63488. * @param frustumPlane the resuling frustum plane
  63489. */
  63490. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63491. /**
  63492. * Gets the top frustum plane transformed by the transform matrix
  63493. * @param transform transformation matrix to be applied to the resulting frustum plane
  63494. * @param frustumPlane the resuling frustum plane
  63495. */
  63496. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63497. /**
  63498. * Gets the bottom frustum plane transformed by the transform matrix
  63499. * @param transform transformation matrix to be applied to the resulting frustum plane
  63500. * @param frustumPlane the resuling frustum plane
  63501. */
  63502. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63503. /**
  63504. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  63505. * @param transform transformation matrix to be applied to the resulting frustum planes
  63506. * @param frustumPlanes the resuling frustum planes
  63507. */
  63508. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  63509. }
  63510. /** Defines supported spaces */
  63511. export enum Space {
  63512. /** Local (object) space */
  63513. LOCAL = 0,
  63514. /** World space */
  63515. WORLD = 1,
  63516. /** Bone space */
  63517. BONE = 2
  63518. }
  63519. /** Defines the 3 main axes */
  63520. export class Axis {
  63521. /** X axis */
  63522. static X: Vector3;
  63523. /** Y axis */
  63524. static Y: Vector3;
  63525. /** Z axis */
  63526. static Z: Vector3;
  63527. }
  63528. /** Class used to represent a Bezier curve */
  63529. export class BezierCurve {
  63530. /**
  63531. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  63532. * @param t defines the time
  63533. * @param x1 defines the left coordinate on X axis
  63534. * @param y1 defines the left coordinate on Y axis
  63535. * @param x2 defines the right coordinate on X axis
  63536. * @param y2 defines the right coordinate on Y axis
  63537. * @returns the interpolated value
  63538. */
  63539. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  63540. }
  63541. /**
  63542. * Defines potential orientation for back face culling
  63543. */
  63544. export enum Orientation {
  63545. /**
  63546. * Clockwise
  63547. */
  63548. CW = 0,
  63549. /** Counter clockwise */
  63550. CCW = 1
  63551. }
  63552. /**
  63553. * Defines angle representation
  63554. */
  63555. export class Angle {
  63556. private _radians;
  63557. /**
  63558. * Creates an Angle object of "radians" radians (float).
  63559. * @param radians the angle in radians
  63560. */
  63561. constructor(radians: number);
  63562. /**
  63563. * Get value in degrees
  63564. * @returns the Angle value in degrees (float)
  63565. */
  63566. degrees(): number;
  63567. /**
  63568. * Get value in radians
  63569. * @returns the Angle value in radians (float)
  63570. */
  63571. radians(): number;
  63572. /**
  63573. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  63574. * @param a defines first vector
  63575. * @param b defines second vector
  63576. * @returns a new Angle
  63577. */
  63578. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  63579. /**
  63580. * Gets a new Angle object from the given float in radians
  63581. * @param radians defines the angle value in radians
  63582. * @returns a new Angle
  63583. */
  63584. static FromRadians(radians: number): Angle;
  63585. /**
  63586. * Gets a new Angle object from the given float in degrees
  63587. * @param degrees defines the angle value in degrees
  63588. * @returns a new Angle
  63589. */
  63590. static FromDegrees(degrees: number): Angle;
  63591. }
  63592. /**
  63593. * This represents an arc in a 2d space.
  63594. */
  63595. export class Arc2 {
  63596. /** Defines the start point of the arc */
  63597. startPoint: Vector2;
  63598. /** Defines the mid point of the arc */
  63599. midPoint: Vector2;
  63600. /** Defines the end point of the arc */
  63601. endPoint: Vector2;
  63602. /**
  63603. * Defines the center point of the arc.
  63604. */
  63605. centerPoint: Vector2;
  63606. /**
  63607. * Defines the radius of the arc.
  63608. */
  63609. radius: number;
  63610. /**
  63611. * Defines the angle of the arc (from mid point to end point).
  63612. */
  63613. angle: Angle;
  63614. /**
  63615. * Defines the start angle of the arc (from start point to middle point).
  63616. */
  63617. startAngle: Angle;
  63618. /**
  63619. * Defines the orientation of the arc (clock wise/counter clock wise).
  63620. */
  63621. orientation: Orientation;
  63622. /**
  63623. * Creates an Arc object from the three given points : start, middle and end.
  63624. * @param startPoint Defines the start point of the arc
  63625. * @param midPoint Defines the midlle point of the arc
  63626. * @param endPoint Defines the end point of the arc
  63627. */
  63628. constructor(
  63629. /** Defines the start point of the arc */
  63630. startPoint: Vector2,
  63631. /** Defines the mid point of the arc */
  63632. midPoint: Vector2,
  63633. /** Defines the end point of the arc */
  63634. endPoint: Vector2);
  63635. }
  63636. /**
  63637. * Represents a 2D path made up of multiple 2D points
  63638. */
  63639. export class Path2 {
  63640. private _points;
  63641. private _length;
  63642. /**
  63643. * If the path start and end point are the same
  63644. */
  63645. closed: boolean;
  63646. /**
  63647. * Creates a Path2 object from the starting 2D coordinates x and y.
  63648. * @param x the starting points x value
  63649. * @param y the starting points y value
  63650. */
  63651. constructor(x: number, y: number);
  63652. /**
  63653. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  63654. * @param x the added points x value
  63655. * @param y the added points y value
  63656. * @returns the updated Path2.
  63657. */
  63658. addLineTo(x: number, y: number): Path2;
  63659. /**
  63660. * 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.
  63661. * @param midX middle point x value
  63662. * @param midY middle point y value
  63663. * @param endX end point x value
  63664. * @param endY end point y value
  63665. * @param numberOfSegments (default: 36)
  63666. * @returns the updated Path2.
  63667. */
  63668. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  63669. /**
  63670. * Closes the Path2.
  63671. * @returns the Path2.
  63672. */
  63673. close(): Path2;
  63674. /**
  63675. * Gets the sum of the distance between each sequential point in the path
  63676. * @returns the Path2 total length (float).
  63677. */
  63678. length(): number;
  63679. /**
  63680. * Gets the points which construct the path
  63681. * @returns the Path2 internal array of points.
  63682. */
  63683. getPoints(): Vector2[];
  63684. /**
  63685. * Retreives the point at the distance aways from the starting point
  63686. * @param normalizedLengthPosition the length along the path to retreive the point from
  63687. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  63688. */
  63689. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  63690. /**
  63691. * Creates a new path starting from an x and y position
  63692. * @param x starting x value
  63693. * @param y starting y value
  63694. * @returns a new Path2 starting at the coordinates (x, y).
  63695. */
  63696. static StartingAt(x: number, y: number): Path2;
  63697. }
  63698. /**
  63699. * Represents a 3D path made up of multiple 3D points
  63700. */
  63701. export class Path3D {
  63702. /**
  63703. * an array of Vector3, the curve axis of the Path3D
  63704. */
  63705. path: Vector3[];
  63706. private _curve;
  63707. private _distances;
  63708. private _tangents;
  63709. private _normals;
  63710. private _binormals;
  63711. private _raw;
  63712. /**
  63713. * new Path3D(path, normal, raw)
  63714. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  63715. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  63716. * @param path an array of Vector3, the curve axis of the Path3D
  63717. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  63718. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  63719. */
  63720. constructor(
  63721. /**
  63722. * an array of Vector3, the curve axis of the Path3D
  63723. */
  63724. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  63725. /**
  63726. * Returns the Path3D array of successive Vector3 designing its curve.
  63727. * @returns the Path3D array of successive Vector3 designing its curve.
  63728. */
  63729. getCurve(): Vector3[];
  63730. /**
  63731. * Returns an array populated with tangent vectors on each Path3D curve point.
  63732. * @returns an array populated with tangent vectors on each Path3D curve point.
  63733. */
  63734. getTangents(): Vector3[];
  63735. /**
  63736. * Returns an array populated with normal vectors on each Path3D curve point.
  63737. * @returns an array populated with normal vectors on each Path3D curve point.
  63738. */
  63739. getNormals(): Vector3[];
  63740. /**
  63741. * Returns an array populated with binormal vectors on each Path3D curve point.
  63742. * @returns an array populated with binormal vectors on each Path3D curve point.
  63743. */
  63744. getBinormals(): Vector3[];
  63745. /**
  63746. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  63747. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  63748. */
  63749. getDistances(): number[];
  63750. /**
  63751. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  63752. * @param path path which all values are copied into the curves points
  63753. * @param firstNormal which should be projected onto the curve
  63754. * @returns the same object updated.
  63755. */
  63756. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  63757. private _compute;
  63758. private _getFirstNonNullVector;
  63759. private _getLastNonNullVector;
  63760. private _normalVector;
  63761. }
  63762. /**
  63763. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63764. * A Curve3 is designed from a series of successive Vector3.
  63765. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  63766. */
  63767. export class Curve3 {
  63768. private _points;
  63769. private _length;
  63770. /**
  63771. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  63772. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  63773. * @param v1 (Vector3) the control point
  63774. * @param v2 (Vector3) the end point of the Quadratic Bezier
  63775. * @param nbPoints (integer) the wanted number of points in the curve
  63776. * @returns the created Curve3
  63777. */
  63778. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63779. /**
  63780. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  63781. * @param v0 (Vector3) the origin point of the Cubic Bezier
  63782. * @param v1 (Vector3) the first control point
  63783. * @param v2 (Vector3) the second control point
  63784. * @param v3 (Vector3) the end point of the Cubic Bezier
  63785. * @param nbPoints (integer) the wanted number of points in the curve
  63786. * @returns the created Curve3
  63787. */
  63788. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63789. /**
  63790. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  63791. * @param p1 (Vector3) the origin point of the Hermite Spline
  63792. * @param t1 (Vector3) the tangent vector at the origin point
  63793. * @param p2 (Vector3) the end point of the Hermite Spline
  63794. * @param t2 (Vector3) the tangent vector at the end point
  63795. * @param nbPoints (integer) the wanted number of points in the curve
  63796. * @returns the created Curve3
  63797. */
  63798. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63799. /**
  63800. * Returns a Curve3 object along a CatmullRom Spline curve :
  63801. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  63802. * @param nbPoints (integer) the wanted number of points between each curve control points
  63803. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  63804. * @returns the created Curve3
  63805. */
  63806. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  63807. /**
  63808. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63809. * A Curve3 is designed from a series of successive Vector3.
  63810. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  63811. * @param points points which make up the curve
  63812. */
  63813. constructor(points: Vector3[]);
  63814. /**
  63815. * @returns the Curve3 stored array of successive Vector3
  63816. */
  63817. getPoints(): Vector3[];
  63818. /**
  63819. * @returns the computed length (float) of the curve.
  63820. */
  63821. length(): number;
  63822. /**
  63823. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  63824. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  63825. * curveA and curveB keep unchanged.
  63826. * @param curve the curve to continue from this curve
  63827. * @returns the newly constructed curve
  63828. */
  63829. continue(curve: DeepImmutable<Curve3>): Curve3;
  63830. private _computeLength;
  63831. }
  63832. /**
  63833. * Contains position and normal vectors for a vertex
  63834. */
  63835. export class PositionNormalVertex {
  63836. /** the position of the vertex (defaut: 0,0,0) */
  63837. position: Vector3;
  63838. /** the normal of the vertex (defaut: 0,1,0) */
  63839. normal: Vector3;
  63840. /**
  63841. * Creates a PositionNormalVertex
  63842. * @param position the position of the vertex (defaut: 0,0,0)
  63843. * @param normal the normal of the vertex (defaut: 0,1,0)
  63844. */
  63845. constructor(
  63846. /** the position of the vertex (defaut: 0,0,0) */
  63847. position?: Vector3,
  63848. /** the normal of the vertex (defaut: 0,1,0) */
  63849. normal?: Vector3);
  63850. /**
  63851. * Clones the PositionNormalVertex
  63852. * @returns the cloned PositionNormalVertex
  63853. */
  63854. clone(): PositionNormalVertex;
  63855. }
  63856. /**
  63857. * Contains position, normal and uv vectors for a vertex
  63858. */
  63859. export class PositionNormalTextureVertex {
  63860. /** the position of the vertex (defaut: 0,0,0) */
  63861. position: Vector3;
  63862. /** the normal of the vertex (defaut: 0,1,0) */
  63863. normal: Vector3;
  63864. /** the uv of the vertex (default: 0,0) */
  63865. uv: Vector2;
  63866. /**
  63867. * Creates a PositionNormalTextureVertex
  63868. * @param position the position of the vertex (defaut: 0,0,0)
  63869. * @param normal the normal of the vertex (defaut: 0,1,0)
  63870. * @param uv the uv of the vertex (default: 0,0)
  63871. */
  63872. constructor(
  63873. /** the position of the vertex (defaut: 0,0,0) */
  63874. position?: Vector3,
  63875. /** the normal of the vertex (defaut: 0,1,0) */
  63876. normal?: Vector3,
  63877. /** the uv of the vertex (default: 0,0) */
  63878. uv?: Vector2);
  63879. /**
  63880. * Clones the PositionNormalTextureVertex
  63881. * @returns the cloned PositionNormalTextureVertex
  63882. */
  63883. clone(): PositionNormalTextureVertex;
  63884. }
  63885. /**
  63886. * @hidden
  63887. */
  63888. export class Tmp {
  63889. static Color3: Color3[];
  63890. static Color4: Color4[];
  63891. static Vector2: Vector2[];
  63892. static Vector3: Vector3[];
  63893. static Vector4: Vector4[];
  63894. static Quaternion: Quaternion[];
  63895. static Matrix: Matrix[];
  63896. }
  63897. }
  63898. declare module BABYLON {
  63899. /**
  63900. * Class used to enable access to offline support
  63901. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63902. */
  63903. export interface IOfflineProvider {
  63904. /**
  63905. * Gets a boolean indicating if scene must be saved in the database
  63906. */
  63907. enableSceneOffline: boolean;
  63908. /**
  63909. * Gets a boolean indicating if textures must be saved in the database
  63910. */
  63911. enableTexturesOffline: boolean;
  63912. /**
  63913. * Open the offline support and make it available
  63914. * @param successCallback defines the callback to call on success
  63915. * @param errorCallback defines the callback to call on error
  63916. */
  63917. open(successCallback: () => void, errorCallback: () => void): void;
  63918. /**
  63919. * Loads an image from the offline support
  63920. * @param url defines the url to load from
  63921. * @param image defines the target DOM image
  63922. */
  63923. loadImage(url: string, image: HTMLImageElement): void;
  63924. /**
  63925. * Loads a file from offline support
  63926. * @param url defines the URL to load from
  63927. * @param sceneLoaded defines a callback to call on success
  63928. * @param progressCallBack defines a callback to call when progress changed
  63929. * @param errorCallback defines a callback to call on error
  63930. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63931. */
  63932. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63933. }
  63934. }
  63935. declare module BABYLON {
  63936. /**
  63937. * A class serves as a medium between the observable and its observers
  63938. */
  63939. export class EventState {
  63940. /**
  63941. * Create a new EventState
  63942. * @param mask defines the mask associated with this state
  63943. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63944. * @param target defines the original target of the state
  63945. * @param currentTarget defines the current target of the state
  63946. */
  63947. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63948. /**
  63949. * Initialize the current event state
  63950. * @param mask defines the mask associated with this state
  63951. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63952. * @param target defines the original target of the state
  63953. * @param currentTarget defines the current target of the state
  63954. * @returns the current event state
  63955. */
  63956. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  63957. /**
  63958. * An Observer can set this property to true to prevent subsequent observers of being notified
  63959. */
  63960. skipNextObservers: boolean;
  63961. /**
  63962. * Get the mask value that were used to trigger the event corresponding to this EventState object
  63963. */
  63964. mask: number;
  63965. /**
  63966. * The object that originally notified the event
  63967. */
  63968. target?: any;
  63969. /**
  63970. * The current object in the bubbling phase
  63971. */
  63972. currentTarget?: any;
  63973. /**
  63974. * This will be populated with the return value of the last function that was executed.
  63975. * If it is the first function in the callback chain it will be the event data.
  63976. */
  63977. lastReturnValue?: any;
  63978. }
  63979. /**
  63980. * Represent an Observer registered to a given Observable object.
  63981. */
  63982. export class Observer<T> {
  63983. /**
  63984. * Defines the callback to call when the observer is notified
  63985. */
  63986. callback: (eventData: T, eventState: EventState) => void;
  63987. /**
  63988. * Defines the mask of the observer (used to filter notifications)
  63989. */
  63990. mask: number;
  63991. /**
  63992. * Defines the current scope used to restore the JS context
  63993. */
  63994. scope: any;
  63995. /** @hidden */
  63996. _willBeUnregistered: boolean;
  63997. /**
  63998. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  63999. */
  64000. unregisterOnNextCall: boolean;
  64001. /**
  64002. * Creates a new observer
  64003. * @param callback defines the callback to call when the observer is notified
  64004. * @param mask defines the mask of the observer (used to filter notifications)
  64005. * @param scope defines the current scope used to restore the JS context
  64006. */
  64007. constructor(
  64008. /**
  64009. * Defines the callback to call when the observer is notified
  64010. */
  64011. callback: (eventData: T, eventState: EventState) => void,
  64012. /**
  64013. * Defines the mask of the observer (used to filter notifications)
  64014. */
  64015. mask: number,
  64016. /**
  64017. * Defines the current scope used to restore the JS context
  64018. */
  64019. scope?: any);
  64020. }
  64021. /**
  64022. * Represent a list of observers registered to multiple Observables object.
  64023. */
  64024. export class MultiObserver<T> {
  64025. private _observers;
  64026. private _observables;
  64027. /**
  64028. * Release associated resources
  64029. */
  64030. dispose(): void;
  64031. /**
  64032. * Raise a callback when one of the observable will notify
  64033. * @param observables defines a list of observables to watch
  64034. * @param callback defines the callback to call on notification
  64035. * @param mask defines the mask used to filter notifications
  64036. * @param scope defines the current scope used to restore the JS context
  64037. * @returns the new MultiObserver
  64038. */
  64039. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  64040. }
  64041. /**
  64042. * The Observable class is a simple implementation of the Observable pattern.
  64043. *
  64044. * 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.
  64045. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  64046. * 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).
  64047. * 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.
  64048. */
  64049. export class Observable<T> {
  64050. private _observers;
  64051. private _eventState;
  64052. private _onObserverAdded;
  64053. /**
  64054. * Creates a new observable
  64055. * @param onObserverAdded defines a callback to call when a new observer is added
  64056. */
  64057. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  64058. /**
  64059. * Create a new Observer with the specified callback
  64060. * @param callback the callback that will be executed for that Observer
  64061. * @param mask the mask used to filter observers
  64062. * @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.
  64063. * @param scope optional scope for the callback to be called from
  64064. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  64065. * @returns the new observer created for the callback
  64066. */
  64067. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  64068. /**
  64069. * Create a new Observer with the specified callback and unregisters after the next notification
  64070. * @param callback the callback that will be executed for that Observer
  64071. * @returns the new observer created for the callback
  64072. */
  64073. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  64074. /**
  64075. * Remove an Observer from the Observable object
  64076. * @param observer the instance of the Observer to remove
  64077. * @returns false if it doesn't belong to this Observable
  64078. */
  64079. remove(observer: Nullable<Observer<T>>): boolean;
  64080. /**
  64081. * Remove a callback from the Observable object
  64082. * @param callback the callback to remove
  64083. * @param scope optional scope. If used only the callbacks with this scope will be removed
  64084. * @returns false if it doesn't belong to this Observable
  64085. */
  64086. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  64087. private _deferUnregister;
  64088. private _remove;
  64089. /**
  64090. * Moves the observable to the top of the observer list making it get called first when notified
  64091. * @param observer the observer to move
  64092. */
  64093. makeObserverTopPriority(observer: Observer<T>): void;
  64094. /**
  64095. * Moves the observable to the bottom of the observer list making it get called last when notified
  64096. * @param observer the observer to move
  64097. */
  64098. makeObserverBottomPriority(observer: Observer<T>): void;
  64099. /**
  64100. * Notify all Observers by calling their respective callback with the given data
  64101. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  64102. * @param eventData defines the data to send to all observers
  64103. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  64104. * @param target defines the original target of the state
  64105. * @param currentTarget defines the current target of the state
  64106. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  64107. */
  64108. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  64109. /**
  64110. * Calling this will execute each callback, expecting it to be a promise or return a value.
  64111. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  64112. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  64113. * and it is crucial that all callbacks will be executed.
  64114. * The order of the callbacks is kept, callbacks are not executed parallel.
  64115. *
  64116. * @param eventData The data to be sent to each callback
  64117. * @param mask is used to filter observers defaults to -1
  64118. * @param target defines the callback target (see EventState)
  64119. * @param currentTarget defines he current object in the bubbling phase
  64120. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  64121. */
  64122. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  64123. /**
  64124. * Notify a specific observer
  64125. * @param observer defines the observer to notify
  64126. * @param eventData defines the data to be sent to each callback
  64127. * @param mask is used to filter observers defaults to -1
  64128. */
  64129. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  64130. /**
  64131. * Gets a boolean indicating if the observable has at least one observer
  64132. * @returns true is the Observable has at least one Observer registered
  64133. */
  64134. hasObservers(): boolean;
  64135. /**
  64136. * Clear the list of observers
  64137. */
  64138. clear(): void;
  64139. /**
  64140. * Clone the current observable
  64141. * @returns a new observable
  64142. */
  64143. clone(): Observable<T>;
  64144. /**
  64145. * Does this observable handles observer registered with a given mask
  64146. * @param mask defines the mask to be tested
  64147. * @return whether or not one observer registered with the given mask is handeled
  64148. **/
  64149. hasSpecificMask(mask?: number): boolean;
  64150. }
  64151. }
  64152. declare module BABYLON {
  64153. /**
  64154. * Class used to help managing file picking and drag'n'drop
  64155. * File Storage
  64156. */
  64157. export class FilesInputStore {
  64158. /**
  64159. * List of files ready to be loaded
  64160. */
  64161. static FilesToLoad: {
  64162. [key: string]: File;
  64163. };
  64164. }
  64165. }
  64166. declare module BABYLON {
  64167. /** Defines the cross module used constants to avoid circular dependncies */
  64168. export class Constants {
  64169. /** Defines that alpha blending is disabled */
  64170. static readonly ALPHA_DISABLE: number;
  64171. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  64172. static readonly ALPHA_ADD: number;
  64173. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  64174. static readonly ALPHA_COMBINE: number;
  64175. /** Defines that alpha blending to DEST - SRC * DEST */
  64176. static readonly ALPHA_SUBTRACT: number;
  64177. /** Defines that alpha blending to SRC * DEST */
  64178. static readonly ALPHA_MULTIPLY: number;
  64179. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  64180. static readonly ALPHA_MAXIMIZED: number;
  64181. /** Defines that alpha blending to SRC + DEST */
  64182. static readonly ALPHA_ONEONE: number;
  64183. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  64184. static readonly ALPHA_PREMULTIPLIED: number;
  64185. /**
  64186. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  64187. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  64188. */
  64189. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  64190. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  64191. static readonly ALPHA_INTERPOLATE: number;
  64192. /**
  64193. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  64194. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  64195. */
  64196. static readonly ALPHA_SCREENMODE: number;
  64197. /** Defines that the ressource is not delayed*/
  64198. static readonly DELAYLOADSTATE_NONE: number;
  64199. /** Defines that the ressource was successfully delay loaded */
  64200. static readonly DELAYLOADSTATE_LOADED: number;
  64201. /** Defines that the ressource is currently delay loading */
  64202. static readonly DELAYLOADSTATE_LOADING: number;
  64203. /** Defines that the ressource is delayed and has not started loading */
  64204. static readonly DELAYLOADSTATE_NOTLOADED: number;
  64205. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  64206. static readonly NEVER: number;
  64207. /** 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 */
  64208. static readonly ALWAYS: number;
  64209. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  64210. static readonly LESS: number;
  64211. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  64212. static readonly EQUAL: number;
  64213. /** 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 */
  64214. static readonly LEQUAL: number;
  64215. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  64216. static readonly GREATER: number;
  64217. /** 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 */
  64218. static readonly GEQUAL: number;
  64219. /** 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 */
  64220. static readonly NOTEQUAL: number;
  64221. /** Passed to stencilOperation to specify that stencil value must be kept */
  64222. static readonly KEEP: number;
  64223. /** Passed to stencilOperation to specify that stencil value must be replaced */
  64224. static readonly REPLACE: number;
  64225. /** Passed to stencilOperation to specify that stencil value must be incremented */
  64226. static readonly INCR: number;
  64227. /** Passed to stencilOperation to specify that stencil value must be decremented */
  64228. static readonly DECR: number;
  64229. /** Passed to stencilOperation to specify that stencil value must be inverted */
  64230. static readonly INVERT: number;
  64231. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  64232. static readonly INCR_WRAP: number;
  64233. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  64234. static readonly DECR_WRAP: number;
  64235. /** Texture is not repeating outside of 0..1 UVs */
  64236. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  64237. /** Texture is repeating outside of 0..1 UVs */
  64238. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  64239. /** Texture is repeating and mirrored */
  64240. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  64241. /** ALPHA */
  64242. static readonly TEXTUREFORMAT_ALPHA: number;
  64243. /** LUMINANCE */
  64244. static readonly TEXTUREFORMAT_LUMINANCE: number;
  64245. /** LUMINANCE_ALPHA */
  64246. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  64247. /** RGB */
  64248. static readonly TEXTUREFORMAT_RGB: number;
  64249. /** RGBA */
  64250. static readonly TEXTUREFORMAT_RGBA: number;
  64251. /** RED */
  64252. static readonly TEXTUREFORMAT_RED: number;
  64253. /** RED (2nd reference) */
  64254. static readonly TEXTUREFORMAT_R: number;
  64255. /** RG */
  64256. static readonly TEXTUREFORMAT_RG: number;
  64257. /** RED_INTEGER */
  64258. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  64259. /** RED_INTEGER (2nd reference) */
  64260. static readonly TEXTUREFORMAT_R_INTEGER: number;
  64261. /** RG_INTEGER */
  64262. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  64263. /** RGB_INTEGER */
  64264. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  64265. /** RGBA_INTEGER */
  64266. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  64267. /** UNSIGNED_BYTE */
  64268. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  64269. /** UNSIGNED_BYTE (2nd reference) */
  64270. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  64271. /** FLOAT */
  64272. static readonly TEXTURETYPE_FLOAT: number;
  64273. /** HALF_FLOAT */
  64274. static readonly TEXTURETYPE_HALF_FLOAT: number;
  64275. /** BYTE */
  64276. static readonly TEXTURETYPE_BYTE: number;
  64277. /** SHORT */
  64278. static readonly TEXTURETYPE_SHORT: number;
  64279. /** UNSIGNED_SHORT */
  64280. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  64281. /** INT */
  64282. static readonly TEXTURETYPE_INT: number;
  64283. /** UNSIGNED_INT */
  64284. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  64285. /** UNSIGNED_SHORT_4_4_4_4 */
  64286. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  64287. /** UNSIGNED_SHORT_5_5_5_1 */
  64288. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  64289. /** UNSIGNED_SHORT_5_6_5 */
  64290. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  64291. /** UNSIGNED_INT_2_10_10_10_REV */
  64292. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  64293. /** UNSIGNED_INT_24_8 */
  64294. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  64295. /** UNSIGNED_INT_10F_11F_11F_REV */
  64296. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  64297. /** UNSIGNED_INT_5_9_9_9_REV */
  64298. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  64299. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  64300. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  64301. /** nearest is mag = nearest and min = nearest and mip = linear */
  64302. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  64303. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64304. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  64305. /** Trilinear is mag = linear and min = linear and mip = linear */
  64306. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  64307. /** nearest is mag = nearest and min = nearest and mip = linear */
  64308. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  64309. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64310. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  64311. /** Trilinear is mag = linear and min = linear and mip = linear */
  64312. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  64313. /** mag = nearest and min = nearest and mip = nearest */
  64314. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  64315. /** mag = nearest and min = linear and mip = nearest */
  64316. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  64317. /** mag = nearest and min = linear and mip = linear */
  64318. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  64319. /** mag = nearest and min = linear and mip = none */
  64320. static readonly TEXTURE_NEAREST_LINEAR: number;
  64321. /** mag = nearest and min = nearest and mip = none */
  64322. static readonly TEXTURE_NEAREST_NEAREST: number;
  64323. /** mag = linear and min = nearest and mip = nearest */
  64324. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  64325. /** mag = linear and min = nearest and mip = linear */
  64326. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  64327. /** mag = linear and min = linear and mip = none */
  64328. static readonly TEXTURE_LINEAR_LINEAR: number;
  64329. /** mag = linear and min = nearest and mip = none */
  64330. static readonly TEXTURE_LINEAR_NEAREST: number;
  64331. /** Explicit coordinates mode */
  64332. static readonly TEXTURE_EXPLICIT_MODE: number;
  64333. /** Spherical coordinates mode */
  64334. static readonly TEXTURE_SPHERICAL_MODE: number;
  64335. /** Planar coordinates mode */
  64336. static readonly TEXTURE_PLANAR_MODE: number;
  64337. /** Cubic coordinates mode */
  64338. static readonly TEXTURE_CUBIC_MODE: number;
  64339. /** Projection coordinates mode */
  64340. static readonly TEXTURE_PROJECTION_MODE: number;
  64341. /** Skybox coordinates mode */
  64342. static readonly TEXTURE_SKYBOX_MODE: number;
  64343. /** Inverse Cubic coordinates mode */
  64344. static readonly TEXTURE_INVCUBIC_MODE: number;
  64345. /** Equirectangular coordinates mode */
  64346. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  64347. /** Equirectangular Fixed coordinates mode */
  64348. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  64349. /** Equirectangular Fixed Mirrored coordinates mode */
  64350. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  64351. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  64352. static readonly SCALEMODE_FLOOR: number;
  64353. /** Defines that texture rescaling will look for the nearest power of 2 size */
  64354. static readonly SCALEMODE_NEAREST: number;
  64355. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  64356. static readonly SCALEMODE_CEILING: number;
  64357. /**
  64358. * The dirty texture flag value
  64359. */
  64360. static readonly MATERIAL_TextureDirtyFlag: number;
  64361. /**
  64362. * The dirty light flag value
  64363. */
  64364. static readonly MATERIAL_LightDirtyFlag: number;
  64365. /**
  64366. * The dirty fresnel flag value
  64367. */
  64368. static readonly MATERIAL_FresnelDirtyFlag: number;
  64369. /**
  64370. * The dirty attribute flag value
  64371. */
  64372. static readonly MATERIAL_AttributesDirtyFlag: number;
  64373. /**
  64374. * The dirty misc flag value
  64375. */
  64376. static readonly MATERIAL_MiscDirtyFlag: number;
  64377. /**
  64378. * The all dirty flag value
  64379. */
  64380. static readonly MATERIAL_AllDirtyFlag: number;
  64381. /**
  64382. * Returns the triangle fill mode
  64383. */
  64384. static readonly MATERIAL_TriangleFillMode: number;
  64385. /**
  64386. * Returns the wireframe mode
  64387. */
  64388. static readonly MATERIAL_WireFrameFillMode: number;
  64389. /**
  64390. * Returns the point fill mode
  64391. */
  64392. static readonly MATERIAL_PointFillMode: number;
  64393. /**
  64394. * Returns the point list draw mode
  64395. */
  64396. static readonly MATERIAL_PointListDrawMode: number;
  64397. /**
  64398. * Returns the line list draw mode
  64399. */
  64400. static readonly MATERIAL_LineListDrawMode: number;
  64401. /**
  64402. * Returns the line loop draw mode
  64403. */
  64404. static readonly MATERIAL_LineLoopDrawMode: number;
  64405. /**
  64406. * Returns the line strip draw mode
  64407. */
  64408. static readonly MATERIAL_LineStripDrawMode: number;
  64409. /**
  64410. * Returns the triangle strip draw mode
  64411. */
  64412. static readonly MATERIAL_TriangleStripDrawMode: number;
  64413. /**
  64414. * Returns the triangle fan draw mode
  64415. */
  64416. static readonly MATERIAL_TriangleFanDrawMode: number;
  64417. /**
  64418. * Stores the clock-wise side orientation
  64419. */
  64420. static readonly MATERIAL_ClockWiseSideOrientation: number;
  64421. /**
  64422. * Stores the counter clock-wise side orientation
  64423. */
  64424. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  64425. /**
  64426. * Nothing
  64427. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64428. */
  64429. static readonly ACTION_NothingTrigger: number;
  64430. /**
  64431. * On pick
  64432. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64433. */
  64434. static readonly ACTION_OnPickTrigger: number;
  64435. /**
  64436. * On left pick
  64437. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64438. */
  64439. static readonly ACTION_OnLeftPickTrigger: number;
  64440. /**
  64441. * On right pick
  64442. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64443. */
  64444. static readonly ACTION_OnRightPickTrigger: number;
  64445. /**
  64446. * On center pick
  64447. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64448. */
  64449. static readonly ACTION_OnCenterPickTrigger: number;
  64450. /**
  64451. * On pick down
  64452. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64453. */
  64454. static readonly ACTION_OnPickDownTrigger: number;
  64455. /**
  64456. * On double pick
  64457. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64458. */
  64459. static readonly ACTION_OnDoublePickTrigger: number;
  64460. /**
  64461. * On pick up
  64462. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64463. */
  64464. static readonly ACTION_OnPickUpTrigger: number;
  64465. /**
  64466. * On pick out.
  64467. * This trigger will only be raised if you also declared a OnPickDown
  64468. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64469. */
  64470. static readonly ACTION_OnPickOutTrigger: number;
  64471. /**
  64472. * On long press
  64473. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64474. */
  64475. static readonly ACTION_OnLongPressTrigger: number;
  64476. /**
  64477. * On pointer over
  64478. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64479. */
  64480. static readonly ACTION_OnPointerOverTrigger: number;
  64481. /**
  64482. * On pointer out
  64483. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64484. */
  64485. static readonly ACTION_OnPointerOutTrigger: number;
  64486. /**
  64487. * On every frame
  64488. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64489. */
  64490. static readonly ACTION_OnEveryFrameTrigger: number;
  64491. /**
  64492. * On intersection enter
  64493. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64494. */
  64495. static readonly ACTION_OnIntersectionEnterTrigger: number;
  64496. /**
  64497. * On intersection exit
  64498. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64499. */
  64500. static readonly ACTION_OnIntersectionExitTrigger: number;
  64501. /**
  64502. * On key down
  64503. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64504. */
  64505. static readonly ACTION_OnKeyDownTrigger: number;
  64506. /**
  64507. * On key up
  64508. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64509. */
  64510. static readonly ACTION_OnKeyUpTrigger: number;
  64511. /**
  64512. * Billboard mode will only apply to Y axis
  64513. */
  64514. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  64515. /**
  64516. * Billboard mode will apply to all axes
  64517. */
  64518. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  64519. /**
  64520. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  64521. */
  64522. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  64523. /**
  64524. * Gets or sets base Assets URL
  64525. */
  64526. static readonly PARTICLES_BaseAssetsUrl: string;
  64527. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  64528. * Test order :
  64529. * Is the bounding sphere outside the frustum ?
  64530. * If not, are the bounding box vertices outside the frustum ?
  64531. * It not, then the cullable object is in the frustum.
  64532. */
  64533. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  64534. /** Culling strategy : Bounding Sphere Only.
  64535. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  64536. * It's also less accurate than the standard because some not visible objects can still be selected.
  64537. * Test : is the bounding sphere outside the frustum ?
  64538. * If not, then the cullable object is in the frustum.
  64539. */
  64540. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  64541. /** Culling strategy : Optimistic Inclusion.
  64542. * This in an inclusion test first, then the standard exclusion test.
  64543. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  64544. * 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.
  64545. * Anyway, it's as accurate as the standard strategy.
  64546. * Test :
  64547. * Is the cullable object bounding sphere center in the frustum ?
  64548. * If not, apply the default culling strategy.
  64549. */
  64550. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  64551. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  64552. * This in an inclusion test first, then the bounding sphere only exclusion test.
  64553. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  64554. * 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.
  64555. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  64556. * Test :
  64557. * Is the cullable object bounding sphere center in the frustum ?
  64558. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  64559. */
  64560. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  64561. /**
  64562. * No logging while loading
  64563. */
  64564. static readonly SCENELOADER_NO_LOGGING: number;
  64565. /**
  64566. * Minimal logging while loading
  64567. */
  64568. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  64569. /**
  64570. * Summary logging while loading
  64571. */
  64572. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  64573. /**
  64574. * Detailled logging while loading
  64575. */
  64576. static readonly SCENELOADER_DETAILED_LOGGING: number;
  64577. }
  64578. }
  64579. declare module BABYLON {
  64580. /**
  64581. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64582. * Babylon.js
  64583. */
  64584. export class DomManagement {
  64585. /**
  64586. * Checks if the window object exists
  64587. * @returns true if the window object exists
  64588. */
  64589. static IsWindowObjectExist(): boolean;
  64590. /**
  64591. * Extracts text content from a DOM element hierarchy
  64592. * @param element defines the root element
  64593. * @returns a string
  64594. */
  64595. static GetDOMTextContent(element: HTMLElement): string;
  64596. }
  64597. }
  64598. declare module BABYLON {
  64599. /**
  64600. * Logger used througouht the application to allow configuration of
  64601. * the log level required for the messages.
  64602. */
  64603. export class Logger {
  64604. /**
  64605. * No log
  64606. */
  64607. static readonly NoneLogLevel: number;
  64608. /**
  64609. * Only message logs
  64610. */
  64611. static readonly MessageLogLevel: number;
  64612. /**
  64613. * Only warning logs
  64614. */
  64615. static readonly WarningLogLevel: number;
  64616. /**
  64617. * Only error logs
  64618. */
  64619. static readonly ErrorLogLevel: number;
  64620. /**
  64621. * All logs
  64622. */
  64623. static readonly AllLogLevel: number;
  64624. private static _LogCache;
  64625. /**
  64626. * Gets a value indicating the number of loading errors
  64627. * @ignorenaming
  64628. */
  64629. static errorsCount: number;
  64630. /**
  64631. * Callback called when a new log is added
  64632. */
  64633. static OnNewCacheEntry: (entry: string) => void;
  64634. private static _AddLogEntry;
  64635. private static _FormatMessage;
  64636. private static _LogDisabled;
  64637. private static _LogEnabled;
  64638. private static _WarnDisabled;
  64639. private static _WarnEnabled;
  64640. private static _ErrorDisabled;
  64641. private static _ErrorEnabled;
  64642. /**
  64643. * Log a message to the console
  64644. */
  64645. static Log: (message: string) => void;
  64646. /**
  64647. * Write a warning message to the console
  64648. */
  64649. static Warn: (message: string) => void;
  64650. /**
  64651. * Write an error message to the console
  64652. */
  64653. static Error: (message: string) => void;
  64654. /**
  64655. * Gets current log cache (list of logs)
  64656. */
  64657. static readonly LogCache: string;
  64658. /**
  64659. * Clears the log cache
  64660. */
  64661. static ClearLogCache(): void;
  64662. /**
  64663. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64664. */
  64665. static LogLevels: number;
  64666. }
  64667. }
  64668. declare module BABYLON {
  64669. /** @hidden */
  64670. export class _TypeStore {
  64671. /** @hidden */
  64672. static RegisteredTypes: {
  64673. [key: string]: Object;
  64674. };
  64675. /** @hidden */
  64676. static GetClass(fqdn: string): any;
  64677. }
  64678. }
  64679. declare module BABYLON {
  64680. /**
  64681. * Class containing a set of static utilities functions for deep copy.
  64682. */
  64683. export class DeepCopier {
  64684. /**
  64685. * Tries to copy an object by duplicating every property
  64686. * @param source defines the source object
  64687. * @param destination defines the target object
  64688. * @param doNotCopyList defines a list of properties to avoid
  64689. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64690. */
  64691. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64692. }
  64693. }
  64694. declare module BABYLON {
  64695. /**
  64696. * Class containing a set of static utilities functions for precision date
  64697. */
  64698. export class PrecisionDate {
  64699. /**
  64700. * Gets either window.performance.now() if supported or Date.now() else
  64701. */
  64702. static readonly Now: number;
  64703. }
  64704. }
  64705. declare module BABYLON {
  64706. /** @hidden */
  64707. export class _DevTools {
  64708. static WarnImport(name: string): string;
  64709. }
  64710. }
  64711. declare module BABYLON {
  64712. /**
  64713. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64714. */
  64715. export class WebRequest {
  64716. private _xhr;
  64717. /**
  64718. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64719. * i.e. when loading files, where the server/service expects an Authorization header
  64720. */
  64721. static CustomRequestHeaders: {
  64722. [key: string]: string;
  64723. };
  64724. /**
  64725. * Add callback functions in this array to update all the requests before they get sent to the network
  64726. */
  64727. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  64728. private _injectCustomRequestHeaders;
  64729. /**
  64730. * Gets or sets a function to be called when loading progress changes
  64731. */
  64732. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64733. /**
  64734. * Returns client's state
  64735. */
  64736. readonly readyState: number;
  64737. /**
  64738. * Returns client's status
  64739. */
  64740. readonly status: number;
  64741. /**
  64742. * Returns client's status as a text
  64743. */
  64744. readonly statusText: string;
  64745. /**
  64746. * Returns client's response
  64747. */
  64748. readonly response: any;
  64749. /**
  64750. * Returns client's response url
  64751. */
  64752. readonly responseURL: string;
  64753. /**
  64754. * Returns client's response as text
  64755. */
  64756. readonly responseText: string;
  64757. /**
  64758. * Gets or sets the expected response type
  64759. */
  64760. responseType: XMLHttpRequestResponseType;
  64761. /** @hidden */
  64762. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64763. /** @hidden */
  64764. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64765. /**
  64766. * Cancels any network activity
  64767. */
  64768. abort(): void;
  64769. /**
  64770. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64771. * @param body defines an optional request body
  64772. */
  64773. send(body?: Document | BodyInit | null): void;
  64774. /**
  64775. * Sets the request method, request URL
  64776. * @param method defines the method to use (GET, POST, etc..)
  64777. * @param url defines the url to connect with
  64778. */
  64779. open(method: string, url: string): void;
  64780. }
  64781. }
  64782. declare module BABYLON {
  64783. /**
  64784. * Class used to evalaute queries containing `and` and `or` operators
  64785. */
  64786. export class AndOrNotEvaluator {
  64787. /**
  64788. * Evaluate a query
  64789. * @param query defines the query to evaluate
  64790. * @param evaluateCallback defines the callback used to filter result
  64791. * @returns true if the query matches
  64792. */
  64793. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  64794. private static _HandleParenthesisContent;
  64795. private static _SimplifyNegation;
  64796. }
  64797. }
  64798. declare module BABYLON {
  64799. /**
  64800. * Class used to store custom tags
  64801. */
  64802. export class Tags {
  64803. /**
  64804. * Adds support for tags on the given object
  64805. * @param obj defines the object to use
  64806. */
  64807. static EnableFor(obj: any): void;
  64808. /**
  64809. * Removes tags support
  64810. * @param obj defines the object to use
  64811. */
  64812. static DisableFor(obj: any): void;
  64813. /**
  64814. * Gets a boolean indicating if the given object has tags
  64815. * @param obj defines the object to use
  64816. * @returns a boolean
  64817. */
  64818. static HasTags(obj: any): boolean;
  64819. /**
  64820. * Gets the tags available on a given object
  64821. * @param obj defines the object to use
  64822. * @param asString defines if the tags must be returned as a string instead of an array of strings
  64823. * @returns the tags
  64824. */
  64825. static GetTags(obj: any, asString?: boolean): any;
  64826. /**
  64827. * Adds tags to an object
  64828. * @param obj defines the object to use
  64829. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  64830. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  64831. */
  64832. static AddTagsTo(obj: any, tagsString: string): void;
  64833. /**
  64834. * @hidden
  64835. */
  64836. static _AddTagTo(obj: any, tag: string): void;
  64837. /**
  64838. * Removes specific tags from a specific object
  64839. * @param obj defines the object to use
  64840. * @param tagsString defines the tags to remove
  64841. */
  64842. static RemoveTagsFrom(obj: any, tagsString: string): void;
  64843. /**
  64844. * @hidden
  64845. */
  64846. static _RemoveTagFrom(obj: any, tag: string): void;
  64847. /**
  64848. * Defines if tags hosted on an object match a given query
  64849. * @param obj defines the object to use
  64850. * @param tagsQuery defines the tag query
  64851. * @returns a boolean
  64852. */
  64853. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  64854. }
  64855. }
  64856. declare module BABYLON {
  64857. /**
  64858. * Manages the defines for the Material
  64859. */
  64860. export class MaterialDefines {
  64861. private _keys;
  64862. private _isDirty;
  64863. /** @hidden */
  64864. _renderId: number;
  64865. /** @hidden */
  64866. _areLightsDirty: boolean;
  64867. /** @hidden */
  64868. _areAttributesDirty: boolean;
  64869. /** @hidden */
  64870. _areTexturesDirty: boolean;
  64871. /** @hidden */
  64872. _areFresnelDirty: boolean;
  64873. /** @hidden */
  64874. _areMiscDirty: boolean;
  64875. /** @hidden */
  64876. _areImageProcessingDirty: boolean;
  64877. /** @hidden */
  64878. _normals: boolean;
  64879. /** @hidden */
  64880. _uvs: boolean;
  64881. /** @hidden */
  64882. _needNormals: boolean;
  64883. /** @hidden */
  64884. _needUVs: boolean;
  64885. /**
  64886. * Specifies if the material needs to be re-calculated
  64887. */
  64888. readonly isDirty: boolean;
  64889. /**
  64890. * Marks the material to indicate that it has been re-calculated
  64891. */
  64892. markAsProcessed(): void;
  64893. /**
  64894. * Marks the material to indicate that it needs to be re-calculated
  64895. */
  64896. markAsUnprocessed(): void;
  64897. /**
  64898. * Marks the material to indicate all of its defines need to be re-calculated
  64899. */
  64900. markAllAsDirty(): void;
  64901. /**
  64902. * Marks the material to indicate that image processing needs to be re-calculated
  64903. */
  64904. markAsImageProcessingDirty(): void;
  64905. /**
  64906. * Marks the material to indicate the lights need to be re-calculated
  64907. */
  64908. markAsLightDirty(): void;
  64909. /**
  64910. * Marks the attribute state as changed
  64911. */
  64912. markAsAttributesDirty(): void;
  64913. /**
  64914. * Marks the texture state as changed
  64915. */
  64916. markAsTexturesDirty(): void;
  64917. /**
  64918. * Marks the fresnel state as changed
  64919. */
  64920. markAsFresnelDirty(): void;
  64921. /**
  64922. * Marks the misc state as changed
  64923. */
  64924. markAsMiscDirty(): void;
  64925. /**
  64926. * Rebuilds the material defines
  64927. */
  64928. rebuild(): void;
  64929. /**
  64930. * Specifies if two material defines are equal
  64931. * @param other - A material define instance to compare to
  64932. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  64933. */
  64934. isEqual(other: MaterialDefines): boolean;
  64935. /**
  64936. * Clones this instance's defines to another instance
  64937. * @param other - material defines to clone values to
  64938. */
  64939. cloneTo(other: MaterialDefines): void;
  64940. /**
  64941. * Resets the material define values
  64942. */
  64943. reset(): void;
  64944. /**
  64945. * Converts the material define values to a string
  64946. * @returns - String of material define information
  64947. */
  64948. toString(): string;
  64949. }
  64950. }
  64951. declare module BABYLON {
  64952. /**
  64953. * Class used to store and describe the pipeline context associated with an effect
  64954. */
  64955. export interface IPipelineContext {
  64956. /**
  64957. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  64958. */
  64959. isAsync: boolean;
  64960. /**
  64961. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  64962. */
  64963. isReady: boolean;
  64964. }
  64965. }
  64966. declare module BABYLON {
  64967. /**
  64968. * Class used to store gfx data (like WebGLBuffer)
  64969. */
  64970. export class DataBuffer {
  64971. /**
  64972. * Gets or sets the number of objects referencing this buffer
  64973. */
  64974. references: number;
  64975. /** Gets or sets the size of the underlying buffer */
  64976. capacity: number;
  64977. /**
  64978. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  64979. */
  64980. is32Bits: boolean;
  64981. /**
  64982. * Gets the underlying buffer
  64983. */
  64984. readonly underlyingResource: any;
  64985. }
  64986. }
  64987. declare module BABYLON {
  64988. /**
  64989. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  64990. */
  64991. export class PerformanceMonitor {
  64992. private _enabled;
  64993. private _rollingFrameTime;
  64994. private _lastFrameTimeMs;
  64995. /**
  64996. * constructor
  64997. * @param frameSampleSize The number of samples required to saturate the sliding window
  64998. */
  64999. constructor(frameSampleSize?: number);
  65000. /**
  65001. * Samples current frame
  65002. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  65003. */
  65004. sampleFrame(timeMs?: number): void;
  65005. /**
  65006. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65007. */
  65008. readonly averageFrameTime: number;
  65009. /**
  65010. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65011. */
  65012. readonly averageFrameTimeVariance: number;
  65013. /**
  65014. * Returns the frame time of the most recent frame
  65015. */
  65016. readonly instantaneousFrameTime: number;
  65017. /**
  65018. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  65019. */
  65020. readonly averageFPS: number;
  65021. /**
  65022. * Returns the average framerate in frames per second using the most recent frame time
  65023. */
  65024. readonly instantaneousFPS: number;
  65025. /**
  65026. * Returns true if enough samples have been taken to completely fill the sliding window
  65027. */
  65028. readonly isSaturated: boolean;
  65029. /**
  65030. * Enables contributions to the sliding window sample set
  65031. */
  65032. enable(): void;
  65033. /**
  65034. * Disables contributions to the sliding window sample set
  65035. * Samples will not be interpolated over the disabled period
  65036. */
  65037. disable(): void;
  65038. /**
  65039. * Returns true if sampling is enabled
  65040. */
  65041. readonly isEnabled: boolean;
  65042. /**
  65043. * Resets performance monitor
  65044. */
  65045. reset(): void;
  65046. }
  65047. /**
  65048. * RollingAverage
  65049. *
  65050. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  65051. */
  65052. export class RollingAverage {
  65053. /**
  65054. * Current average
  65055. */
  65056. average: number;
  65057. /**
  65058. * Current variance
  65059. */
  65060. variance: number;
  65061. protected _samples: Array<number>;
  65062. protected _sampleCount: number;
  65063. protected _pos: number;
  65064. protected _m2: number;
  65065. /**
  65066. * constructor
  65067. * @param length The number of samples required to saturate the sliding window
  65068. */
  65069. constructor(length: number);
  65070. /**
  65071. * Adds a sample to the sample set
  65072. * @param v The sample value
  65073. */
  65074. add(v: number): void;
  65075. /**
  65076. * Returns previously added values or null if outside of history or outside the sliding window domain
  65077. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  65078. * @return Value previously recorded with add() or null if outside of range
  65079. */
  65080. history(i: number): number;
  65081. /**
  65082. * Returns true if enough samples have been taken to completely fill the sliding window
  65083. * @return true if sample-set saturated
  65084. */
  65085. isSaturated(): boolean;
  65086. /**
  65087. * Resets the rolling average (equivalent to 0 samples taken so far)
  65088. */
  65089. reset(): void;
  65090. /**
  65091. * Wraps a value around the sample range boundaries
  65092. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  65093. * @return Wrapped position in sample range
  65094. */
  65095. protected _wrapPosition(i: number): number;
  65096. }
  65097. }
  65098. declare module BABYLON {
  65099. /**
  65100. * This class implement a typical dictionary using a string as key and the generic type T as value.
  65101. * The underlying implementation relies on an associative array to ensure the best performances.
  65102. * The value can be anything including 'null' but except 'undefined'
  65103. */
  65104. export class StringDictionary<T> {
  65105. /**
  65106. * This will clear this dictionary and copy the content from the 'source' one.
  65107. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  65108. * @param source the dictionary to take the content from and copy to this dictionary
  65109. */
  65110. copyFrom(source: StringDictionary<T>): void;
  65111. /**
  65112. * Get a value based from its key
  65113. * @param key the given key to get the matching value from
  65114. * @return the value if found, otherwise undefined is returned
  65115. */
  65116. get(key: string): T | undefined;
  65117. /**
  65118. * Get a value from its key or add it if it doesn't exist.
  65119. * This method will ensure you that a given key/data will be present in the dictionary.
  65120. * @param key the given key to get the matching value from
  65121. * @param factory the factory that will create the value if the key is not present in the dictionary.
  65122. * The factory will only be invoked if there's no data for the given key.
  65123. * @return the value corresponding to the key.
  65124. */
  65125. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  65126. /**
  65127. * Get a value from its key if present in the dictionary otherwise add it
  65128. * @param key the key to get the value from
  65129. * @param val if there's no such key/value pair in the dictionary add it with this value
  65130. * @return the value corresponding to the key
  65131. */
  65132. getOrAdd(key: string, val: T): T;
  65133. /**
  65134. * Check if there's a given key in the dictionary
  65135. * @param key the key to check for
  65136. * @return true if the key is present, false otherwise
  65137. */
  65138. contains(key: string): boolean;
  65139. /**
  65140. * Add a new key and its corresponding value
  65141. * @param key the key to add
  65142. * @param value the value corresponding to the key
  65143. * @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
  65144. */
  65145. add(key: string, value: T): boolean;
  65146. /**
  65147. * Update a specific value associated to a key
  65148. * @param key defines the key to use
  65149. * @param value defines the value to store
  65150. * @returns true if the value was updated (or false if the key was not found)
  65151. */
  65152. set(key: string, value: T): boolean;
  65153. /**
  65154. * Get the element of the given key and remove it from the dictionary
  65155. * @param key defines the key to search
  65156. * @returns the value associated with the key or null if not found
  65157. */
  65158. getAndRemove(key: string): Nullable<T>;
  65159. /**
  65160. * Remove a key/value from the dictionary.
  65161. * @param key the key to remove
  65162. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  65163. */
  65164. remove(key: string): boolean;
  65165. /**
  65166. * Clear the whole content of the dictionary
  65167. */
  65168. clear(): void;
  65169. /**
  65170. * Gets the current count
  65171. */
  65172. readonly count: number;
  65173. /**
  65174. * Execute a callback on each key/val of the dictionary.
  65175. * Note that you can remove any element in this dictionary in the callback implementation
  65176. * @param callback the callback to execute on a given key/value pair
  65177. */
  65178. forEach(callback: (key: string, val: T) => void): void;
  65179. /**
  65180. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  65181. * If the callback returns null or undefined the method will iterate to the next key/value pair
  65182. * Note that you can remove any element in this dictionary in the callback implementation
  65183. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  65184. * @returns the first item
  65185. */
  65186. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  65187. private _count;
  65188. private _data;
  65189. }
  65190. }
  65191. declare module BABYLON {
  65192. /**
  65193. * Helper class that provides a small promise polyfill
  65194. */
  65195. export class PromisePolyfill {
  65196. /**
  65197. * Static function used to check if the polyfill is required
  65198. * If this is the case then the function will inject the polyfill to window.Promise
  65199. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  65200. */
  65201. static Apply(force?: boolean): void;
  65202. }
  65203. }
  65204. declare module BABYLON {
  65205. /**
  65206. * Class used to store data that will be store in GPU memory
  65207. */
  65208. export class Buffer {
  65209. private _engine;
  65210. private _buffer;
  65211. /** @hidden */
  65212. _data: Nullable<DataArray>;
  65213. private _updatable;
  65214. private _instanced;
  65215. /**
  65216. * Gets the byte stride.
  65217. */
  65218. readonly byteStride: number;
  65219. /**
  65220. * Constructor
  65221. * @param engine the engine
  65222. * @param data the data to use for this buffer
  65223. * @param updatable whether the data is updatable
  65224. * @param stride the stride (optional)
  65225. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65226. * @param instanced whether the buffer is instanced (optional)
  65227. * @param useBytes set to true if the stride in in bytes (optional)
  65228. */
  65229. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  65230. /**
  65231. * Create a new VertexBuffer based on the current buffer
  65232. * @param kind defines the vertex buffer kind (position, normal, etc.)
  65233. * @param offset defines offset in the buffer (0 by default)
  65234. * @param size defines the size in floats of attributes (position is 3 for instance)
  65235. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  65236. * @param instanced defines if the vertex buffer contains indexed data
  65237. * @param useBytes defines if the offset and stride are in bytes
  65238. * @returns the new vertex buffer
  65239. */
  65240. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  65241. /**
  65242. * Gets a boolean indicating if the Buffer is updatable?
  65243. * @returns true if the buffer is updatable
  65244. */
  65245. isUpdatable(): boolean;
  65246. /**
  65247. * Gets current buffer's data
  65248. * @returns a DataArray or null
  65249. */
  65250. getData(): Nullable<DataArray>;
  65251. /**
  65252. * Gets underlying native buffer
  65253. * @returns underlying native buffer
  65254. */
  65255. getBuffer(): Nullable<DataBuffer>;
  65256. /**
  65257. * Gets the stride in float32 units (i.e. byte stride / 4).
  65258. * May not be an integer if the byte stride is not divisible by 4.
  65259. * DEPRECATED. Use byteStride instead.
  65260. * @returns the stride in float32 units
  65261. */
  65262. getStrideSize(): number;
  65263. /**
  65264. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65265. * @param data defines the data to store
  65266. */
  65267. create(data?: Nullable<DataArray>): void;
  65268. /** @hidden */
  65269. _rebuild(): void;
  65270. /**
  65271. * Update current buffer data
  65272. * @param data defines the data to store
  65273. */
  65274. update(data: DataArray): void;
  65275. /**
  65276. * Updates the data directly.
  65277. * @param data the new data
  65278. * @param offset the new offset
  65279. * @param vertexCount the vertex count (optional)
  65280. * @param useBytes set to true if the offset is in bytes
  65281. */
  65282. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  65283. /**
  65284. * Release all resources
  65285. */
  65286. dispose(): void;
  65287. }
  65288. /**
  65289. * Specialized buffer used to store vertex data
  65290. */
  65291. export class VertexBuffer {
  65292. /** @hidden */
  65293. _buffer: Buffer;
  65294. private _kind;
  65295. private _size;
  65296. private _ownsBuffer;
  65297. private _instanced;
  65298. private _instanceDivisor;
  65299. /**
  65300. * The byte type.
  65301. */
  65302. static readonly BYTE: number;
  65303. /**
  65304. * The unsigned byte type.
  65305. */
  65306. static readonly UNSIGNED_BYTE: number;
  65307. /**
  65308. * The short type.
  65309. */
  65310. static readonly SHORT: number;
  65311. /**
  65312. * The unsigned short type.
  65313. */
  65314. static readonly UNSIGNED_SHORT: number;
  65315. /**
  65316. * The integer type.
  65317. */
  65318. static readonly INT: number;
  65319. /**
  65320. * The unsigned integer type.
  65321. */
  65322. static readonly UNSIGNED_INT: number;
  65323. /**
  65324. * The float type.
  65325. */
  65326. static readonly FLOAT: number;
  65327. /**
  65328. * Gets or sets the instance divisor when in instanced mode
  65329. */
  65330. instanceDivisor: number;
  65331. /**
  65332. * Gets the byte stride.
  65333. */
  65334. readonly byteStride: number;
  65335. /**
  65336. * Gets the byte offset.
  65337. */
  65338. readonly byteOffset: number;
  65339. /**
  65340. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  65341. */
  65342. readonly normalized: boolean;
  65343. /**
  65344. * Gets the data type of each component in the array.
  65345. */
  65346. readonly type: number;
  65347. /**
  65348. * Constructor
  65349. * @param engine the engine
  65350. * @param data the data to use for this vertex buffer
  65351. * @param kind the vertex buffer kind
  65352. * @param updatable whether the data is updatable
  65353. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65354. * @param stride the stride (optional)
  65355. * @param instanced whether the buffer is instanced (optional)
  65356. * @param offset the offset of the data (optional)
  65357. * @param size the number of components (optional)
  65358. * @param type the type of the component (optional)
  65359. * @param normalized whether the data contains normalized data (optional)
  65360. * @param useBytes set to true if stride and offset are in bytes (optional)
  65361. */
  65362. 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);
  65363. /** @hidden */
  65364. _rebuild(): void;
  65365. /**
  65366. * Returns the kind of the VertexBuffer (string)
  65367. * @returns a string
  65368. */
  65369. getKind(): string;
  65370. /**
  65371. * Gets a boolean indicating if the VertexBuffer is updatable?
  65372. * @returns true if the buffer is updatable
  65373. */
  65374. isUpdatable(): boolean;
  65375. /**
  65376. * Gets current buffer's data
  65377. * @returns a DataArray or null
  65378. */
  65379. getData(): Nullable<DataArray>;
  65380. /**
  65381. * Gets underlying native buffer
  65382. * @returns underlying native buffer
  65383. */
  65384. getBuffer(): Nullable<DataBuffer>;
  65385. /**
  65386. * Gets the stride in float32 units (i.e. byte stride / 4).
  65387. * May not be an integer if the byte stride is not divisible by 4.
  65388. * DEPRECATED. Use byteStride instead.
  65389. * @returns the stride in float32 units
  65390. */
  65391. getStrideSize(): number;
  65392. /**
  65393. * Returns the offset as a multiple of the type byte length.
  65394. * DEPRECATED. Use byteOffset instead.
  65395. * @returns the offset in bytes
  65396. */
  65397. getOffset(): number;
  65398. /**
  65399. * Returns the number of components per vertex attribute (integer)
  65400. * @returns the size in float
  65401. */
  65402. getSize(): number;
  65403. /**
  65404. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65405. * @returns true if this buffer is instanced
  65406. */
  65407. getIsInstanced(): boolean;
  65408. /**
  65409. * Returns the instancing divisor, zero for non-instanced (integer).
  65410. * @returns a number
  65411. */
  65412. getInstanceDivisor(): number;
  65413. /**
  65414. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65415. * @param data defines the data to store
  65416. */
  65417. create(data?: DataArray): void;
  65418. /**
  65419. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65420. * This function will create a new buffer if the current one is not updatable
  65421. * @param data defines the data to store
  65422. */
  65423. update(data: DataArray): void;
  65424. /**
  65425. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65426. * Returns the directly updated WebGLBuffer.
  65427. * @param data the new data
  65428. * @param offset the new offset
  65429. * @param useBytes set to true if the offset is in bytes
  65430. */
  65431. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65432. /**
  65433. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65434. */
  65435. dispose(): void;
  65436. /**
  65437. * Enumerates each value of this vertex buffer as numbers.
  65438. * @param count the number of values to enumerate
  65439. * @param callback the callback function called for each value
  65440. */
  65441. forEach(count: number, callback: (value: number, index: number) => void): void;
  65442. /**
  65443. * Positions
  65444. */
  65445. static readonly PositionKind: string;
  65446. /**
  65447. * Normals
  65448. */
  65449. static readonly NormalKind: string;
  65450. /**
  65451. * Tangents
  65452. */
  65453. static readonly TangentKind: string;
  65454. /**
  65455. * Texture coordinates
  65456. */
  65457. static readonly UVKind: string;
  65458. /**
  65459. * Texture coordinates 2
  65460. */
  65461. static readonly UV2Kind: string;
  65462. /**
  65463. * Texture coordinates 3
  65464. */
  65465. static readonly UV3Kind: string;
  65466. /**
  65467. * Texture coordinates 4
  65468. */
  65469. static readonly UV4Kind: string;
  65470. /**
  65471. * Texture coordinates 5
  65472. */
  65473. static readonly UV5Kind: string;
  65474. /**
  65475. * Texture coordinates 6
  65476. */
  65477. static readonly UV6Kind: string;
  65478. /**
  65479. * Colors
  65480. */
  65481. static readonly ColorKind: string;
  65482. /**
  65483. * Matrix indices (for bones)
  65484. */
  65485. static readonly MatricesIndicesKind: string;
  65486. /**
  65487. * Matrix weights (for bones)
  65488. */
  65489. static readonly MatricesWeightsKind: string;
  65490. /**
  65491. * Additional matrix indices (for bones)
  65492. */
  65493. static readonly MatricesIndicesExtraKind: string;
  65494. /**
  65495. * Additional matrix weights (for bones)
  65496. */
  65497. static readonly MatricesWeightsExtraKind: string;
  65498. /**
  65499. * Deduces the stride given a kind.
  65500. * @param kind The kind string to deduce
  65501. * @returns The deduced stride
  65502. */
  65503. static DeduceStride(kind: string): number;
  65504. /**
  65505. * Gets the byte length of the given type.
  65506. * @param type the type
  65507. * @returns the number of bytes
  65508. */
  65509. static GetTypeByteLength(type: number): number;
  65510. /**
  65511. * Enumerates each value of the given parameters as numbers.
  65512. * @param data the data to enumerate
  65513. * @param byteOffset the byte offset of the data
  65514. * @param byteStride the byte stride of the data
  65515. * @param componentCount the number of components per element
  65516. * @param componentType the type of the component
  65517. * @param count the total number of components
  65518. * @param normalized whether the data is normalized
  65519. * @param callback the callback function called for each value
  65520. */
  65521. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65522. private static _GetFloatValue;
  65523. }
  65524. }
  65525. declare module BABYLON {
  65526. /**
  65527. * Class representing spherical polynomial coefficients to the 3rd degree
  65528. */
  65529. export class SphericalPolynomial {
  65530. /**
  65531. * The x coefficients of the spherical polynomial
  65532. */
  65533. x: Vector3;
  65534. /**
  65535. * The y coefficients of the spherical polynomial
  65536. */
  65537. y: Vector3;
  65538. /**
  65539. * The z coefficients of the spherical polynomial
  65540. */
  65541. z: Vector3;
  65542. /**
  65543. * The xx coefficients of the spherical polynomial
  65544. */
  65545. xx: Vector3;
  65546. /**
  65547. * The yy coefficients of the spherical polynomial
  65548. */
  65549. yy: Vector3;
  65550. /**
  65551. * The zz coefficients of the spherical polynomial
  65552. */
  65553. zz: Vector3;
  65554. /**
  65555. * The xy coefficients of the spherical polynomial
  65556. */
  65557. xy: Vector3;
  65558. /**
  65559. * The yz coefficients of the spherical polynomial
  65560. */
  65561. yz: Vector3;
  65562. /**
  65563. * The zx coefficients of the spherical polynomial
  65564. */
  65565. zx: Vector3;
  65566. /**
  65567. * Adds an ambient color to the spherical polynomial
  65568. * @param color the color to add
  65569. */
  65570. addAmbient(color: Color3): void;
  65571. /**
  65572. * Scales the spherical polynomial by the given amount
  65573. * @param scale the amount to scale
  65574. */
  65575. scale(scale: number): void;
  65576. /**
  65577. * Gets the spherical polynomial from harmonics
  65578. * @param harmonics the spherical harmonics
  65579. * @returns the spherical polynomial
  65580. */
  65581. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  65582. /**
  65583. * Constructs a spherical polynomial from an array.
  65584. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  65585. * @returns the spherical polynomial
  65586. */
  65587. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  65588. }
  65589. /**
  65590. * Class representing spherical harmonics coefficients to the 3rd degree
  65591. */
  65592. export class SphericalHarmonics {
  65593. /**
  65594. * The l0,0 coefficients of the spherical harmonics
  65595. */
  65596. l00: Vector3;
  65597. /**
  65598. * The l1,-1 coefficients of the spherical harmonics
  65599. */
  65600. l1_1: Vector3;
  65601. /**
  65602. * The l1,0 coefficients of the spherical harmonics
  65603. */
  65604. l10: Vector3;
  65605. /**
  65606. * The l1,1 coefficients of the spherical harmonics
  65607. */
  65608. l11: Vector3;
  65609. /**
  65610. * The l2,-2 coefficients of the spherical harmonics
  65611. */
  65612. l2_2: Vector3;
  65613. /**
  65614. * The l2,-1 coefficients of the spherical harmonics
  65615. */
  65616. l2_1: Vector3;
  65617. /**
  65618. * The l2,0 coefficients of the spherical harmonics
  65619. */
  65620. l20: Vector3;
  65621. /**
  65622. * The l2,1 coefficients of the spherical harmonics
  65623. */
  65624. l21: Vector3;
  65625. /**
  65626. * The l2,2 coefficients of the spherical harmonics
  65627. */
  65628. lL22: Vector3;
  65629. /**
  65630. * Adds a light to the spherical harmonics
  65631. * @param direction the direction of the light
  65632. * @param color the color of the light
  65633. * @param deltaSolidAngle the delta solid angle of the light
  65634. */
  65635. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  65636. /**
  65637. * Scales the spherical harmonics by the given amount
  65638. * @param scale the amount to scale
  65639. */
  65640. scale(scale: number): void;
  65641. /**
  65642. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  65643. *
  65644. * ```
  65645. * E_lm = A_l * L_lm
  65646. * ```
  65647. *
  65648. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  65649. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  65650. * the scaling factors are given in equation 9.
  65651. */
  65652. convertIncidentRadianceToIrradiance(): void;
  65653. /**
  65654. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  65655. *
  65656. * ```
  65657. * L = (1/pi) * E * rho
  65658. * ```
  65659. *
  65660. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  65661. */
  65662. convertIrradianceToLambertianRadiance(): void;
  65663. /**
  65664. * Gets the spherical harmonics from polynomial
  65665. * @param polynomial the spherical polynomial
  65666. * @returns the spherical harmonics
  65667. */
  65668. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  65669. /**
  65670. * Constructs a spherical harmonics from an array.
  65671. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  65672. * @returns the spherical harmonics
  65673. */
  65674. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  65675. }
  65676. }
  65677. declare module BABYLON {
  65678. /**
  65679. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  65680. */
  65681. export interface CubeMapInfo {
  65682. /**
  65683. * The pixel array for the front face.
  65684. * This is stored in format, left to right, up to down format.
  65685. */
  65686. front: Nullable<ArrayBufferView>;
  65687. /**
  65688. * The pixel array for the back face.
  65689. * This is stored in format, left to right, up to down format.
  65690. */
  65691. back: Nullable<ArrayBufferView>;
  65692. /**
  65693. * The pixel array for the left face.
  65694. * This is stored in format, left to right, up to down format.
  65695. */
  65696. left: Nullable<ArrayBufferView>;
  65697. /**
  65698. * The pixel array for the right face.
  65699. * This is stored in format, left to right, up to down format.
  65700. */
  65701. right: Nullable<ArrayBufferView>;
  65702. /**
  65703. * The pixel array for the up face.
  65704. * This is stored in format, left to right, up to down format.
  65705. */
  65706. up: Nullable<ArrayBufferView>;
  65707. /**
  65708. * The pixel array for the down face.
  65709. * This is stored in format, left to right, up to down format.
  65710. */
  65711. down: Nullable<ArrayBufferView>;
  65712. /**
  65713. * The size of the cubemap stored.
  65714. *
  65715. * Each faces will be size * size pixels.
  65716. */
  65717. size: number;
  65718. /**
  65719. * The format of the texture.
  65720. *
  65721. * RGBA, RGB.
  65722. */
  65723. format: number;
  65724. /**
  65725. * The type of the texture data.
  65726. *
  65727. * UNSIGNED_INT, FLOAT.
  65728. */
  65729. type: number;
  65730. /**
  65731. * Specifies whether the texture is in gamma space.
  65732. */
  65733. gammaSpace: boolean;
  65734. }
  65735. /**
  65736. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  65737. */
  65738. export class PanoramaToCubeMapTools {
  65739. private static FACE_FRONT;
  65740. private static FACE_BACK;
  65741. private static FACE_RIGHT;
  65742. private static FACE_LEFT;
  65743. private static FACE_DOWN;
  65744. private static FACE_UP;
  65745. /**
  65746. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  65747. *
  65748. * @param float32Array The source data.
  65749. * @param inputWidth The width of the input panorama.
  65750. * @param inputHeight The height of the input panorama.
  65751. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  65752. * @return The cubemap data
  65753. */
  65754. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  65755. private static CreateCubemapTexture;
  65756. private static CalcProjectionSpherical;
  65757. }
  65758. }
  65759. declare module BABYLON {
  65760. /**
  65761. * Helper class dealing with the extraction of spherical polynomial dataArray
  65762. * from a cube map.
  65763. */
  65764. export class CubeMapToSphericalPolynomialTools {
  65765. private static FileFaces;
  65766. /**
  65767. * Converts a texture to the according Spherical Polynomial data.
  65768. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65769. *
  65770. * @param texture The texture to extract the information from.
  65771. * @return The Spherical Polynomial data.
  65772. */
  65773. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  65774. /**
  65775. * Converts a cubemap to the according Spherical Polynomial data.
  65776. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65777. *
  65778. * @param cubeInfo The Cube map to extract the information from.
  65779. * @return The Spherical Polynomial data.
  65780. */
  65781. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  65782. }
  65783. }
  65784. declare module BABYLON {
  65785. /**
  65786. * The engine store class is responsible to hold all the instances of Engine and Scene created
  65787. * during the life time of the application.
  65788. */
  65789. export class EngineStore {
  65790. /** Gets the list of created engines */
  65791. static Instances: Engine[];
  65792. /**
  65793. * Gets the latest created engine
  65794. */
  65795. static readonly LastCreatedEngine: Nullable<Engine>;
  65796. /**
  65797. * Gets the latest created scene
  65798. */
  65799. static readonly LastCreatedScene: Nullable<Scene>;
  65800. }
  65801. }
  65802. declare module BABYLON {
  65803. /**
  65804. * Define options used to create a render target texture
  65805. */
  65806. export class RenderTargetCreationOptions {
  65807. /**
  65808. * Specifies is mipmaps must be generated
  65809. */
  65810. generateMipMaps?: boolean;
  65811. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  65812. generateDepthBuffer?: boolean;
  65813. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  65814. generateStencilBuffer?: boolean;
  65815. /** Defines texture type (int by default) */
  65816. type?: number;
  65817. /** Defines sampling mode (trilinear by default) */
  65818. samplingMode?: number;
  65819. /** Defines format (RGBA by default) */
  65820. format?: number;
  65821. }
  65822. }
  65823. declare module BABYLON {
  65824. /**
  65825. * @hidden
  65826. **/
  65827. export class _AlphaState {
  65828. private _isAlphaBlendDirty;
  65829. private _isBlendFunctionParametersDirty;
  65830. private _isBlendEquationParametersDirty;
  65831. private _isBlendConstantsDirty;
  65832. private _alphaBlend;
  65833. private _blendFunctionParameters;
  65834. private _blendEquationParameters;
  65835. private _blendConstants;
  65836. /**
  65837. * Initializes the state.
  65838. */
  65839. constructor();
  65840. readonly isDirty: boolean;
  65841. alphaBlend: boolean;
  65842. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  65843. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  65844. setAlphaEquationParameters(rgb: number, alpha: number): void;
  65845. reset(): void;
  65846. apply(gl: WebGLRenderingContext): void;
  65847. }
  65848. }
  65849. declare module BABYLON {
  65850. /**
  65851. * @hidden
  65852. **/
  65853. export class _DepthCullingState {
  65854. private _isDepthTestDirty;
  65855. private _isDepthMaskDirty;
  65856. private _isDepthFuncDirty;
  65857. private _isCullFaceDirty;
  65858. private _isCullDirty;
  65859. private _isZOffsetDirty;
  65860. private _isFrontFaceDirty;
  65861. private _depthTest;
  65862. private _depthMask;
  65863. private _depthFunc;
  65864. private _cull;
  65865. private _cullFace;
  65866. private _zOffset;
  65867. private _frontFace;
  65868. /**
  65869. * Initializes the state.
  65870. */
  65871. constructor();
  65872. readonly isDirty: boolean;
  65873. zOffset: number;
  65874. cullFace: Nullable<number>;
  65875. cull: Nullable<boolean>;
  65876. depthFunc: Nullable<number>;
  65877. depthMask: boolean;
  65878. depthTest: boolean;
  65879. frontFace: Nullable<number>;
  65880. reset(): void;
  65881. apply(gl: WebGLRenderingContext): void;
  65882. }
  65883. }
  65884. declare module BABYLON {
  65885. /**
  65886. * @hidden
  65887. **/
  65888. export class _StencilState {
  65889. /** 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 */
  65890. static readonly ALWAYS: number;
  65891. /** Passed to stencilOperation to specify that stencil value must be kept */
  65892. static readonly KEEP: number;
  65893. /** Passed to stencilOperation to specify that stencil value must be replaced */
  65894. static readonly REPLACE: number;
  65895. private _isStencilTestDirty;
  65896. private _isStencilMaskDirty;
  65897. private _isStencilFuncDirty;
  65898. private _isStencilOpDirty;
  65899. private _stencilTest;
  65900. private _stencilMask;
  65901. private _stencilFunc;
  65902. private _stencilFuncRef;
  65903. private _stencilFuncMask;
  65904. private _stencilOpStencilFail;
  65905. private _stencilOpDepthFail;
  65906. private _stencilOpStencilDepthPass;
  65907. readonly isDirty: boolean;
  65908. stencilFunc: number;
  65909. stencilFuncRef: number;
  65910. stencilFuncMask: number;
  65911. stencilOpStencilFail: number;
  65912. stencilOpDepthFail: number;
  65913. stencilOpStencilDepthPass: number;
  65914. stencilMask: number;
  65915. stencilTest: boolean;
  65916. constructor();
  65917. reset(): void;
  65918. apply(gl: WebGLRenderingContext): void;
  65919. }
  65920. }
  65921. declare module BABYLON {
  65922. /**
  65923. * @hidden
  65924. **/
  65925. export class _TimeToken {
  65926. _startTimeQuery: Nullable<WebGLQuery>;
  65927. _endTimeQuery: Nullable<WebGLQuery>;
  65928. _timeElapsedQuery: Nullable<WebGLQuery>;
  65929. _timeElapsedQueryEnded: boolean;
  65930. }
  65931. }
  65932. declare module BABYLON {
  65933. /**
  65934. * Class used to store data associated with WebGL texture data for the engine
  65935. * This class should not be used directly
  65936. */
  65937. export class InternalTexture {
  65938. /** hidden */
  65939. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  65940. /**
  65941. * The source of the texture data is unknown
  65942. */
  65943. static DATASOURCE_UNKNOWN: number;
  65944. /**
  65945. * Texture data comes from an URL
  65946. */
  65947. static DATASOURCE_URL: number;
  65948. /**
  65949. * Texture data is only used for temporary storage
  65950. */
  65951. static DATASOURCE_TEMP: number;
  65952. /**
  65953. * Texture data comes from raw data (ArrayBuffer)
  65954. */
  65955. static DATASOURCE_RAW: number;
  65956. /**
  65957. * Texture content is dynamic (video or dynamic texture)
  65958. */
  65959. static DATASOURCE_DYNAMIC: number;
  65960. /**
  65961. * Texture content is generated by rendering to it
  65962. */
  65963. static DATASOURCE_RENDERTARGET: number;
  65964. /**
  65965. * Texture content is part of a multi render target process
  65966. */
  65967. static DATASOURCE_MULTIRENDERTARGET: number;
  65968. /**
  65969. * Texture data comes from a cube data file
  65970. */
  65971. static DATASOURCE_CUBE: number;
  65972. /**
  65973. * Texture data comes from a raw cube data
  65974. */
  65975. static DATASOURCE_CUBERAW: number;
  65976. /**
  65977. * Texture data come from a prefiltered cube data file
  65978. */
  65979. static DATASOURCE_CUBEPREFILTERED: number;
  65980. /**
  65981. * Texture content is raw 3D data
  65982. */
  65983. static DATASOURCE_RAW3D: number;
  65984. /**
  65985. * Texture content is a depth texture
  65986. */
  65987. static DATASOURCE_DEPTHTEXTURE: number;
  65988. /**
  65989. * Texture data comes from a raw cube data encoded with RGBD
  65990. */
  65991. static DATASOURCE_CUBERAW_RGBD: number;
  65992. /**
  65993. * Defines if the texture is ready
  65994. */
  65995. isReady: boolean;
  65996. /**
  65997. * Defines if the texture is a cube texture
  65998. */
  65999. isCube: boolean;
  66000. /**
  66001. * Defines if the texture contains 3D data
  66002. */
  66003. is3D: boolean;
  66004. /**
  66005. * Defines if the texture contains multiview data
  66006. */
  66007. isMultiview: boolean;
  66008. /**
  66009. * Gets the URL used to load this texture
  66010. */
  66011. url: string;
  66012. /**
  66013. * Gets the sampling mode of the texture
  66014. */
  66015. samplingMode: number;
  66016. /**
  66017. * Gets a boolean indicating if the texture needs mipmaps generation
  66018. */
  66019. generateMipMaps: boolean;
  66020. /**
  66021. * Gets the number of samples used by the texture (WebGL2+ only)
  66022. */
  66023. samples: number;
  66024. /**
  66025. * Gets the type of the texture (int, float...)
  66026. */
  66027. type: number;
  66028. /**
  66029. * Gets the format of the texture (RGB, RGBA...)
  66030. */
  66031. format: number;
  66032. /**
  66033. * Observable called when the texture is loaded
  66034. */
  66035. onLoadedObservable: Observable<InternalTexture>;
  66036. /**
  66037. * Gets the width of the texture
  66038. */
  66039. width: number;
  66040. /**
  66041. * Gets the height of the texture
  66042. */
  66043. height: number;
  66044. /**
  66045. * Gets the depth of the texture
  66046. */
  66047. depth: number;
  66048. /**
  66049. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  66050. */
  66051. baseWidth: number;
  66052. /**
  66053. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  66054. */
  66055. baseHeight: number;
  66056. /**
  66057. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  66058. */
  66059. baseDepth: number;
  66060. /**
  66061. * Gets a boolean indicating if the texture is inverted on Y axis
  66062. */
  66063. invertY: boolean;
  66064. /** @hidden */
  66065. _invertVScale: boolean;
  66066. /** @hidden */
  66067. _associatedChannel: number;
  66068. /** @hidden */
  66069. _dataSource: number;
  66070. /** @hidden */
  66071. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  66072. /** @hidden */
  66073. _bufferView: Nullable<ArrayBufferView>;
  66074. /** @hidden */
  66075. _bufferViewArray: Nullable<ArrayBufferView[]>;
  66076. /** @hidden */
  66077. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  66078. /** @hidden */
  66079. _size: number;
  66080. /** @hidden */
  66081. _extension: string;
  66082. /** @hidden */
  66083. _files: Nullable<string[]>;
  66084. /** @hidden */
  66085. _workingCanvas: Nullable<HTMLCanvasElement>;
  66086. /** @hidden */
  66087. _workingContext: Nullable<CanvasRenderingContext2D>;
  66088. /** @hidden */
  66089. _framebuffer: Nullable<WebGLFramebuffer>;
  66090. /** @hidden */
  66091. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  66092. /** @hidden */
  66093. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  66094. /** @hidden */
  66095. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  66096. /** @hidden */
  66097. _attachments: Nullable<number[]>;
  66098. /** @hidden */
  66099. _cachedCoordinatesMode: Nullable<number>;
  66100. /** @hidden */
  66101. _cachedWrapU: Nullable<number>;
  66102. /** @hidden */
  66103. _cachedWrapV: Nullable<number>;
  66104. /** @hidden */
  66105. _cachedWrapR: Nullable<number>;
  66106. /** @hidden */
  66107. _cachedAnisotropicFilteringLevel: Nullable<number>;
  66108. /** @hidden */
  66109. _isDisabled: boolean;
  66110. /** @hidden */
  66111. _compression: Nullable<string>;
  66112. /** @hidden */
  66113. _generateStencilBuffer: boolean;
  66114. /** @hidden */
  66115. _generateDepthBuffer: boolean;
  66116. /** @hidden */
  66117. _comparisonFunction: number;
  66118. /** @hidden */
  66119. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  66120. /** @hidden */
  66121. _lodGenerationScale: number;
  66122. /** @hidden */
  66123. _lodGenerationOffset: number;
  66124. /** @hidden */
  66125. _colorTextureArray: Nullable<WebGLTexture>;
  66126. /** @hidden */
  66127. _depthStencilTextureArray: Nullable<WebGLTexture>;
  66128. /** @hidden */
  66129. _lodTextureHigh: Nullable<BaseTexture>;
  66130. /** @hidden */
  66131. _lodTextureMid: Nullable<BaseTexture>;
  66132. /** @hidden */
  66133. _lodTextureLow: Nullable<BaseTexture>;
  66134. /** @hidden */
  66135. _isRGBD: boolean;
  66136. /** @hidden */
  66137. _webGLTexture: Nullable<WebGLTexture>;
  66138. /** @hidden */
  66139. _references: number;
  66140. private _engine;
  66141. /**
  66142. * Gets the Engine the texture belongs to.
  66143. * @returns The babylon engine
  66144. */
  66145. getEngine(): Engine;
  66146. /**
  66147. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  66148. */
  66149. readonly dataSource: number;
  66150. /**
  66151. * Creates a new InternalTexture
  66152. * @param engine defines the engine to use
  66153. * @param dataSource defines the type of data that will be used
  66154. * @param delayAllocation if the texture allocation should be delayed (default: false)
  66155. */
  66156. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  66157. /**
  66158. * Increments the number of references (ie. the number of Texture that point to it)
  66159. */
  66160. incrementReferences(): void;
  66161. /**
  66162. * Change the size of the texture (not the size of the content)
  66163. * @param width defines the new width
  66164. * @param height defines the new height
  66165. * @param depth defines the new depth (1 by default)
  66166. */
  66167. updateSize(width: int, height: int, depth?: int): void;
  66168. /** @hidden */
  66169. _rebuild(): void;
  66170. /** @hidden */
  66171. _swapAndDie(target: InternalTexture): void;
  66172. /**
  66173. * Dispose the current allocated resources
  66174. */
  66175. dispose(): void;
  66176. }
  66177. }
  66178. declare module BABYLON {
  66179. /**
  66180. * This represents the main contract an easing function should follow.
  66181. * Easing functions are used throughout the animation system.
  66182. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66183. */
  66184. export interface IEasingFunction {
  66185. /**
  66186. * Given an input gradient between 0 and 1, this returns the corrseponding value
  66187. * of the easing function.
  66188. * The link below provides some of the most common examples of easing functions.
  66189. * @see https://easings.net/
  66190. * @param gradient Defines the value between 0 and 1 we want the easing value for
  66191. * @returns the corresponding value on the curve defined by the easing function
  66192. */
  66193. ease(gradient: number): number;
  66194. }
  66195. /**
  66196. * Base class used for every default easing function.
  66197. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66198. */
  66199. export class EasingFunction implements IEasingFunction {
  66200. /**
  66201. * Interpolation follows the mathematical formula associated with the easing function.
  66202. */
  66203. static readonly EASINGMODE_EASEIN: number;
  66204. /**
  66205. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  66206. */
  66207. static readonly EASINGMODE_EASEOUT: number;
  66208. /**
  66209. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  66210. */
  66211. static readonly EASINGMODE_EASEINOUT: number;
  66212. private _easingMode;
  66213. /**
  66214. * Sets the easing mode of the current function.
  66215. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  66216. */
  66217. setEasingMode(easingMode: number): void;
  66218. /**
  66219. * Gets the current easing mode.
  66220. * @returns the easing mode
  66221. */
  66222. getEasingMode(): number;
  66223. /**
  66224. * @hidden
  66225. */
  66226. easeInCore(gradient: number): number;
  66227. /**
  66228. * Given an input gradient between 0 and 1, this returns the corrseponding value
  66229. * of the easing function.
  66230. * @param gradient Defines the value between 0 and 1 we want the easing value for
  66231. * @returns the corresponding value on the curve defined by the easing function
  66232. */
  66233. ease(gradient: number): number;
  66234. }
  66235. /**
  66236. * Easing function with a circle shape (see link below).
  66237. * @see https://easings.net/#easeInCirc
  66238. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66239. */
  66240. export class CircleEase extends EasingFunction implements IEasingFunction {
  66241. /** @hidden */
  66242. easeInCore(gradient: number): number;
  66243. }
  66244. /**
  66245. * Easing function with a ease back shape (see link below).
  66246. * @see https://easings.net/#easeInBack
  66247. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66248. */
  66249. export class BackEase extends EasingFunction implements IEasingFunction {
  66250. /** Defines the amplitude of the function */
  66251. amplitude: number;
  66252. /**
  66253. * Instantiates a back ease easing
  66254. * @see https://easings.net/#easeInBack
  66255. * @param amplitude Defines the amplitude of the function
  66256. */
  66257. constructor(
  66258. /** Defines the amplitude of the function */
  66259. amplitude?: number);
  66260. /** @hidden */
  66261. easeInCore(gradient: number): number;
  66262. }
  66263. /**
  66264. * Easing function with a bouncing shape (see link below).
  66265. * @see https://easings.net/#easeInBounce
  66266. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66267. */
  66268. export class BounceEase extends EasingFunction implements IEasingFunction {
  66269. /** Defines the number of bounces */
  66270. bounces: number;
  66271. /** Defines the amplitude of the bounce */
  66272. bounciness: number;
  66273. /**
  66274. * Instantiates a bounce easing
  66275. * @see https://easings.net/#easeInBounce
  66276. * @param bounces Defines the number of bounces
  66277. * @param bounciness Defines the amplitude of the bounce
  66278. */
  66279. constructor(
  66280. /** Defines the number of bounces */
  66281. bounces?: number,
  66282. /** Defines the amplitude of the bounce */
  66283. bounciness?: number);
  66284. /** @hidden */
  66285. easeInCore(gradient: number): number;
  66286. }
  66287. /**
  66288. * Easing function with a power of 3 shape (see link below).
  66289. * @see https://easings.net/#easeInCubic
  66290. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66291. */
  66292. export class CubicEase extends EasingFunction implements IEasingFunction {
  66293. /** @hidden */
  66294. easeInCore(gradient: number): number;
  66295. }
  66296. /**
  66297. * Easing function with an elastic shape (see link below).
  66298. * @see https://easings.net/#easeInElastic
  66299. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66300. */
  66301. export class ElasticEase extends EasingFunction implements IEasingFunction {
  66302. /** Defines the number of oscillations*/
  66303. oscillations: number;
  66304. /** Defines the amplitude of the oscillations*/
  66305. springiness: number;
  66306. /**
  66307. * Instantiates an elastic easing function
  66308. * @see https://easings.net/#easeInElastic
  66309. * @param oscillations Defines the number of oscillations
  66310. * @param springiness Defines the amplitude of the oscillations
  66311. */
  66312. constructor(
  66313. /** Defines the number of oscillations*/
  66314. oscillations?: number,
  66315. /** Defines the amplitude of the oscillations*/
  66316. springiness?: number);
  66317. /** @hidden */
  66318. easeInCore(gradient: number): number;
  66319. }
  66320. /**
  66321. * Easing function with an exponential shape (see link below).
  66322. * @see https://easings.net/#easeInExpo
  66323. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66324. */
  66325. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  66326. /** Defines the exponent of the function */
  66327. exponent: number;
  66328. /**
  66329. * Instantiates an exponential easing function
  66330. * @see https://easings.net/#easeInExpo
  66331. * @param exponent Defines the exponent of the function
  66332. */
  66333. constructor(
  66334. /** Defines the exponent of the function */
  66335. exponent?: number);
  66336. /** @hidden */
  66337. easeInCore(gradient: number): number;
  66338. }
  66339. /**
  66340. * Easing function with a power shape (see link below).
  66341. * @see https://easings.net/#easeInQuad
  66342. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66343. */
  66344. export class PowerEase extends EasingFunction implements IEasingFunction {
  66345. /** Defines the power of the function */
  66346. power: number;
  66347. /**
  66348. * Instantiates an power base easing function
  66349. * @see https://easings.net/#easeInQuad
  66350. * @param power Defines the power of the function
  66351. */
  66352. constructor(
  66353. /** Defines the power of the function */
  66354. power?: number);
  66355. /** @hidden */
  66356. easeInCore(gradient: number): number;
  66357. }
  66358. /**
  66359. * Easing function with a power of 2 shape (see link below).
  66360. * @see https://easings.net/#easeInQuad
  66361. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66362. */
  66363. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  66364. /** @hidden */
  66365. easeInCore(gradient: number): number;
  66366. }
  66367. /**
  66368. * Easing function with a power of 4 shape (see link below).
  66369. * @see https://easings.net/#easeInQuart
  66370. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66371. */
  66372. export class QuarticEase extends EasingFunction implements IEasingFunction {
  66373. /** @hidden */
  66374. easeInCore(gradient: number): number;
  66375. }
  66376. /**
  66377. * Easing function with a power of 5 shape (see link below).
  66378. * @see https://easings.net/#easeInQuint
  66379. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66380. */
  66381. export class QuinticEase extends EasingFunction implements IEasingFunction {
  66382. /** @hidden */
  66383. easeInCore(gradient: number): number;
  66384. }
  66385. /**
  66386. * Easing function with a sin shape (see link below).
  66387. * @see https://easings.net/#easeInSine
  66388. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66389. */
  66390. export class SineEase extends EasingFunction implements IEasingFunction {
  66391. /** @hidden */
  66392. easeInCore(gradient: number): number;
  66393. }
  66394. /**
  66395. * Easing function with a bezier shape (see link below).
  66396. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66397. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66398. */
  66399. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  66400. /** Defines the x component of the start tangent in the bezier curve */
  66401. x1: number;
  66402. /** Defines the y component of the start tangent in the bezier curve */
  66403. y1: number;
  66404. /** Defines the x component of the end tangent in the bezier curve */
  66405. x2: number;
  66406. /** Defines the y component of the end tangent in the bezier curve */
  66407. y2: number;
  66408. /**
  66409. * Instantiates a bezier function
  66410. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66411. * @param x1 Defines the x component of the start tangent in the bezier curve
  66412. * @param y1 Defines the y component of the start tangent in the bezier curve
  66413. * @param x2 Defines the x component of the end tangent in the bezier curve
  66414. * @param y2 Defines the y component of the end tangent in the bezier curve
  66415. */
  66416. constructor(
  66417. /** Defines the x component of the start tangent in the bezier curve */
  66418. x1?: number,
  66419. /** Defines the y component of the start tangent in the bezier curve */
  66420. y1?: number,
  66421. /** Defines the x component of the end tangent in the bezier curve */
  66422. x2?: number,
  66423. /** Defines the y component of the end tangent in the bezier curve */
  66424. y2?: number);
  66425. /** @hidden */
  66426. easeInCore(gradient: number): number;
  66427. }
  66428. }
  66429. declare module BABYLON {
  66430. /**
  66431. * Defines an interface which represents an animation key frame
  66432. */
  66433. export interface IAnimationKey {
  66434. /**
  66435. * Frame of the key frame
  66436. */
  66437. frame: number;
  66438. /**
  66439. * Value at the specifies key frame
  66440. */
  66441. value: any;
  66442. /**
  66443. * The input tangent for the cubic hermite spline
  66444. */
  66445. inTangent?: any;
  66446. /**
  66447. * The output tangent for the cubic hermite spline
  66448. */
  66449. outTangent?: any;
  66450. /**
  66451. * The animation interpolation type
  66452. */
  66453. interpolation?: AnimationKeyInterpolation;
  66454. }
  66455. /**
  66456. * Enum for the animation key frame interpolation type
  66457. */
  66458. export enum AnimationKeyInterpolation {
  66459. /**
  66460. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  66461. */
  66462. STEP = 1
  66463. }
  66464. }
  66465. declare module BABYLON {
  66466. /**
  66467. * Represents the range of an animation
  66468. */
  66469. export class AnimationRange {
  66470. /**The name of the animation range**/
  66471. name: string;
  66472. /**The starting frame of the animation */
  66473. from: number;
  66474. /**The ending frame of the animation*/
  66475. to: number;
  66476. /**
  66477. * Initializes the range of an animation
  66478. * @param name The name of the animation range
  66479. * @param from The starting frame of the animation
  66480. * @param to The ending frame of the animation
  66481. */
  66482. constructor(
  66483. /**The name of the animation range**/
  66484. name: string,
  66485. /**The starting frame of the animation */
  66486. from: number,
  66487. /**The ending frame of the animation*/
  66488. to: number);
  66489. /**
  66490. * Makes a copy of the animation range
  66491. * @returns A copy of the animation range
  66492. */
  66493. clone(): AnimationRange;
  66494. }
  66495. }
  66496. declare module BABYLON {
  66497. /**
  66498. * Composed of a frame, and an action function
  66499. */
  66500. export class AnimationEvent {
  66501. /** The frame for which the event is triggered **/
  66502. frame: number;
  66503. /** The event to perform when triggered **/
  66504. action: (currentFrame: number) => void;
  66505. /** Specifies if the event should be triggered only once**/
  66506. onlyOnce?: boolean | undefined;
  66507. /**
  66508. * Specifies if the animation event is done
  66509. */
  66510. isDone: boolean;
  66511. /**
  66512. * Initializes the animation event
  66513. * @param frame The frame for which the event is triggered
  66514. * @param action The event to perform when triggered
  66515. * @param onlyOnce Specifies if the event should be triggered only once
  66516. */
  66517. constructor(
  66518. /** The frame for which the event is triggered **/
  66519. frame: number,
  66520. /** The event to perform when triggered **/
  66521. action: (currentFrame: number) => void,
  66522. /** Specifies if the event should be triggered only once**/
  66523. onlyOnce?: boolean | undefined);
  66524. /** @hidden */
  66525. _clone(): AnimationEvent;
  66526. }
  66527. }
  66528. declare module BABYLON {
  66529. /**
  66530. * Interface used to define a behavior
  66531. */
  66532. export interface Behavior<T> {
  66533. /** gets or sets behavior's name */
  66534. name: string;
  66535. /**
  66536. * Function called when the behavior needs to be initialized (after attaching it to a target)
  66537. */
  66538. init(): void;
  66539. /**
  66540. * Called when the behavior is attached to a target
  66541. * @param target defines the target where the behavior is attached to
  66542. */
  66543. attach(target: T): void;
  66544. /**
  66545. * Called when the behavior is detached from its target
  66546. */
  66547. detach(): void;
  66548. }
  66549. /**
  66550. * Interface implemented by classes supporting behaviors
  66551. */
  66552. export interface IBehaviorAware<T> {
  66553. /**
  66554. * Attach a behavior
  66555. * @param behavior defines the behavior to attach
  66556. * @returns the current host
  66557. */
  66558. addBehavior(behavior: Behavior<T>): T;
  66559. /**
  66560. * Remove a behavior from the current object
  66561. * @param behavior defines the behavior to detach
  66562. * @returns the current host
  66563. */
  66564. removeBehavior(behavior: Behavior<T>): T;
  66565. /**
  66566. * Gets a behavior using its name to search
  66567. * @param name defines the name to search
  66568. * @returns the behavior or null if not found
  66569. */
  66570. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  66571. }
  66572. }
  66573. declare module BABYLON {
  66574. /**
  66575. * @hidden
  66576. */
  66577. export class IntersectionInfo {
  66578. bu: Nullable<number>;
  66579. bv: Nullable<number>;
  66580. distance: number;
  66581. faceId: number;
  66582. subMeshId: number;
  66583. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  66584. }
  66585. }
  66586. declare module BABYLON {
  66587. /**
  66588. * Class used to store bounding sphere information
  66589. */
  66590. export class BoundingSphere {
  66591. /**
  66592. * Gets the center of the bounding sphere in local space
  66593. */
  66594. readonly center: Vector3;
  66595. /**
  66596. * Radius of the bounding sphere in local space
  66597. */
  66598. radius: number;
  66599. /**
  66600. * Gets the center of the bounding sphere in world space
  66601. */
  66602. readonly centerWorld: Vector3;
  66603. /**
  66604. * Radius of the bounding sphere in world space
  66605. */
  66606. radiusWorld: number;
  66607. /**
  66608. * Gets the minimum vector in local space
  66609. */
  66610. readonly minimum: Vector3;
  66611. /**
  66612. * Gets the maximum vector in local space
  66613. */
  66614. readonly maximum: Vector3;
  66615. private _worldMatrix;
  66616. private static readonly TmpVector3;
  66617. /**
  66618. * Creates a new bounding sphere
  66619. * @param min defines the minimum vector (in local space)
  66620. * @param max defines the maximum vector (in local space)
  66621. * @param worldMatrix defines the new world matrix
  66622. */
  66623. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66624. /**
  66625. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  66626. * @param min defines the new minimum vector (in local space)
  66627. * @param max defines the new maximum vector (in local space)
  66628. * @param worldMatrix defines the new world matrix
  66629. */
  66630. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66631. /**
  66632. * Scale the current bounding sphere by applying a scale factor
  66633. * @param factor defines the scale factor to apply
  66634. * @returns the current bounding box
  66635. */
  66636. scale(factor: number): BoundingSphere;
  66637. /**
  66638. * Gets the world matrix of the bounding box
  66639. * @returns a matrix
  66640. */
  66641. getWorldMatrix(): DeepImmutable<Matrix>;
  66642. /** @hidden */
  66643. _update(worldMatrix: DeepImmutable<Matrix>): void;
  66644. /**
  66645. * Tests if the bounding sphere is intersecting the frustum planes
  66646. * @param frustumPlanes defines the frustum planes to test
  66647. * @returns true if there is an intersection
  66648. */
  66649. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66650. /**
  66651. * Tests if the bounding sphere center is in between the frustum planes.
  66652. * Used for optimistic fast inclusion.
  66653. * @param frustumPlanes defines the frustum planes to test
  66654. * @returns true if the sphere center is in between the frustum planes
  66655. */
  66656. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66657. /**
  66658. * Tests if a point is inside the bounding sphere
  66659. * @param point defines the point to test
  66660. * @returns true if the point is inside the bounding sphere
  66661. */
  66662. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66663. /**
  66664. * Checks if two sphere intersct
  66665. * @param sphere0 sphere 0
  66666. * @param sphere1 sphere 1
  66667. * @returns true if the speres intersect
  66668. */
  66669. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  66670. }
  66671. }
  66672. declare module BABYLON {
  66673. /**
  66674. * Class used to store bounding box information
  66675. */
  66676. export class BoundingBox implements ICullable {
  66677. /**
  66678. * Gets the 8 vectors representing the bounding box in local space
  66679. */
  66680. readonly vectors: Vector3[];
  66681. /**
  66682. * Gets the center of the bounding box in local space
  66683. */
  66684. readonly center: Vector3;
  66685. /**
  66686. * Gets the center of the bounding box in world space
  66687. */
  66688. readonly centerWorld: Vector3;
  66689. /**
  66690. * Gets the extend size in local space
  66691. */
  66692. readonly extendSize: Vector3;
  66693. /**
  66694. * Gets the extend size in world space
  66695. */
  66696. readonly extendSizeWorld: Vector3;
  66697. /**
  66698. * Gets the OBB (object bounding box) directions
  66699. */
  66700. readonly directions: Vector3[];
  66701. /**
  66702. * Gets the 8 vectors representing the bounding box in world space
  66703. */
  66704. readonly vectorsWorld: Vector3[];
  66705. /**
  66706. * Gets the minimum vector in world space
  66707. */
  66708. readonly minimumWorld: Vector3;
  66709. /**
  66710. * Gets the maximum vector in world space
  66711. */
  66712. readonly maximumWorld: Vector3;
  66713. /**
  66714. * Gets the minimum vector in local space
  66715. */
  66716. readonly minimum: Vector3;
  66717. /**
  66718. * Gets the maximum vector in local space
  66719. */
  66720. readonly maximum: Vector3;
  66721. private _worldMatrix;
  66722. private static readonly TmpVector3;
  66723. /**
  66724. * @hidden
  66725. */
  66726. _tag: number;
  66727. /**
  66728. * Creates a new bounding box
  66729. * @param min defines the minimum vector (in local space)
  66730. * @param max defines the maximum vector (in local space)
  66731. * @param worldMatrix defines the new world matrix
  66732. */
  66733. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66734. /**
  66735. * Recreates the entire bounding box from scratch as if we call the constructor in place
  66736. * @param min defines the new minimum vector (in local space)
  66737. * @param max defines the new maximum vector (in local space)
  66738. * @param worldMatrix defines the new world matrix
  66739. */
  66740. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66741. /**
  66742. * Scale the current bounding box by applying a scale factor
  66743. * @param factor defines the scale factor to apply
  66744. * @returns the current bounding box
  66745. */
  66746. scale(factor: number): BoundingBox;
  66747. /**
  66748. * Gets the world matrix of the bounding box
  66749. * @returns a matrix
  66750. */
  66751. getWorldMatrix(): DeepImmutable<Matrix>;
  66752. /** @hidden */
  66753. _update(world: DeepImmutable<Matrix>): void;
  66754. /**
  66755. * Tests if the bounding box is intersecting the frustum planes
  66756. * @param frustumPlanes defines the frustum planes to test
  66757. * @returns true if there is an intersection
  66758. */
  66759. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66760. /**
  66761. * Tests if the bounding box is entirely inside the frustum planes
  66762. * @param frustumPlanes defines the frustum planes to test
  66763. * @returns true if there is an inclusion
  66764. */
  66765. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66766. /**
  66767. * Tests if a point is inside the bounding box
  66768. * @param point defines the point to test
  66769. * @returns true if the point is inside the bounding box
  66770. */
  66771. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66772. /**
  66773. * Tests if the bounding box intersects with a bounding sphere
  66774. * @param sphere defines the sphere to test
  66775. * @returns true if there is an intersection
  66776. */
  66777. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  66778. /**
  66779. * Tests if the bounding box intersects with a box defined by a min and max vectors
  66780. * @param min defines the min vector to use
  66781. * @param max defines the max vector to use
  66782. * @returns true if there is an intersection
  66783. */
  66784. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  66785. /**
  66786. * Tests if two bounding boxes are intersections
  66787. * @param box0 defines the first box to test
  66788. * @param box1 defines the second box to test
  66789. * @returns true if there is an intersection
  66790. */
  66791. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  66792. /**
  66793. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  66794. * @param minPoint defines the minimum vector of the bounding box
  66795. * @param maxPoint defines the maximum vector of the bounding box
  66796. * @param sphereCenter defines the sphere center
  66797. * @param sphereRadius defines the sphere radius
  66798. * @returns true if there is an intersection
  66799. */
  66800. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  66801. /**
  66802. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  66803. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  66804. * @param frustumPlanes defines the frustum planes to test
  66805. * @return true if there is an inclusion
  66806. */
  66807. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66808. /**
  66809. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  66810. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  66811. * @param frustumPlanes defines the frustum planes to test
  66812. * @return true if there is an intersection
  66813. */
  66814. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66815. }
  66816. }
  66817. declare module BABYLON {
  66818. /** @hidden */
  66819. export class Collider {
  66820. /** Define if a collision was found */
  66821. collisionFound: boolean;
  66822. /**
  66823. * Define last intersection point in local space
  66824. */
  66825. intersectionPoint: Vector3;
  66826. /**
  66827. * Define last collided mesh
  66828. */
  66829. collidedMesh: Nullable<AbstractMesh>;
  66830. private _collisionPoint;
  66831. private _planeIntersectionPoint;
  66832. private _tempVector;
  66833. private _tempVector2;
  66834. private _tempVector3;
  66835. private _tempVector4;
  66836. private _edge;
  66837. private _baseToVertex;
  66838. private _destinationPoint;
  66839. private _slidePlaneNormal;
  66840. private _displacementVector;
  66841. /** @hidden */
  66842. _radius: Vector3;
  66843. /** @hidden */
  66844. _retry: number;
  66845. private _velocity;
  66846. private _basePoint;
  66847. private _epsilon;
  66848. /** @hidden */
  66849. _velocityWorldLength: number;
  66850. /** @hidden */
  66851. _basePointWorld: Vector3;
  66852. private _velocityWorld;
  66853. private _normalizedVelocity;
  66854. /** @hidden */
  66855. _initialVelocity: Vector3;
  66856. /** @hidden */
  66857. _initialPosition: Vector3;
  66858. private _nearestDistance;
  66859. private _collisionMask;
  66860. collisionMask: number;
  66861. /**
  66862. * Gets the plane normal used to compute the sliding response (in local space)
  66863. */
  66864. readonly slidePlaneNormal: Vector3;
  66865. /** @hidden */
  66866. _initialize(source: Vector3, dir: Vector3, e: number): void;
  66867. /** @hidden */
  66868. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  66869. /** @hidden */
  66870. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  66871. /** @hidden */
  66872. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  66873. /** @hidden */
  66874. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  66875. /** @hidden */
  66876. _getResponse(pos: Vector3, vel: Vector3): void;
  66877. }
  66878. }
  66879. declare module BABYLON {
  66880. /**
  66881. * Interface for cullable objects
  66882. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  66883. */
  66884. export interface ICullable {
  66885. /**
  66886. * Checks if the object or part of the object is in the frustum
  66887. * @param frustumPlanes Camera near/planes
  66888. * @returns true if the object is in frustum otherwise false
  66889. */
  66890. isInFrustum(frustumPlanes: Plane[]): boolean;
  66891. /**
  66892. * Checks if a cullable object (mesh...) is in the camera frustum
  66893. * Unlike isInFrustum this cheks the full bounding box
  66894. * @param frustumPlanes Camera near/planes
  66895. * @returns true if the object is in frustum otherwise false
  66896. */
  66897. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  66898. }
  66899. /**
  66900. * Info for a bounding data of a mesh
  66901. */
  66902. export class BoundingInfo implements ICullable {
  66903. /**
  66904. * Bounding box for the mesh
  66905. */
  66906. readonly boundingBox: BoundingBox;
  66907. /**
  66908. * Bounding sphere for the mesh
  66909. */
  66910. readonly boundingSphere: BoundingSphere;
  66911. private _isLocked;
  66912. private static readonly TmpVector3;
  66913. /**
  66914. * Constructs bounding info
  66915. * @param minimum min vector of the bounding box/sphere
  66916. * @param maximum max vector of the bounding box/sphere
  66917. * @param worldMatrix defines the new world matrix
  66918. */
  66919. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66920. /**
  66921. * Recreates the entire bounding info from scratch as if we call the constructor in place
  66922. * @param min defines the new minimum vector (in local space)
  66923. * @param max defines the new maximum vector (in local space)
  66924. * @param worldMatrix defines the new world matrix
  66925. */
  66926. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66927. /**
  66928. * min vector of the bounding box/sphere
  66929. */
  66930. readonly minimum: Vector3;
  66931. /**
  66932. * max vector of the bounding box/sphere
  66933. */
  66934. readonly maximum: Vector3;
  66935. /**
  66936. * If the info is locked and won't be updated to avoid perf overhead
  66937. */
  66938. isLocked: boolean;
  66939. /**
  66940. * Updates the bounding sphere and box
  66941. * @param world world matrix to be used to update
  66942. */
  66943. update(world: DeepImmutable<Matrix>): void;
  66944. /**
  66945. * Recreate the bounding info to be centered around a specific point given a specific extend.
  66946. * @param center New center of the bounding info
  66947. * @param extend New extend of the bounding info
  66948. * @returns the current bounding info
  66949. */
  66950. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  66951. /**
  66952. * Scale the current bounding info by applying a scale factor
  66953. * @param factor defines the scale factor to apply
  66954. * @returns the current bounding info
  66955. */
  66956. scale(factor: number): BoundingInfo;
  66957. /**
  66958. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  66959. * @param frustumPlanes defines the frustum to test
  66960. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  66961. * @returns true if the bounding info is in the frustum planes
  66962. */
  66963. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  66964. /**
  66965. * Gets the world distance between the min and max points of the bounding box
  66966. */
  66967. readonly diagonalLength: number;
  66968. /**
  66969. * Checks if a cullable object (mesh...) is in the camera frustum
  66970. * Unlike isInFrustum this cheks the full bounding box
  66971. * @param frustumPlanes Camera near/planes
  66972. * @returns true if the object is in frustum otherwise false
  66973. */
  66974. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66975. /** @hidden */
  66976. _checkCollision(collider: Collider): boolean;
  66977. /**
  66978. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  66979. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  66980. * @param point the point to check intersection with
  66981. * @returns if the point intersects
  66982. */
  66983. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66984. /**
  66985. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  66986. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  66987. * @param boundingInfo the bounding info to check intersection with
  66988. * @param precise if the intersection should be done using OBB
  66989. * @returns if the bounding info intersects
  66990. */
  66991. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  66992. }
  66993. }
  66994. declare module BABYLON {
  66995. /**
  66996. * Defines an array and its length.
  66997. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  66998. */
  66999. export interface ISmartArrayLike<T> {
  67000. /**
  67001. * The data of the array.
  67002. */
  67003. data: Array<T>;
  67004. /**
  67005. * The active length of the array.
  67006. */
  67007. length: number;
  67008. }
  67009. /**
  67010. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  67011. */
  67012. export class SmartArray<T> implements ISmartArrayLike<T> {
  67013. /**
  67014. * The full set of data from the array.
  67015. */
  67016. data: Array<T>;
  67017. /**
  67018. * The active length of the array.
  67019. */
  67020. length: number;
  67021. protected _id: number;
  67022. /**
  67023. * Instantiates a Smart Array.
  67024. * @param capacity defines the default capacity of the array.
  67025. */
  67026. constructor(capacity: number);
  67027. /**
  67028. * Pushes a value at the end of the active data.
  67029. * @param value defines the object to push in the array.
  67030. */
  67031. push(value: T): void;
  67032. /**
  67033. * Iterates over the active data and apply the lambda to them.
  67034. * @param func defines the action to apply on each value.
  67035. */
  67036. forEach(func: (content: T) => void): void;
  67037. /**
  67038. * Sorts the full sets of data.
  67039. * @param compareFn defines the comparison function to apply.
  67040. */
  67041. sort(compareFn: (a: T, b: T) => number): void;
  67042. /**
  67043. * Resets the active data to an empty array.
  67044. */
  67045. reset(): void;
  67046. /**
  67047. * Releases all the data from the array as well as the array.
  67048. */
  67049. dispose(): void;
  67050. /**
  67051. * Concats the active data with a given array.
  67052. * @param array defines the data to concatenate with.
  67053. */
  67054. concat(array: any): void;
  67055. /**
  67056. * Returns the position of a value in the active data.
  67057. * @param value defines the value to find the index for
  67058. * @returns the index if found in the active data otherwise -1
  67059. */
  67060. indexOf(value: T): number;
  67061. /**
  67062. * Returns whether an element is part of the active data.
  67063. * @param value defines the value to look for
  67064. * @returns true if found in the active data otherwise false
  67065. */
  67066. contains(value: T): boolean;
  67067. private static _GlobalId;
  67068. }
  67069. /**
  67070. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  67071. * The data in this array can only be present once
  67072. */
  67073. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  67074. private _duplicateId;
  67075. /**
  67076. * Pushes a value at the end of the active data.
  67077. * THIS DOES NOT PREVENT DUPPLICATE DATA
  67078. * @param value defines the object to push in the array.
  67079. */
  67080. push(value: T): void;
  67081. /**
  67082. * Pushes a value at the end of the active data.
  67083. * If the data is already present, it won t be added again
  67084. * @param value defines the object to push in the array.
  67085. * @returns true if added false if it was already present
  67086. */
  67087. pushNoDuplicate(value: T): boolean;
  67088. /**
  67089. * Resets the active data to an empty array.
  67090. */
  67091. reset(): void;
  67092. /**
  67093. * Concats the active data with a given array.
  67094. * This ensures no dupplicate will be present in the result.
  67095. * @param array defines the data to concatenate with.
  67096. */
  67097. concatWithNoDuplicate(array: any): void;
  67098. }
  67099. }
  67100. declare module BABYLON {
  67101. /**
  67102. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67103. * separate meshes. This can be use to improve performances.
  67104. * @see http://doc.babylonjs.com/how_to/multi_materials
  67105. */
  67106. export class MultiMaterial extends Material {
  67107. private _subMaterials;
  67108. /**
  67109. * Gets or Sets the list of Materials used within the multi material.
  67110. * They need to be ordered according to the submeshes order in the associated mesh
  67111. */
  67112. subMaterials: Nullable<Material>[];
  67113. /**
  67114. * Function used to align with Node.getChildren()
  67115. * @returns the list of Materials used within the multi material
  67116. */
  67117. getChildren(): Nullable<Material>[];
  67118. /**
  67119. * Instantiates a new Multi Material
  67120. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67121. * separate meshes. This can be use to improve performances.
  67122. * @see http://doc.babylonjs.com/how_to/multi_materials
  67123. * @param name Define the name in the scene
  67124. * @param scene Define the scene the material belongs to
  67125. */
  67126. constructor(name: string, scene: Scene);
  67127. private _hookArray;
  67128. /**
  67129. * Get one of the submaterial by its index in the submaterials array
  67130. * @param index The index to look the sub material at
  67131. * @returns The Material if the index has been defined
  67132. */
  67133. getSubMaterial(index: number): Nullable<Material>;
  67134. /**
  67135. * Get the list of active textures for the whole sub materials list.
  67136. * @returns All the textures that will be used during the rendering
  67137. */
  67138. getActiveTextures(): BaseTexture[];
  67139. /**
  67140. * Gets the current class name of the material e.g. "MultiMaterial"
  67141. * Mainly use in serialization.
  67142. * @returns the class name
  67143. */
  67144. getClassName(): string;
  67145. /**
  67146. * Checks if the material is ready to render the requested sub mesh
  67147. * @param mesh Define the mesh the submesh belongs to
  67148. * @param subMesh Define the sub mesh to look readyness for
  67149. * @param useInstances Define whether or not the material is used with instances
  67150. * @returns true if ready, otherwise false
  67151. */
  67152. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  67153. /**
  67154. * Clones the current material and its related sub materials
  67155. * @param name Define the name of the newly cloned material
  67156. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  67157. * @returns the cloned material
  67158. */
  67159. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  67160. /**
  67161. * Serializes the materials into a JSON representation.
  67162. * @returns the JSON representation
  67163. */
  67164. serialize(): any;
  67165. /**
  67166. * Dispose the material and release its associated resources
  67167. * @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)
  67168. * @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)
  67169. * @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)
  67170. */
  67171. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  67172. /**
  67173. * Creates a MultiMaterial from parsed MultiMaterial data.
  67174. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  67175. * @param scene defines the hosting scene
  67176. * @returns a new MultiMaterial
  67177. */
  67178. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  67179. }
  67180. }
  67181. declare module BABYLON {
  67182. /**
  67183. * Class used to represent data loading progression
  67184. */
  67185. export class SceneLoaderFlags {
  67186. private static _ForceFullSceneLoadingForIncremental;
  67187. private static _ShowLoadingScreen;
  67188. private static _CleanBoneMatrixWeights;
  67189. private static _loggingLevel;
  67190. /**
  67191. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  67192. */
  67193. static ForceFullSceneLoadingForIncremental: boolean;
  67194. /**
  67195. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  67196. */
  67197. static ShowLoadingScreen: boolean;
  67198. /**
  67199. * Defines the current logging level (while loading the scene)
  67200. * @ignorenaming
  67201. */
  67202. static loggingLevel: number;
  67203. /**
  67204. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  67205. */
  67206. static CleanBoneMatrixWeights: boolean;
  67207. }
  67208. }
  67209. declare module BABYLON {
  67210. /**
  67211. * 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.
  67212. * @see https://doc.babylonjs.com/how_to/transformnode
  67213. */
  67214. export class TransformNode extends Node {
  67215. /**
  67216. * Object will not rotate to face the camera
  67217. */
  67218. static BILLBOARDMODE_NONE: number;
  67219. /**
  67220. * Object will rotate to face the camera but only on the x axis
  67221. */
  67222. static BILLBOARDMODE_X: number;
  67223. /**
  67224. * Object will rotate to face the camera but only on the y axis
  67225. */
  67226. static BILLBOARDMODE_Y: number;
  67227. /**
  67228. * Object will rotate to face the camera but only on the z axis
  67229. */
  67230. static BILLBOARDMODE_Z: number;
  67231. /**
  67232. * Object will rotate to face the camera
  67233. */
  67234. static BILLBOARDMODE_ALL: number;
  67235. private _forward;
  67236. private _forwardInverted;
  67237. private _up;
  67238. private _right;
  67239. private _rightInverted;
  67240. private _position;
  67241. private _rotation;
  67242. private _rotationQuaternion;
  67243. protected _scaling: Vector3;
  67244. protected _isDirty: boolean;
  67245. private _transformToBoneReferal;
  67246. private _billboardMode;
  67247. /**
  67248. * Gets or sets the billboard mode. Default is 0.
  67249. *
  67250. * | Value | Type | Description |
  67251. * | --- | --- | --- |
  67252. * | 0 | BILLBOARDMODE_NONE | |
  67253. * | 1 | BILLBOARDMODE_X | |
  67254. * | 2 | BILLBOARDMODE_Y | |
  67255. * | 4 | BILLBOARDMODE_Z | |
  67256. * | 7 | BILLBOARDMODE_ALL | |
  67257. *
  67258. */
  67259. billboardMode: number;
  67260. private _preserveParentRotationForBillboard;
  67261. /**
  67262. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  67263. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  67264. */
  67265. preserveParentRotationForBillboard: boolean;
  67266. /**
  67267. * 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
  67268. */
  67269. scalingDeterminant: number;
  67270. private _infiniteDistance;
  67271. /**
  67272. * Gets or sets the distance of the object to max, often used by skybox
  67273. */
  67274. infiniteDistance: boolean;
  67275. /**
  67276. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  67277. * By default the system will update normals to compensate
  67278. */
  67279. ignoreNonUniformScaling: boolean;
  67280. /**
  67281. * 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
  67282. */
  67283. reIntegrateRotationIntoRotationQuaternion: boolean;
  67284. /** @hidden */
  67285. _poseMatrix: Nullable<Matrix>;
  67286. /** @hidden */
  67287. _localMatrix: Matrix;
  67288. private _usePivotMatrix;
  67289. private _absolutePosition;
  67290. private _pivotMatrix;
  67291. private _pivotMatrixInverse;
  67292. protected _postMultiplyPivotMatrix: boolean;
  67293. protected _isWorldMatrixFrozen: boolean;
  67294. /** @hidden */
  67295. _indexInSceneTransformNodesArray: number;
  67296. /**
  67297. * An event triggered after the world matrix is updated
  67298. */
  67299. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  67300. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  67301. /**
  67302. * Gets a string identifying the name of the class
  67303. * @returns "TransformNode" string
  67304. */
  67305. getClassName(): string;
  67306. /**
  67307. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  67308. */
  67309. position: Vector3;
  67310. /**
  67311. * 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)).
  67312. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  67313. */
  67314. rotation: Vector3;
  67315. /**
  67316. * 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)).
  67317. */
  67318. scaling: Vector3;
  67319. /**
  67320. * 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).
  67321. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  67322. */
  67323. rotationQuaternion: Nullable<Quaternion>;
  67324. /**
  67325. * The forward direction of that transform in world space.
  67326. */
  67327. readonly forward: Vector3;
  67328. /**
  67329. * The up direction of that transform in world space.
  67330. */
  67331. readonly up: Vector3;
  67332. /**
  67333. * The right direction of that transform in world space.
  67334. */
  67335. readonly right: Vector3;
  67336. /**
  67337. * Copies the parameter passed Matrix into the mesh Pose matrix.
  67338. * @param matrix the matrix to copy the pose from
  67339. * @returns this TransformNode.
  67340. */
  67341. updatePoseMatrix(matrix: Matrix): TransformNode;
  67342. /**
  67343. * Returns the mesh Pose matrix.
  67344. * @returns the pose matrix
  67345. */
  67346. getPoseMatrix(): Matrix;
  67347. /** @hidden */
  67348. _isSynchronized(): boolean;
  67349. /** @hidden */
  67350. _initCache(): void;
  67351. /**
  67352. * Flag the transform node as dirty (Forcing it to update everything)
  67353. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  67354. * @returns this transform node
  67355. */
  67356. markAsDirty(property: string): TransformNode;
  67357. /**
  67358. * Returns the current mesh absolute position.
  67359. * Returns a Vector3.
  67360. */
  67361. readonly absolutePosition: Vector3;
  67362. /**
  67363. * Sets a new matrix to apply before all other transformation
  67364. * @param matrix defines the transform matrix
  67365. * @returns the current TransformNode
  67366. */
  67367. setPreTransformMatrix(matrix: Matrix): TransformNode;
  67368. /**
  67369. * Sets a new pivot matrix to the current node
  67370. * @param matrix defines the new pivot matrix to use
  67371. * @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
  67372. * @returns the current TransformNode
  67373. */
  67374. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  67375. /**
  67376. * Returns the mesh pivot matrix.
  67377. * Default : Identity.
  67378. * @returns the matrix
  67379. */
  67380. getPivotMatrix(): Matrix;
  67381. /**
  67382. * Prevents the World matrix to be computed any longer.
  67383. * @returns the TransformNode.
  67384. */
  67385. freezeWorldMatrix(): TransformNode;
  67386. /**
  67387. * Allows back the World matrix computation.
  67388. * @returns the TransformNode.
  67389. */
  67390. unfreezeWorldMatrix(): this;
  67391. /**
  67392. * True if the World matrix has been frozen.
  67393. */
  67394. readonly isWorldMatrixFrozen: boolean;
  67395. /**
  67396. * Retuns the mesh absolute position in the World.
  67397. * @returns a Vector3.
  67398. */
  67399. getAbsolutePosition(): Vector3;
  67400. /**
  67401. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  67402. * @param absolutePosition the absolute position to set
  67403. * @returns the TransformNode.
  67404. */
  67405. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  67406. /**
  67407. * Sets the mesh position in its local space.
  67408. * @param vector3 the position to set in localspace
  67409. * @returns the TransformNode.
  67410. */
  67411. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  67412. /**
  67413. * Returns the mesh position in the local space from the current World matrix values.
  67414. * @returns a new Vector3.
  67415. */
  67416. getPositionExpressedInLocalSpace(): Vector3;
  67417. /**
  67418. * Translates the mesh along the passed Vector3 in its local space.
  67419. * @param vector3 the distance to translate in localspace
  67420. * @returns the TransformNode.
  67421. */
  67422. locallyTranslate(vector3: Vector3): TransformNode;
  67423. private static _lookAtVectorCache;
  67424. /**
  67425. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  67426. * @param targetPoint the position (must be in same space as current mesh) to look at
  67427. * @param yawCor optional yaw (y-axis) correction in radians
  67428. * @param pitchCor optional pitch (x-axis) correction in radians
  67429. * @param rollCor optional roll (z-axis) correction in radians
  67430. * @param space the choosen space of the target
  67431. * @returns the TransformNode.
  67432. */
  67433. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  67434. /**
  67435. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67436. * This Vector3 is expressed in the World space.
  67437. * @param localAxis axis to rotate
  67438. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67439. */
  67440. getDirection(localAxis: Vector3): Vector3;
  67441. /**
  67442. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  67443. * localAxis is expressed in the mesh local space.
  67444. * result is computed in the Wordl space from the mesh World matrix.
  67445. * @param localAxis axis to rotate
  67446. * @param result the resulting transformnode
  67447. * @returns this TransformNode.
  67448. */
  67449. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  67450. /**
  67451. * Sets this transform node rotation to the given local axis.
  67452. * @param localAxis the axis in local space
  67453. * @param yawCor optional yaw (y-axis) correction in radians
  67454. * @param pitchCor optional pitch (x-axis) correction in radians
  67455. * @param rollCor optional roll (z-axis) correction in radians
  67456. * @returns this TransformNode
  67457. */
  67458. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  67459. /**
  67460. * Sets a new pivot point to the current node
  67461. * @param point defines the new pivot point to use
  67462. * @param space defines if the point is in world or local space (local by default)
  67463. * @returns the current TransformNode
  67464. */
  67465. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  67466. /**
  67467. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  67468. * @returns the pivot point
  67469. */
  67470. getPivotPoint(): Vector3;
  67471. /**
  67472. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  67473. * @param result the vector3 to store the result
  67474. * @returns this TransformNode.
  67475. */
  67476. getPivotPointToRef(result: Vector3): TransformNode;
  67477. /**
  67478. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  67479. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  67480. */
  67481. getAbsolutePivotPoint(): Vector3;
  67482. /**
  67483. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  67484. * @param result vector3 to store the result
  67485. * @returns this TransformNode.
  67486. */
  67487. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  67488. /**
  67489. * Defines the passed node as the parent of the current node.
  67490. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  67491. * @see https://doc.babylonjs.com/how_to/parenting
  67492. * @param node the node ot set as the parent
  67493. * @returns this TransformNode.
  67494. */
  67495. setParent(node: Nullable<Node>): TransformNode;
  67496. private _nonUniformScaling;
  67497. /**
  67498. * True if the scaling property of this object is non uniform eg. (1,2,1)
  67499. */
  67500. readonly nonUniformScaling: boolean;
  67501. /** @hidden */
  67502. _updateNonUniformScalingState(value: boolean): boolean;
  67503. /**
  67504. * Attach the current TransformNode to another TransformNode associated with a bone
  67505. * @param bone Bone affecting the TransformNode
  67506. * @param affectedTransformNode TransformNode associated with the bone
  67507. * @returns this object
  67508. */
  67509. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  67510. /**
  67511. * Detach the transform node if its associated with a bone
  67512. * @returns this object
  67513. */
  67514. detachFromBone(): TransformNode;
  67515. private static _rotationAxisCache;
  67516. /**
  67517. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  67518. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67519. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67520. * The passed axis is also normalized.
  67521. * @param axis the axis to rotate around
  67522. * @param amount the amount to rotate in radians
  67523. * @param space Space to rotate in (Default: local)
  67524. * @returns the TransformNode.
  67525. */
  67526. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  67527. /**
  67528. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  67529. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67530. * The passed axis is also normalized. .
  67531. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  67532. * @param point the point to rotate around
  67533. * @param axis the axis to rotate around
  67534. * @param amount the amount to rotate in radians
  67535. * @returns the TransformNode
  67536. */
  67537. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  67538. /**
  67539. * Translates the mesh along the axis vector for the passed distance in the given space.
  67540. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67541. * @param axis the axis to translate in
  67542. * @param distance the distance to translate
  67543. * @param space Space to rotate in (Default: local)
  67544. * @returns the TransformNode.
  67545. */
  67546. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  67547. /**
  67548. * Adds a rotation step to the mesh current rotation.
  67549. * x, y, z are Euler angles expressed in radians.
  67550. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  67551. * This means this rotation is made in the mesh local space only.
  67552. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  67553. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  67554. * ```javascript
  67555. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  67556. * ```
  67557. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  67558. * 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.
  67559. * @param x Rotation to add
  67560. * @param y Rotation to add
  67561. * @param z Rotation to add
  67562. * @returns the TransformNode.
  67563. */
  67564. addRotation(x: number, y: number, z: number): TransformNode;
  67565. /**
  67566. * @hidden
  67567. */
  67568. protected _getEffectiveParent(): Nullable<Node>;
  67569. /**
  67570. * Computes the world matrix of the node
  67571. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67572. * @returns the world matrix
  67573. */
  67574. computeWorldMatrix(force?: boolean): Matrix;
  67575. protected _afterComputeWorldMatrix(): void;
  67576. /**
  67577. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  67578. * @param func callback function to add
  67579. *
  67580. * @returns the TransformNode.
  67581. */
  67582. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67583. /**
  67584. * Removes a registered callback function.
  67585. * @param func callback function to remove
  67586. * @returns the TransformNode.
  67587. */
  67588. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67589. /**
  67590. * Gets the position of the current mesh in camera space
  67591. * @param camera defines the camera to use
  67592. * @returns a position
  67593. */
  67594. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  67595. /**
  67596. * Returns the distance from the mesh to the active camera
  67597. * @param camera defines the camera to use
  67598. * @returns the distance
  67599. */
  67600. getDistanceToCamera(camera?: Nullable<Camera>): number;
  67601. /**
  67602. * Clone the current transform node
  67603. * @param name Name of the new clone
  67604. * @param newParent New parent for the clone
  67605. * @param doNotCloneChildren Do not clone children hierarchy
  67606. * @returns the new transform node
  67607. */
  67608. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  67609. /**
  67610. * Serializes the objects information.
  67611. * @param currentSerializationObject defines the object to serialize in
  67612. * @returns the serialized object
  67613. */
  67614. serialize(currentSerializationObject?: any): any;
  67615. /**
  67616. * Returns a new TransformNode object parsed from the source provided.
  67617. * @param parsedTransformNode is the source.
  67618. * @param scene the scne the object belongs to
  67619. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  67620. * @returns a new TransformNode object parsed from the source provided.
  67621. */
  67622. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  67623. /**
  67624. * Get all child-transformNodes of this node
  67625. * @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
  67626. * @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
  67627. * @returns an array of TransformNode
  67628. */
  67629. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  67630. /**
  67631. * Releases resources associated with this transform node.
  67632. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67633. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67634. */
  67635. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67636. }
  67637. }
  67638. declare module BABYLON {
  67639. /**
  67640. * Class used to override all child animations of a given target
  67641. */
  67642. export class AnimationPropertiesOverride {
  67643. /**
  67644. * Gets or sets a value indicating if animation blending must be used
  67645. */
  67646. enableBlending: boolean;
  67647. /**
  67648. * Gets or sets the blending speed to use when enableBlending is true
  67649. */
  67650. blendingSpeed: number;
  67651. /**
  67652. * Gets or sets the default loop mode to use
  67653. */
  67654. loopMode: number;
  67655. }
  67656. }
  67657. declare module BABYLON {
  67658. /**
  67659. * Class used to store bone information
  67660. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  67661. */
  67662. export class Bone extends Node {
  67663. /**
  67664. * defines the bone name
  67665. */
  67666. name: string;
  67667. private static _tmpVecs;
  67668. private static _tmpQuat;
  67669. private static _tmpMats;
  67670. /**
  67671. * Gets the list of child bones
  67672. */
  67673. children: Bone[];
  67674. /** Gets the animations associated with this bone */
  67675. animations: Animation[];
  67676. /**
  67677. * Gets or sets bone length
  67678. */
  67679. length: number;
  67680. /**
  67681. * @hidden Internal only
  67682. * Set this value to map this bone to a different index in the transform matrices
  67683. * Set this value to -1 to exclude the bone from the transform matrices
  67684. */
  67685. _index: Nullable<number>;
  67686. private _skeleton;
  67687. private _localMatrix;
  67688. private _restPose;
  67689. private _baseMatrix;
  67690. private _absoluteTransform;
  67691. private _invertedAbsoluteTransform;
  67692. private _parent;
  67693. private _scalingDeterminant;
  67694. private _worldTransform;
  67695. private _localScaling;
  67696. private _localRotation;
  67697. private _localPosition;
  67698. private _needToDecompose;
  67699. private _needToCompose;
  67700. /** @hidden */
  67701. _linkedTransformNode: Nullable<TransformNode>;
  67702. /** @hidden */
  67703. /** @hidden */
  67704. _matrix: Matrix;
  67705. /**
  67706. * Create a new bone
  67707. * @param name defines the bone name
  67708. * @param skeleton defines the parent skeleton
  67709. * @param parentBone defines the parent (can be null if the bone is the root)
  67710. * @param localMatrix defines the local matrix
  67711. * @param restPose defines the rest pose matrix
  67712. * @param baseMatrix defines the base matrix
  67713. * @param index defines index of the bone in the hiearchy
  67714. */
  67715. constructor(
  67716. /**
  67717. * defines the bone name
  67718. */
  67719. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  67720. /**
  67721. * Gets the current object class name.
  67722. * @return the class name
  67723. */
  67724. getClassName(): string;
  67725. /**
  67726. * Gets the parent skeleton
  67727. * @returns a skeleton
  67728. */
  67729. getSkeleton(): Skeleton;
  67730. /**
  67731. * Gets parent bone
  67732. * @returns a bone or null if the bone is the root of the bone hierarchy
  67733. */
  67734. getParent(): Nullable<Bone>;
  67735. /**
  67736. * Returns an array containing the root bones
  67737. * @returns an array containing the root bones
  67738. */
  67739. getChildren(): Array<Bone>;
  67740. /**
  67741. * Sets the parent bone
  67742. * @param parent defines the parent (can be null if the bone is the root)
  67743. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67744. */
  67745. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  67746. /**
  67747. * Gets the local matrix
  67748. * @returns a matrix
  67749. */
  67750. getLocalMatrix(): Matrix;
  67751. /**
  67752. * Gets the base matrix (initial matrix which remains unchanged)
  67753. * @returns a matrix
  67754. */
  67755. getBaseMatrix(): Matrix;
  67756. /**
  67757. * Gets the rest pose matrix
  67758. * @returns a matrix
  67759. */
  67760. getRestPose(): Matrix;
  67761. /**
  67762. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  67763. */
  67764. getWorldMatrix(): Matrix;
  67765. /**
  67766. * Sets the local matrix to rest pose matrix
  67767. */
  67768. returnToRest(): void;
  67769. /**
  67770. * Gets the inverse of the absolute transform matrix.
  67771. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  67772. * @returns a matrix
  67773. */
  67774. getInvertedAbsoluteTransform(): Matrix;
  67775. /**
  67776. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  67777. * @returns a matrix
  67778. */
  67779. getAbsoluteTransform(): Matrix;
  67780. /**
  67781. * Links with the given transform node.
  67782. * The local matrix of this bone is copied from the transform node every frame.
  67783. * @param transformNode defines the transform node to link to
  67784. */
  67785. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  67786. /** Gets or sets current position (in local space) */
  67787. position: Vector3;
  67788. /** Gets or sets current rotation (in local space) */
  67789. rotation: Vector3;
  67790. /** Gets or sets current rotation quaternion (in local space) */
  67791. rotationQuaternion: Quaternion;
  67792. /** Gets or sets current scaling (in local space) */
  67793. scaling: Vector3;
  67794. /**
  67795. * Gets the animation properties override
  67796. */
  67797. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  67798. private _decompose;
  67799. private _compose;
  67800. /**
  67801. * Update the base and local matrices
  67802. * @param matrix defines the new base or local matrix
  67803. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67804. * @param updateLocalMatrix defines if the local matrix should be updated
  67805. */
  67806. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  67807. /** @hidden */
  67808. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  67809. /**
  67810. * Flag the bone as dirty (Forcing it to update everything)
  67811. */
  67812. markAsDirty(): void;
  67813. private _markAsDirtyAndCompose;
  67814. private _markAsDirtyAndDecompose;
  67815. /**
  67816. * Translate the bone in local or world space
  67817. * @param vec The amount to translate the bone
  67818. * @param space The space that the translation is in
  67819. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67820. */
  67821. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67822. /**
  67823. * Set the postion of the bone in local or world space
  67824. * @param position The position to set the bone
  67825. * @param space The space that the position is in
  67826. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67827. */
  67828. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67829. /**
  67830. * Set the absolute position of the bone (world space)
  67831. * @param position The position to set the bone
  67832. * @param mesh The mesh that this bone is attached to
  67833. */
  67834. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  67835. /**
  67836. * Scale the bone on the x, y and z axes (in local space)
  67837. * @param x The amount to scale the bone on the x axis
  67838. * @param y The amount to scale the bone on the y axis
  67839. * @param z The amount to scale the bone on the z axis
  67840. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  67841. */
  67842. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  67843. /**
  67844. * Set the bone scaling in local space
  67845. * @param scale defines the scaling vector
  67846. */
  67847. setScale(scale: Vector3): void;
  67848. /**
  67849. * Gets the current scaling in local space
  67850. * @returns the current scaling vector
  67851. */
  67852. getScale(): Vector3;
  67853. /**
  67854. * Gets the current scaling in local space and stores it in a target vector
  67855. * @param result defines the target vector
  67856. */
  67857. getScaleToRef(result: Vector3): void;
  67858. /**
  67859. * Set the yaw, pitch, and roll of the bone in local or world space
  67860. * @param yaw The rotation of the bone on the y axis
  67861. * @param pitch The rotation of the bone on the x axis
  67862. * @param roll The rotation of the bone on the z axis
  67863. * @param space The space that the axes of rotation are in
  67864. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67865. */
  67866. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  67867. /**
  67868. * Add a rotation to the bone on an axis in local or world space
  67869. * @param axis The axis to rotate the bone on
  67870. * @param amount The amount to rotate the bone
  67871. * @param space The space that the axis is in
  67872. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67873. */
  67874. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  67875. /**
  67876. * Set the rotation of the bone to a particular axis angle in local or world space
  67877. * @param axis The axis to rotate the bone on
  67878. * @param angle The angle that the bone should be rotated to
  67879. * @param space The space that the axis is in
  67880. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67881. */
  67882. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  67883. /**
  67884. * Set the euler rotation of the bone in local of world space
  67885. * @param rotation The euler rotation that the bone should be set to
  67886. * @param space The space that the rotation is in
  67887. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67888. */
  67889. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67890. /**
  67891. * Set the quaternion rotation of the bone in local of world space
  67892. * @param quat The quaternion rotation that the bone should be set to
  67893. * @param space The space that the rotation is in
  67894. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67895. */
  67896. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  67897. /**
  67898. * Set the rotation matrix of the bone in local of world space
  67899. * @param rotMat The rotation matrix that the bone should be set to
  67900. * @param space The space that the rotation is in
  67901. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67902. */
  67903. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  67904. private _rotateWithMatrix;
  67905. private _getNegativeRotationToRef;
  67906. /**
  67907. * Get the position of the bone in local or world space
  67908. * @param space The space that the returned position is in
  67909. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67910. * @returns The position of the bone
  67911. */
  67912. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  67913. /**
  67914. * Copy the position of the bone to a vector3 in local or world space
  67915. * @param space The space that the returned position is in
  67916. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67917. * @param result The vector3 to copy the position to
  67918. */
  67919. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  67920. /**
  67921. * Get the absolute position of the bone (world space)
  67922. * @param mesh The mesh that this bone is attached to
  67923. * @returns The absolute position of the bone
  67924. */
  67925. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  67926. /**
  67927. * Copy the absolute position of the bone (world space) to the result param
  67928. * @param mesh The mesh that this bone is attached to
  67929. * @param result The vector3 to copy the absolute position to
  67930. */
  67931. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  67932. /**
  67933. * Compute the absolute transforms of this bone and its children
  67934. */
  67935. computeAbsoluteTransforms(): void;
  67936. /**
  67937. * Get the world direction from an axis that is in the local space of the bone
  67938. * @param localAxis The local direction that is used to compute the world direction
  67939. * @param mesh The mesh that this bone is attached to
  67940. * @returns The world direction
  67941. */
  67942. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67943. /**
  67944. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  67945. * @param localAxis The local direction that is used to compute the world direction
  67946. * @param mesh The mesh that this bone is attached to
  67947. * @param result The vector3 that the world direction will be copied to
  67948. */
  67949. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67950. /**
  67951. * Get the euler rotation of the bone in local or world space
  67952. * @param space The space that the rotation should be in
  67953. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67954. * @returns The euler rotation
  67955. */
  67956. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  67957. /**
  67958. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  67959. * @param space The space that the rotation should be in
  67960. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67961. * @param result The vector3 that the rotation should be copied to
  67962. */
  67963. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67964. /**
  67965. * Get the quaternion rotation of the bone in either local or world space
  67966. * @param space The space that the rotation should be in
  67967. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67968. * @returns The quaternion rotation
  67969. */
  67970. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  67971. /**
  67972. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  67973. * @param space The space that the rotation should be in
  67974. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67975. * @param result The quaternion that the rotation should be copied to
  67976. */
  67977. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  67978. /**
  67979. * Get the rotation matrix of the bone in local or world space
  67980. * @param space The space that the rotation should be in
  67981. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67982. * @returns The rotation matrix
  67983. */
  67984. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  67985. /**
  67986. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  67987. * @param space The space that the rotation should be in
  67988. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67989. * @param result The quaternion that the rotation should be copied to
  67990. */
  67991. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  67992. /**
  67993. * Get the world position of a point that is in the local space of the bone
  67994. * @param position The local position
  67995. * @param mesh The mesh that this bone is attached to
  67996. * @returns The world position
  67997. */
  67998. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67999. /**
  68000. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  68001. * @param position The local position
  68002. * @param mesh The mesh that this bone is attached to
  68003. * @param result The vector3 that the world position should be copied to
  68004. */
  68005. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68006. /**
  68007. * Get the local position of a point that is in world space
  68008. * @param position The world position
  68009. * @param mesh The mesh that this bone is attached to
  68010. * @returns The local position
  68011. */
  68012. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68013. /**
  68014. * Get the local position of a point that is in world space and copy it to the result param
  68015. * @param position The world position
  68016. * @param mesh The mesh that this bone is attached to
  68017. * @param result The vector3 that the local position should be copied to
  68018. */
  68019. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68020. }
  68021. }
  68022. declare module BABYLON {
  68023. /**
  68024. * Enum that determines the text-wrapping mode to use.
  68025. */
  68026. export enum InspectableType {
  68027. /**
  68028. * Checkbox for booleans
  68029. */
  68030. Checkbox = 0,
  68031. /**
  68032. * Sliders for numbers
  68033. */
  68034. Slider = 1,
  68035. /**
  68036. * Vector3
  68037. */
  68038. Vector3 = 2,
  68039. /**
  68040. * Quaternions
  68041. */
  68042. Quaternion = 3,
  68043. /**
  68044. * Color3
  68045. */
  68046. Color3 = 4
  68047. }
  68048. /**
  68049. * Interface used to define custom inspectable properties.
  68050. * This interface is used by the inspector to display custom property grids
  68051. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68052. */
  68053. export interface IInspectable {
  68054. /**
  68055. * Gets the label to display
  68056. */
  68057. label: string;
  68058. /**
  68059. * Gets the name of the property to edit
  68060. */
  68061. propertyName: string;
  68062. /**
  68063. * Gets the type of the editor to use
  68064. */
  68065. type: InspectableType;
  68066. /**
  68067. * Gets the minimum value of the property when using in "slider" mode
  68068. */
  68069. min?: number;
  68070. /**
  68071. * Gets the maximum value of the property when using in "slider" mode
  68072. */
  68073. max?: number;
  68074. /**
  68075. * Gets the setp to use when using in "slider" mode
  68076. */
  68077. step?: number;
  68078. }
  68079. }
  68080. declare module BABYLON {
  68081. /**
  68082. * This represents the required contract to create a new type of texture loader.
  68083. */
  68084. export interface IInternalTextureLoader {
  68085. /**
  68086. * Defines wether the loader supports cascade loading the different faces.
  68087. */
  68088. supportCascades: boolean;
  68089. /**
  68090. * This returns if the loader support the current file information.
  68091. * @param extension defines the file extension of the file being loaded
  68092. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68093. * @param fallback defines the fallback internal texture if any
  68094. * @param isBase64 defines whether the texture is encoded as a base64
  68095. * @param isBuffer defines whether the texture data are stored as a buffer
  68096. * @returns true if the loader can load the specified file
  68097. */
  68098. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  68099. /**
  68100. * Transform the url before loading if required.
  68101. * @param rootUrl the url of the texture
  68102. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68103. * @returns the transformed texture
  68104. */
  68105. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  68106. /**
  68107. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  68108. * @param rootUrl the url of the texture
  68109. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68110. * @returns the fallback texture
  68111. */
  68112. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  68113. /**
  68114. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  68115. * @param data contains the texture data
  68116. * @param texture defines the BabylonJS internal texture
  68117. * @param createPolynomials will be true if polynomials have been requested
  68118. * @param onLoad defines the callback to trigger once the texture is ready
  68119. * @param onError defines the callback to trigger in case of error
  68120. */
  68121. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  68122. /**
  68123. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  68124. * @param data contains the texture data
  68125. * @param texture defines the BabylonJS internal texture
  68126. * @param callback defines the method to call once ready to upload
  68127. */
  68128. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  68129. }
  68130. }
  68131. declare module BABYLON {
  68132. interface Engine {
  68133. /**
  68134. * Creates a depth stencil cube texture.
  68135. * This is only available in WebGL 2.
  68136. * @param size The size of face edge in the cube texture.
  68137. * @param options The options defining the cube texture.
  68138. * @returns The cube texture
  68139. */
  68140. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  68141. /**
  68142. * Creates a cube texture
  68143. * @param rootUrl defines the url where the files to load is located
  68144. * @param scene defines the current scene
  68145. * @param files defines the list of files to load (1 per face)
  68146. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68147. * @param onLoad defines an optional callback raised when the texture is loaded
  68148. * @param onError defines an optional callback raised if there is an issue to load the texture
  68149. * @param format defines the format of the data
  68150. * @param forcedExtension defines the extension to use to pick the right loader
  68151. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  68152. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68153. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68154. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  68155. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  68156. * @returns the cube texture as an InternalTexture
  68157. */
  68158. 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;
  68159. /**
  68160. * Creates a cube texture
  68161. * @param rootUrl defines the url where the files to load is located
  68162. * @param scene defines the current scene
  68163. * @param files defines the list of files to load (1 per face)
  68164. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68165. * @param onLoad defines an optional callback raised when the texture is loaded
  68166. * @param onError defines an optional callback raised if there is an issue to load the texture
  68167. * @param format defines the format of the data
  68168. * @param forcedExtension defines the extension to use to pick the right loader
  68169. * @returns the cube texture as an InternalTexture
  68170. */
  68171. 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;
  68172. /**
  68173. * Creates a cube texture
  68174. * @param rootUrl defines the url where the files to load is located
  68175. * @param scene defines the current scene
  68176. * @param files defines the list of files to load (1 per face)
  68177. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68178. * @param onLoad defines an optional callback raised when the texture is loaded
  68179. * @param onError defines an optional callback raised if there is an issue to load the texture
  68180. * @param format defines the format of the data
  68181. * @param forcedExtension defines the extension to use to pick the right loader
  68182. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  68183. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68184. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68185. * @returns the cube texture as an InternalTexture
  68186. */
  68187. 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;
  68188. /** @hidden */
  68189. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  68190. /** @hidden */
  68191. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  68192. /** @hidden */
  68193. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  68194. /** @hidden */
  68195. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  68196. }
  68197. }
  68198. declare module BABYLON {
  68199. /**
  68200. * Class for creating a cube texture
  68201. */
  68202. export class CubeTexture extends BaseTexture {
  68203. private _delayedOnLoad;
  68204. /**
  68205. * The url of the texture
  68206. */
  68207. url: string;
  68208. /**
  68209. * Gets or sets the center of the bounding box associated with the cube texture.
  68210. * It must define where the camera used to render the texture was set
  68211. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  68212. */
  68213. boundingBoxPosition: Vector3;
  68214. private _boundingBoxSize;
  68215. /**
  68216. * Gets or sets the size of the bounding box associated with the cube texture
  68217. * When defined, the cubemap will switch to local mode
  68218. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  68219. * @example https://www.babylonjs-playground.com/#RNASML
  68220. */
  68221. /**
  68222. * Returns the bounding box size
  68223. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  68224. */
  68225. boundingBoxSize: Vector3;
  68226. protected _rotationY: number;
  68227. /**
  68228. * Sets texture matrix rotation angle around Y axis in radians.
  68229. */
  68230. /**
  68231. * Gets texture matrix rotation angle around Y axis radians.
  68232. */
  68233. rotationY: number;
  68234. /**
  68235. * Are mip maps generated for this texture or not.
  68236. */
  68237. readonly noMipmap: boolean;
  68238. private _noMipmap;
  68239. private _files;
  68240. private _extensions;
  68241. private _textureMatrix;
  68242. private _format;
  68243. private _createPolynomials;
  68244. /** @hidden */
  68245. _prefiltered: boolean;
  68246. /**
  68247. * Creates a cube texture from an array of image urls
  68248. * @param files defines an array of image urls
  68249. * @param scene defines the hosting scene
  68250. * @param noMipmap specifies if mip maps are not used
  68251. * @returns a cube texture
  68252. */
  68253. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  68254. /**
  68255. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  68256. * @param url defines the url of the prefiltered texture
  68257. * @param scene defines the scene the texture is attached to
  68258. * @param forcedExtension defines the extension of the file if different from the url
  68259. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  68260. * @return the prefiltered texture
  68261. */
  68262. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  68263. /**
  68264. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  68265. * as prefiltered data.
  68266. * @param rootUrl defines the url of the texture or the root name of the six images
  68267. * @param scene defines the scene the texture is attached to
  68268. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  68269. * @param noMipmap defines if mipmaps should be created or not
  68270. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  68271. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  68272. * @param onError defines a callback triggered in case of error during load
  68273. * @param format defines the internal format to use for the texture once loaded
  68274. * @param prefiltered defines whether or not the texture is created from prefiltered data
  68275. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  68276. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  68277. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68278. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68279. * @return the cube texture
  68280. */
  68281. 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);
  68282. /**
  68283. * Get the current class name of the texture useful for serialization or dynamic coding.
  68284. * @returns "CubeTexture"
  68285. */
  68286. getClassName(): string;
  68287. /**
  68288. * Update the url (and optional buffer) of this texture if url was null during construction.
  68289. * @param url the url of the texture
  68290. * @param forcedExtension defines the extension to use
  68291. * @param onLoad callback called when the texture is loaded (defaults to null)
  68292. */
  68293. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  68294. /**
  68295. * Delays loading of the cube texture
  68296. * @param forcedExtension defines the extension to use
  68297. */
  68298. delayLoad(forcedExtension?: string): void;
  68299. /**
  68300. * Returns the reflection texture matrix
  68301. * @returns the reflection texture matrix
  68302. */
  68303. getReflectionTextureMatrix(): Matrix;
  68304. /**
  68305. * Sets the reflection texture matrix
  68306. * @param value Reflection texture matrix
  68307. */
  68308. setReflectionTextureMatrix(value: Matrix): void;
  68309. /**
  68310. * Parses text to create a cube texture
  68311. * @param parsedTexture define the serialized text to read from
  68312. * @param scene defines the hosting scene
  68313. * @param rootUrl defines the root url of the cube texture
  68314. * @returns a cube texture
  68315. */
  68316. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  68317. /**
  68318. * Makes a clone, or deep copy, of the cube texture
  68319. * @returns a new cube texture
  68320. */
  68321. clone(): CubeTexture;
  68322. }
  68323. }
  68324. declare module BABYLON {
  68325. /** @hidden */
  68326. export var postprocessVertexShader: {
  68327. name: string;
  68328. shader: string;
  68329. };
  68330. }
  68331. declare module BABYLON {
  68332. /**
  68333. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  68334. * This is the base of the follow, arc rotate cameras and Free camera
  68335. * @see http://doc.babylonjs.com/features/cameras
  68336. */
  68337. export class TargetCamera extends Camera {
  68338. private static _RigCamTransformMatrix;
  68339. private static _TargetTransformMatrix;
  68340. private static _TargetFocalPoint;
  68341. /**
  68342. * Define the current direction the camera is moving to
  68343. */
  68344. cameraDirection: Vector3;
  68345. /**
  68346. * Define the current rotation the camera is rotating to
  68347. */
  68348. cameraRotation: Vector2;
  68349. /**
  68350. * When set, the up vector of the camera will be updated by the rotation of the camera
  68351. */
  68352. updateUpVectorFromRotation: boolean;
  68353. private _tmpQuaternion;
  68354. /**
  68355. * Define the current rotation of the camera
  68356. */
  68357. rotation: Vector3;
  68358. /**
  68359. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  68360. */
  68361. rotationQuaternion: Quaternion;
  68362. /**
  68363. * Define the current speed of the camera
  68364. */
  68365. speed: number;
  68366. /**
  68367. * Add cconstraint to the camera to prevent it to move freely in all directions and
  68368. * around all axis.
  68369. */
  68370. noRotationConstraint: boolean;
  68371. /**
  68372. * Define the current target of the camera as an object or a position.
  68373. */
  68374. lockedTarget: any;
  68375. /** @hidden */
  68376. _currentTarget: Vector3;
  68377. /** @hidden */
  68378. _initialFocalDistance: number;
  68379. /** @hidden */
  68380. _viewMatrix: Matrix;
  68381. /** @hidden */
  68382. _camMatrix: Matrix;
  68383. /** @hidden */
  68384. _cameraTransformMatrix: Matrix;
  68385. /** @hidden */
  68386. _cameraRotationMatrix: Matrix;
  68387. /** @hidden */
  68388. _referencePoint: Vector3;
  68389. /** @hidden */
  68390. _transformedReferencePoint: Vector3;
  68391. protected _globalCurrentTarget: Vector3;
  68392. protected _globalCurrentUpVector: Vector3;
  68393. /** @hidden */
  68394. _reset: () => void;
  68395. private _defaultUp;
  68396. /**
  68397. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  68398. * This is the base of the follow, arc rotate cameras and Free camera
  68399. * @see http://doc.babylonjs.com/features/cameras
  68400. * @param name Defines the name of the camera in the scene
  68401. * @param position Defines the start position of the camera in the scene
  68402. * @param scene Defines the scene the camera belongs to
  68403. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  68404. */
  68405. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  68406. /**
  68407. * Gets the position in front of the camera at a given distance.
  68408. * @param distance The distance from the camera we want the position to be
  68409. * @returns the position
  68410. */
  68411. getFrontPosition(distance: number): Vector3;
  68412. /** @hidden */
  68413. _getLockedTargetPosition(): Nullable<Vector3>;
  68414. private _storedPosition;
  68415. private _storedRotation;
  68416. private _storedRotationQuaternion;
  68417. /**
  68418. * Store current camera state of the camera (fov, position, rotation, etc..)
  68419. * @returns the camera
  68420. */
  68421. storeState(): Camera;
  68422. /**
  68423. * Restored camera state. You must call storeState() first
  68424. * @returns whether it was successful or not
  68425. * @hidden
  68426. */
  68427. _restoreStateValues(): boolean;
  68428. /** @hidden */
  68429. _initCache(): void;
  68430. /** @hidden */
  68431. _updateCache(ignoreParentClass?: boolean): void;
  68432. /** @hidden */
  68433. _isSynchronizedViewMatrix(): boolean;
  68434. /** @hidden */
  68435. _computeLocalCameraSpeed(): number;
  68436. /**
  68437. * Defines the target the camera should look at.
  68438. * This will automatically adapt alpha beta and radius to fit within the new target.
  68439. * @param target Defines the new target as a Vector or a mesh
  68440. */
  68441. setTarget(target: Vector3): void;
  68442. /**
  68443. * Return the current target position of the camera. This value is expressed in local space.
  68444. * @returns the target position
  68445. */
  68446. getTarget(): Vector3;
  68447. /** @hidden */
  68448. _decideIfNeedsToMove(): boolean;
  68449. /** @hidden */
  68450. _updatePosition(): void;
  68451. /** @hidden */
  68452. _checkInputs(): void;
  68453. protected _updateCameraRotationMatrix(): void;
  68454. /**
  68455. * 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)
  68456. * @returns the current camera
  68457. */
  68458. private _rotateUpVectorWithCameraRotationMatrix;
  68459. private _cachedRotationZ;
  68460. private _cachedQuaternionRotationZ;
  68461. /** @hidden */
  68462. _getViewMatrix(): Matrix;
  68463. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  68464. /**
  68465. * @hidden
  68466. */
  68467. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  68468. /**
  68469. * @hidden
  68470. */
  68471. _updateRigCameras(): void;
  68472. private _getRigCamPositionAndTarget;
  68473. /**
  68474. * Gets the current object class name.
  68475. * @return the class name
  68476. */
  68477. getClassName(): string;
  68478. }
  68479. }
  68480. declare module BABYLON {
  68481. /**
  68482. * @ignore
  68483. * This is a list of all the different input types that are available in the application.
  68484. * Fo instance: ArcRotateCameraGamepadInput...
  68485. */
  68486. export var CameraInputTypes: {};
  68487. /**
  68488. * This is the contract to implement in order to create a new input class.
  68489. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  68490. */
  68491. export interface ICameraInput<TCamera extends Camera> {
  68492. /**
  68493. * Defines the camera the input is attached to.
  68494. */
  68495. camera: Nullable<TCamera>;
  68496. /**
  68497. * Gets the class name of the current intput.
  68498. * @returns the class name
  68499. */
  68500. getClassName(): string;
  68501. /**
  68502. * Get the friendly name associated with the input class.
  68503. * @returns the input friendly name
  68504. */
  68505. getSimpleName(): string;
  68506. /**
  68507. * Attach the input controls to a specific dom element to get the input from.
  68508. * @param element Defines the element the controls should be listened from
  68509. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68510. */
  68511. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68512. /**
  68513. * Detach the current controls from the specified dom element.
  68514. * @param element Defines the element to stop listening the inputs from
  68515. */
  68516. detachControl(element: Nullable<HTMLElement>): void;
  68517. /**
  68518. * Update the current camera state depending on the inputs that have been used this frame.
  68519. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68520. */
  68521. checkInputs?: () => void;
  68522. }
  68523. /**
  68524. * Represents a map of input types to input instance or input index to input instance.
  68525. */
  68526. export interface CameraInputsMap<TCamera extends Camera> {
  68527. /**
  68528. * Accessor to the input by input type.
  68529. */
  68530. [name: string]: ICameraInput<TCamera>;
  68531. /**
  68532. * Accessor to the input by input index.
  68533. */
  68534. [idx: number]: ICameraInput<TCamera>;
  68535. }
  68536. /**
  68537. * This represents the input manager used within a camera.
  68538. * It helps dealing with all the different kind of input attached to a camera.
  68539. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68540. */
  68541. export class CameraInputsManager<TCamera extends Camera> {
  68542. /**
  68543. * Defines the list of inputs attahed to the camera.
  68544. */
  68545. attached: CameraInputsMap<TCamera>;
  68546. /**
  68547. * Defines the dom element the camera is collecting inputs from.
  68548. * This is null if the controls have not been attached.
  68549. */
  68550. attachedElement: Nullable<HTMLElement>;
  68551. /**
  68552. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68553. */
  68554. noPreventDefault: boolean;
  68555. /**
  68556. * Defined the camera the input manager belongs to.
  68557. */
  68558. camera: TCamera;
  68559. /**
  68560. * Update the current camera state depending on the inputs that have been used this frame.
  68561. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68562. */
  68563. checkInputs: () => void;
  68564. /**
  68565. * Instantiate a new Camera Input Manager.
  68566. * @param camera Defines the camera the input manager blongs to
  68567. */
  68568. constructor(camera: TCamera);
  68569. /**
  68570. * Add an input method to a camera
  68571. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68572. * @param input camera input method
  68573. */
  68574. add(input: ICameraInput<TCamera>): void;
  68575. /**
  68576. * Remove a specific input method from a camera
  68577. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  68578. * @param inputToRemove camera input method
  68579. */
  68580. remove(inputToRemove: ICameraInput<TCamera>): void;
  68581. /**
  68582. * Remove a specific input type from a camera
  68583. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  68584. * @param inputType the type of the input to remove
  68585. */
  68586. removeByType(inputType: string): void;
  68587. private _addCheckInputs;
  68588. /**
  68589. * Attach the input controls to the currently attached dom element to listen the events from.
  68590. * @param input Defines the input to attach
  68591. */
  68592. attachInput(input: ICameraInput<TCamera>): void;
  68593. /**
  68594. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  68595. * @param element Defines the dom element to collect the events from
  68596. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68597. */
  68598. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  68599. /**
  68600. * Detach the current manager inputs controls from a specific dom element.
  68601. * @param element Defines the dom element to collect the events from
  68602. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  68603. */
  68604. detachElement(element: HTMLElement, disconnect?: boolean): void;
  68605. /**
  68606. * Rebuild the dynamic inputCheck function from the current list of
  68607. * defined inputs in the manager.
  68608. */
  68609. rebuildInputCheck(): void;
  68610. /**
  68611. * Remove all attached input methods from a camera
  68612. */
  68613. clear(): void;
  68614. /**
  68615. * Serialize the current input manager attached to a camera.
  68616. * This ensures than once parsed,
  68617. * the input associated to the camera will be identical to the current ones
  68618. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  68619. */
  68620. serialize(serializedCamera: any): void;
  68621. /**
  68622. * Parses an input manager serialized JSON to restore the previous list of inputs
  68623. * and states associated to a camera.
  68624. * @param parsedCamera Defines the JSON to parse
  68625. */
  68626. parse(parsedCamera: any): void;
  68627. }
  68628. }
  68629. declare module BABYLON {
  68630. /**
  68631. * Gather the list of keyboard event types as constants.
  68632. */
  68633. export class KeyboardEventTypes {
  68634. /**
  68635. * The keydown event is fired when a key becomes active (pressed).
  68636. */
  68637. static readonly KEYDOWN: number;
  68638. /**
  68639. * The keyup event is fired when a key has been released.
  68640. */
  68641. static readonly KEYUP: number;
  68642. }
  68643. /**
  68644. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68645. */
  68646. export class KeyboardInfo {
  68647. /**
  68648. * Defines the type of event (KeyboardEventTypes)
  68649. */
  68650. type: number;
  68651. /**
  68652. * Defines the related dom event
  68653. */
  68654. event: KeyboardEvent;
  68655. /**
  68656. * Instantiates a new keyboard info.
  68657. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68658. * @param type Defines the type of event (KeyboardEventTypes)
  68659. * @param event Defines the related dom event
  68660. */
  68661. constructor(
  68662. /**
  68663. * Defines the type of event (KeyboardEventTypes)
  68664. */
  68665. type: number,
  68666. /**
  68667. * Defines the related dom event
  68668. */
  68669. event: KeyboardEvent);
  68670. }
  68671. /**
  68672. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68673. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  68674. */
  68675. export class KeyboardInfoPre extends KeyboardInfo {
  68676. /**
  68677. * Defines the type of event (KeyboardEventTypes)
  68678. */
  68679. type: number;
  68680. /**
  68681. * Defines the related dom event
  68682. */
  68683. event: KeyboardEvent;
  68684. /**
  68685. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  68686. */
  68687. skipOnPointerObservable: boolean;
  68688. /**
  68689. * Instantiates a new keyboard pre info.
  68690. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68691. * @param type Defines the type of event (KeyboardEventTypes)
  68692. * @param event Defines the related dom event
  68693. */
  68694. constructor(
  68695. /**
  68696. * Defines the type of event (KeyboardEventTypes)
  68697. */
  68698. type: number,
  68699. /**
  68700. * Defines the related dom event
  68701. */
  68702. event: KeyboardEvent);
  68703. }
  68704. }
  68705. declare module BABYLON {
  68706. /**
  68707. * Manage the keyboard inputs to control the movement of a free camera.
  68708. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68709. */
  68710. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  68711. /**
  68712. * Defines the camera the input is attached to.
  68713. */
  68714. camera: FreeCamera;
  68715. /**
  68716. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  68717. */
  68718. keysUp: number[];
  68719. /**
  68720. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  68721. */
  68722. keysDown: number[];
  68723. /**
  68724. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  68725. */
  68726. keysLeft: number[];
  68727. /**
  68728. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  68729. */
  68730. keysRight: number[];
  68731. private _keys;
  68732. private _onCanvasBlurObserver;
  68733. private _onKeyboardObserver;
  68734. private _engine;
  68735. private _scene;
  68736. /**
  68737. * Attach the input controls to a specific dom element to get the input from.
  68738. * @param element Defines the element the controls should be listened from
  68739. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68740. */
  68741. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68742. /**
  68743. * Detach the current controls from the specified dom element.
  68744. * @param element Defines the element to stop listening the inputs from
  68745. */
  68746. detachControl(element: Nullable<HTMLElement>): void;
  68747. /**
  68748. * Update the current camera state depending on the inputs that have been used this frame.
  68749. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68750. */
  68751. checkInputs(): void;
  68752. /**
  68753. * Gets the class name of the current intput.
  68754. * @returns the class name
  68755. */
  68756. getClassName(): string;
  68757. /** @hidden */
  68758. _onLostFocus(): void;
  68759. /**
  68760. * Get the friendly name associated with the input class.
  68761. * @returns the input friendly name
  68762. */
  68763. getSimpleName(): string;
  68764. }
  68765. }
  68766. declare module BABYLON {
  68767. /**
  68768. * Interface describing all the common properties and methods a shadow light needs to implement.
  68769. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  68770. * as well as binding the different shadow properties to the effects.
  68771. */
  68772. export interface IShadowLight extends Light {
  68773. /**
  68774. * The light id in the scene (used in scene.findLighById for instance)
  68775. */
  68776. id: string;
  68777. /**
  68778. * The position the shdow will be casted from.
  68779. */
  68780. position: Vector3;
  68781. /**
  68782. * In 2d mode (needCube being false), the direction used to cast the shadow.
  68783. */
  68784. direction: Vector3;
  68785. /**
  68786. * The transformed position. Position of the light in world space taking parenting in account.
  68787. */
  68788. transformedPosition: Vector3;
  68789. /**
  68790. * The transformed direction. Direction of the light in world space taking parenting in account.
  68791. */
  68792. transformedDirection: Vector3;
  68793. /**
  68794. * The friendly name of the light in the scene.
  68795. */
  68796. name: string;
  68797. /**
  68798. * Defines the shadow projection clipping minimum z value.
  68799. */
  68800. shadowMinZ: number;
  68801. /**
  68802. * Defines the shadow projection clipping maximum z value.
  68803. */
  68804. shadowMaxZ: number;
  68805. /**
  68806. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  68807. * @returns true if the information has been computed, false if it does not need to (no parenting)
  68808. */
  68809. computeTransformedInformation(): boolean;
  68810. /**
  68811. * Gets the scene the light belongs to.
  68812. * @returns The scene
  68813. */
  68814. getScene(): Scene;
  68815. /**
  68816. * Callback defining a custom Projection Matrix Builder.
  68817. * This can be used to override the default projection matrix computation.
  68818. */
  68819. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  68820. /**
  68821. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  68822. * @param matrix The materix to updated with the projection information
  68823. * @param viewMatrix The transform matrix of the light
  68824. * @param renderList The list of mesh to render in the map
  68825. * @returns The current light
  68826. */
  68827. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  68828. /**
  68829. * Gets the current depth scale used in ESM.
  68830. * @returns The scale
  68831. */
  68832. getDepthScale(): number;
  68833. /**
  68834. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  68835. * @returns true if a cube texture needs to be use
  68836. */
  68837. needCube(): boolean;
  68838. /**
  68839. * Detects if the projection matrix requires to be recomputed this frame.
  68840. * @returns true if it requires to be recomputed otherwise, false.
  68841. */
  68842. needProjectionMatrixCompute(): boolean;
  68843. /**
  68844. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  68845. */
  68846. forceProjectionMatrixCompute(): void;
  68847. /**
  68848. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  68849. * @param faceIndex The index of the face we are computed the direction to generate shadow
  68850. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  68851. */
  68852. getShadowDirection(faceIndex?: number): Vector3;
  68853. /**
  68854. * Gets the minZ used for shadow according to both the scene and the light.
  68855. * @param activeCamera The camera we are returning the min for
  68856. * @returns the depth min z
  68857. */
  68858. getDepthMinZ(activeCamera: Camera): number;
  68859. /**
  68860. * Gets the maxZ used for shadow according to both the scene and the light.
  68861. * @param activeCamera The camera we are returning the max for
  68862. * @returns the depth max z
  68863. */
  68864. getDepthMaxZ(activeCamera: Camera): number;
  68865. }
  68866. /**
  68867. * Base implementation IShadowLight
  68868. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  68869. */
  68870. export abstract class ShadowLight extends Light implements IShadowLight {
  68871. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  68872. protected _position: Vector3;
  68873. protected _setPosition(value: Vector3): void;
  68874. /**
  68875. * Sets the position the shadow will be casted from. Also use as the light position for both
  68876. * point and spot lights.
  68877. */
  68878. /**
  68879. * Sets the position the shadow will be casted from. Also use as the light position for both
  68880. * point and spot lights.
  68881. */
  68882. position: Vector3;
  68883. protected _direction: Vector3;
  68884. protected _setDirection(value: Vector3): void;
  68885. /**
  68886. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  68887. * Also use as the light direction on spot and directional lights.
  68888. */
  68889. /**
  68890. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  68891. * Also use as the light direction on spot and directional lights.
  68892. */
  68893. direction: Vector3;
  68894. private _shadowMinZ;
  68895. /**
  68896. * Gets the shadow projection clipping minimum z value.
  68897. */
  68898. /**
  68899. * Sets the shadow projection clipping minimum z value.
  68900. */
  68901. shadowMinZ: number;
  68902. private _shadowMaxZ;
  68903. /**
  68904. * Sets the shadow projection clipping maximum z value.
  68905. */
  68906. /**
  68907. * Gets the shadow projection clipping maximum z value.
  68908. */
  68909. shadowMaxZ: number;
  68910. /**
  68911. * Callback defining a custom Projection Matrix Builder.
  68912. * This can be used to override the default projection matrix computation.
  68913. */
  68914. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  68915. /**
  68916. * The transformed position. Position of the light in world space taking parenting in account.
  68917. */
  68918. transformedPosition: Vector3;
  68919. /**
  68920. * The transformed direction. Direction of the light in world space taking parenting in account.
  68921. */
  68922. transformedDirection: Vector3;
  68923. private _needProjectionMatrixCompute;
  68924. /**
  68925. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  68926. * @returns true if the information has been computed, false if it does not need to (no parenting)
  68927. */
  68928. computeTransformedInformation(): boolean;
  68929. /**
  68930. * Return the depth scale used for the shadow map.
  68931. * @returns the depth scale.
  68932. */
  68933. getDepthScale(): number;
  68934. /**
  68935. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  68936. * @param faceIndex The index of the face we are computed the direction to generate shadow
  68937. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  68938. */
  68939. getShadowDirection(faceIndex?: number): Vector3;
  68940. /**
  68941. * Returns the ShadowLight absolute position in the World.
  68942. * @returns the position vector in world space
  68943. */
  68944. getAbsolutePosition(): Vector3;
  68945. /**
  68946. * Sets the ShadowLight direction toward the passed target.
  68947. * @param target The point to target in local space
  68948. * @returns the updated ShadowLight direction
  68949. */
  68950. setDirectionToTarget(target: Vector3): Vector3;
  68951. /**
  68952. * Returns the light rotation in euler definition.
  68953. * @returns the x y z rotation in local space.
  68954. */
  68955. getRotation(): Vector3;
  68956. /**
  68957. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  68958. * @returns true if a cube texture needs to be use
  68959. */
  68960. needCube(): boolean;
  68961. /**
  68962. * Detects if the projection matrix requires to be recomputed this frame.
  68963. * @returns true if it requires to be recomputed otherwise, false.
  68964. */
  68965. needProjectionMatrixCompute(): boolean;
  68966. /**
  68967. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  68968. */
  68969. forceProjectionMatrixCompute(): void;
  68970. /** @hidden */
  68971. _initCache(): void;
  68972. /** @hidden */
  68973. _isSynchronized(): boolean;
  68974. /**
  68975. * Computes the world matrix of the node
  68976. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  68977. * @returns the world matrix
  68978. */
  68979. computeWorldMatrix(force?: boolean): Matrix;
  68980. /**
  68981. * Gets the minZ used for shadow according to both the scene and the light.
  68982. * @param activeCamera The camera we are returning the min for
  68983. * @returns the depth min z
  68984. */
  68985. getDepthMinZ(activeCamera: Camera): number;
  68986. /**
  68987. * Gets the maxZ used for shadow according to both the scene and the light.
  68988. * @param activeCamera The camera we are returning the max for
  68989. * @returns the depth max z
  68990. */
  68991. getDepthMaxZ(activeCamera: Camera): number;
  68992. /**
  68993. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  68994. * @param matrix The materix to updated with the projection information
  68995. * @param viewMatrix The transform matrix of the light
  68996. * @param renderList The list of mesh to render in the map
  68997. * @returns The current light
  68998. */
  68999. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  69000. }
  69001. }
  69002. declare module BABYLON {
  69003. /**
  69004. * "Static Class" containing the most commonly used helper while dealing with material for
  69005. * rendering purpose.
  69006. *
  69007. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  69008. *
  69009. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  69010. */
  69011. export class MaterialHelper {
  69012. /**
  69013. * Bind the current view position to an effect.
  69014. * @param effect The effect to be bound
  69015. * @param scene The scene the eyes position is used from
  69016. */
  69017. static BindEyePosition(effect: Effect, scene: Scene): void;
  69018. /**
  69019. * Helps preparing the defines values about the UVs in used in the effect.
  69020. * UVs are shared as much as we can accross channels in the shaders.
  69021. * @param texture The texture we are preparing the UVs for
  69022. * @param defines The defines to update
  69023. * @param key The channel key "diffuse", "specular"... used in the shader
  69024. */
  69025. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  69026. /**
  69027. * Binds a texture matrix value to its corrsponding uniform
  69028. * @param texture The texture to bind the matrix for
  69029. * @param uniformBuffer The uniform buffer receivin the data
  69030. * @param key The channel key "diffuse", "specular"... used in the shader
  69031. */
  69032. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  69033. /**
  69034. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  69035. * @param mesh defines the current mesh
  69036. * @param scene defines the current scene
  69037. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  69038. * @param pointsCloud defines if point cloud rendering has to be turned on
  69039. * @param fogEnabled defines if fog has to be turned on
  69040. * @param alphaTest defines if alpha testing has to be turned on
  69041. * @param defines defines the current list of defines
  69042. */
  69043. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  69044. /**
  69045. * Helper used to prepare the list of defines associated with frame values for shader compilation
  69046. * @param scene defines the current scene
  69047. * @param engine defines the current engine
  69048. * @param defines specifies the list of active defines
  69049. * @param useInstances defines if instances have to be turned on
  69050. * @param useClipPlane defines if clip plane have to be turned on
  69051. */
  69052. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  69053. /**
  69054. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  69055. * @param mesh The mesh containing the geometry data we will draw
  69056. * @param defines The defines to update
  69057. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  69058. * @param useBones Precise whether bones should be used or not (override mesh info)
  69059. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  69060. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  69061. * @returns false if defines are considered not dirty and have not been checked
  69062. */
  69063. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  69064. /**
  69065. * Prepares the defines related to multiview
  69066. * @param scene The scene we are intending to draw
  69067. * @param defines The defines to update
  69068. */
  69069. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  69070. /**
  69071. * Prepares the defines related to the light information passed in parameter
  69072. * @param scene The scene we are intending to draw
  69073. * @param mesh The mesh the effect is compiling for
  69074. * @param defines The defines to update
  69075. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  69076. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  69077. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  69078. * @returns true if normals will be required for the rest of the effect
  69079. */
  69080. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  69081. /**
  69082. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  69083. * that won t be acctive due to defines being turned off.
  69084. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  69085. * @param samplersList The samplers list
  69086. * @param defines The defines helping in the list generation
  69087. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  69088. */
  69089. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  69090. /**
  69091. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  69092. * @param defines The defines to update while falling back
  69093. * @param fallbacks The authorized effect fallbacks
  69094. * @param maxSimultaneousLights The maximum number of lights allowed
  69095. * @param rank the current rank of the Effect
  69096. * @returns The newly affected rank
  69097. */
  69098. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  69099. /**
  69100. * Prepares the list of attributes required for morph targets according to the effect defines.
  69101. * @param attribs The current list of supported attribs
  69102. * @param mesh The mesh to prepare the morph targets attributes for
  69103. * @param defines The current Defines of the effect
  69104. */
  69105. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  69106. /**
  69107. * Prepares the list of attributes required for bones according to the effect defines.
  69108. * @param attribs The current list of supported attribs
  69109. * @param mesh The mesh to prepare the bones attributes for
  69110. * @param defines The current Defines of the effect
  69111. * @param fallbacks The current efffect fallback strategy
  69112. */
  69113. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  69114. /**
  69115. * Prepares the list of attributes required for instances according to the effect defines.
  69116. * @param attribs The current list of supported attribs
  69117. * @param defines The current Defines of the effect
  69118. */
  69119. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  69120. /**
  69121. * Binds the light shadow information to the effect for the given mesh.
  69122. * @param light The light containing the generator
  69123. * @param scene The scene the lights belongs to
  69124. * @param mesh The mesh we are binding the information to render
  69125. * @param lightIndex The light index in the effect used to render the mesh
  69126. * @param effect The effect we are binding the data to
  69127. */
  69128. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  69129. /**
  69130. * Binds the light information to the effect.
  69131. * @param light The light containing the generator
  69132. * @param effect The effect we are binding the data to
  69133. * @param lightIndex The light index in the effect used to render
  69134. */
  69135. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  69136. /**
  69137. * Binds the lights information from the scene to the effect for the given mesh.
  69138. * @param scene The scene the lights belongs to
  69139. * @param mesh The mesh we are binding the information to render
  69140. * @param effect The effect we are binding the data to
  69141. * @param defines The generated defines for the effect
  69142. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  69143. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  69144. */
  69145. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  69146. private static _tempFogColor;
  69147. /**
  69148. * Binds the fog information from the scene to the effect for the given mesh.
  69149. * @param scene The scene the lights belongs to
  69150. * @param mesh The mesh we are binding the information to render
  69151. * @param effect The effect we are binding the data to
  69152. * @param linearSpace Defines if the fog effect is applied in linear space
  69153. */
  69154. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  69155. /**
  69156. * Binds the bones information from the mesh to the effect.
  69157. * @param mesh The mesh we are binding the information to render
  69158. * @param effect The effect we are binding the data to
  69159. */
  69160. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  69161. /**
  69162. * Binds the morph targets information from the mesh to the effect.
  69163. * @param abstractMesh The mesh we are binding the information to render
  69164. * @param effect The effect we are binding the data to
  69165. */
  69166. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  69167. /**
  69168. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  69169. * @param defines The generated defines used in the effect
  69170. * @param effect The effect we are binding the data to
  69171. * @param scene The scene we are willing to render with logarithmic scale for
  69172. */
  69173. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  69174. /**
  69175. * Binds the clip plane information from the scene to the effect.
  69176. * @param scene The scene the clip plane information are extracted from
  69177. * @param effect The effect we are binding the data to
  69178. */
  69179. static BindClipPlane(effect: Effect, scene: Scene): void;
  69180. }
  69181. }
  69182. declare module BABYLON {
  69183. /** @hidden */
  69184. export var kernelBlurVaryingDeclaration: {
  69185. name: string;
  69186. shader: string;
  69187. };
  69188. }
  69189. declare module BABYLON {
  69190. /** @hidden */
  69191. export var kernelBlurFragment: {
  69192. name: string;
  69193. shader: string;
  69194. };
  69195. }
  69196. declare module BABYLON {
  69197. /** @hidden */
  69198. export var kernelBlurFragment2: {
  69199. name: string;
  69200. shader: string;
  69201. };
  69202. }
  69203. declare module BABYLON {
  69204. /** @hidden */
  69205. export var kernelBlurPixelShader: {
  69206. name: string;
  69207. shader: string;
  69208. };
  69209. }
  69210. declare module BABYLON {
  69211. /** @hidden */
  69212. export var kernelBlurVertex: {
  69213. name: string;
  69214. shader: string;
  69215. };
  69216. }
  69217. declare module BABYLON {
  69218. /** @hidden */
  69219. export var kernelBlurVertexShader: {
  69220. name: string;
  69221. shader: string;
  69222. };
  69223. }
  69224. declare module BABYLON {
  69225. /**
  69226. * The Blur Post Process which blurs an image based on a kernel and direction.
  69227. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  69228. */
  69229. export class BlurPostProcess extends PostProcess {
  69230. /** The direction in which to blur the image. */
  69231. direction: Vector2;
  69232. private blockCompilation;
  69233. protected _kernel: number;
  69234. protected _idealKernel: number;
  69235. protected _packedFloat: boolean;
  69236. private _staticDefines;
  69237. /**
  69238. * Sets the length in pixels of the blur sample region
  69239. */
  69240. /**
  69241. * Gets the length in pixels of the blur sample region
  69242. */
  69243. kernel: number;
  69244. /**
  69245. * Sets wether or not the blur needs to unpack/repack floats
  69246. */
  69247. /**
  69248. * Gets wether or not the blur is unpacking/repacking floats
  69249. */
  69250. packedFloat: boolean;
  69251. /**
  69252. * Creates a new instance BlurPostProcess
  69253. * @param name The name of the effect.
  69254. * @param direction The direction in which to blur the image.
  69255. * @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.
  69256. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  69257. * @param camera The camera to apply the render pass to.
  69258. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69259. * @param engine The engine which the post process will be applied. (default: current engine)
  69260. * @param reusable If the post process can be reused on the same frame. (default: false)
  69261. * @param textureType Type of textures used when performing the post process. (default: 0)
  69262. * @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)
  69263. */
  69264. constructor(name: string,
  69265. /** The direction in which to blur the image. */
  69266. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  69267. /**
  69268. * Updates the effect with the current post process compile time values and recompiles the shader.
  69269. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69270. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69271. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69272. * @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
  69273. * @param onCompiled Called when the shader has been compiled.
  69274. * @param onError Called if there is an error when compiling a shader.
  69275. */
  69276. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69277. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69278. /**
  69279. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  69280. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  69281. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  69282. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  69283. * The gaps between physical kernels are compensated for in the weighting of the samples
  69284. * @param idealKernel Ideal blur kernel.
  69285. * @return Nearest best kernel.
  69286. */
  69287. protected _nearestBestKernel(idealKernel: number): number;
  69288. /**
  69289. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  69290. * @param x The point on the Gaussian distribution to sample.
  69291. * @return the value of the Gaussian function at x.
  69292. */
  69293. protected _gaussianWeight(x: number): number;
  69294. /**
  69295. * Generates a string that can be used as a floating point number in GLSL.
  69296. * @param x Value to print.
  69297. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  69298. * @return GLSL float string.
  69299. */
  69300. protected _glslFloat(x: number, decimalFigures?: number): string;
  69301. }
  69302. }
  69303. declare module BABYLON {
  69304. /** @hidden */
  69305. export var shadowMapPixelShader: {
  69306. name: string;
  69307. shader: string;
  69308. };
  69309. }
  69310. declare module BABYLON {
  69311. /** @hidden */
  69312. export var bonesDeclaration: {
  69313. name: string;
  69314. shader: string;
  69315. };
  69316. }
  69317. declare module BABYLON {
  69318. /** @hidden */
  69319. export var morphTargetsVertexGlobalDeclaration: {
  69320. name: string;
  69321. shader: string;
  69322. };
  69323. }
  69324. declare module BABYLON {
  69325. /** @hidden */
  69326. export var morphTargetsVertexDeclaration: {
  69327. name: string;
  69328. shader: string;
  69329. };
  69330. }
  69331. declare module BABYLON {
  69332. /** @hidden */
  69333. export var instancesDeclaration: {
  69334. name: string;
  69335. shader: string;
  69336. };
  69337. }
  69338. declare module BABYLON {
  69339. /** @hidden */
  69340. export var helperFunctions: {
  69341. name: string;
  69342. shader: string;
  69343. };
  69344. }
  69345. declare module BABYLON {
  69346. /** @hidden */
  69347. export var morphTargetsVertex: {
  69348. name: string;
  69349. shader: string;
  69350. };
  69351. }
  69352. declare module BABYLON {
  69353. /** @hidden */
  69354. export var instancesVertex: {
  69355. name: string;
  69356. shader: string;
  69357. };
  69358. }
  69359. declare module BABYLON {
  69360. /** @hidden */
  69361. export var bonesVertex: {
  69362. name: string;
  69363. shader: string;
  69364. };
  69365. }
  69366. declare module BABYLON {
  69367. /** @hidden */
  69368. export var shadowMapVertexShader: {
  69369. name: string;
  69370. shader: string;
  69371. };
  69372. }
  69373. declare module BABYLON {
  69374. /** @hidden */
  69375. export var depthBoxBlurPixelShader: {
  69376. name: string;
  69377. shader: string;
  69378. };
  69379. }
  69380. declare module BABYLON {
  69381. /**
  69382. * Defines the options associated with the creation of a custom shader for a shadow generator.
  69383. */
  69384. export interface ICustomShaderOptions {
  69385. /**
  69386. * Gets or sets the custom shader name to use
  69387. */
  69388. shaderName: string;
  69389. /**
  69390. * The list of attribute names used in the shader
  69391. */
  69392. attributes?: string[];
  69393. /**
  69394. * The list of unifrom names used in the shader
  69395. */
  69396. uniforms?: string[];
  69397. /**
  69398. * The list of sampler names used in the shader
  69399. */
  69400. samplers?: string[];
  69401. /**
  69402. * The list of defines used in the shader
  69403. */
  69404. defines?: string[];
  69405. }
  69406. /**
  69407. * Interface to implement to create a shadow generator compatible with BJS.
  69408. */
  69409. export interface IShadowGenerator {
  69410. /**
  69411. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69412. * @returns The render target texture if present otherwise, null
  69413. */
  69414. getShadowMap(): Nullable<RenderTargetTexture>;
  69415. /**
  69416. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69417. * @returns The render target texture if the shadow map is present otherwise, null
  69418. */
  69419. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69420. /**
  69421. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  69422. * @param subMesh The submesh we want to render in the shadow map
  69423. * @param useInstances Defines wether will draw in the map using instances
  69424. * @returns true if ready otherwise, false
  69425. */
  69426. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69427. /**
  69428. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  69429. * @param defines Defines of the material we want to update
  69430. * @param lightIndex Index of the light in the enabled light list of the material
  69431. */
  69432. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  69433. /**
  69434. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  69435. * defined in the generator but impacting the effect).
  69436. * It implies the unifroms available on the materials are the standard BJS ones.
  69437. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  69438. * @param effect The effect we are binfing the information for
  69439. */
  69440. bindShadowLight(lightIndex: string, effect: Effect): void;
  69441. /**
  69442. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  69443. * (eq to shadow prjection matrix * light transform matrix)
  69444. * @returns The transform matrix used to create the shadow map
  69445. */
  69446. getTransformMatrix(): Matrix;
  69447. /**
  69448. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  69449. * Cube and 2D textures for instance.
  69450. */
  69451. recreateShadowMap(): void;
  69452. /**
  69453. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69454. * @param onCompiled Callback triggered at the and of the effects compilation
  69455. * @param options Sets of optional options forcing the compilation with different modes
  69456. */
  69457. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69458. useInstances: boolean;
  69459. }>): void;
  69460. /**
  69461. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69462. * @param options Sets of optional options forcing the compilation with different modes
  69463. * @returns A promise that resolves when the compilation completes
  69464. */
  69465. forceCompilationAsync(options?: Partial<{
  69466. useInstances: boolean;
  69467. }>): Promise<void>;
  69468. /**
  69469. * Serializes the shadow generator setup to a json object.
  69470. * @returns The serialized JSON object
  69471. */
  69472. serialize(): any;
  69473. /**
  69474. * Disposes the Shadow map and related Textures and effects.
  69475. */
  69476. dispose(): void;
  69477. }
  69478. /**
  69479. * Default implementation IShadowGenerator.
  69480. * This is the main object responsible of generating shadows in the framework.
  69481. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  69482. */
  69483. export class ShadowGenerator implements IShadowGenerator {
  69484. /**
  69485. * Shadow generator mode None: no filtering applied.
  69486. */
  69487. static readonly FILTER_NONE: number;
  69488. /**
  69489. * Shadow generator mode ESM: Exponential Shadow Mapping.
  69490. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69491. */
  69492. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  69493. /**
  69494. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  69495. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  69496. */
  69497. static readonly FILTER_POISSONSAMPLING: number;
  69498. /**
  69499. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  69500. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69501. */
  69502. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  69503. /**
  69504. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  69505. * edge artifacts on steep falloff.
  69506. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69507. */
  69508. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  69509. /**
  69510. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  69511. * edge artifacts on steep falloff.
  69512. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69513. */
  69514. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  69515. /**
  69516. * Shadow generator mode PCF: Percentage Closer Filtering
  69517. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69518. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  69519. */
  69520. static readonly FILTER_PCF: number;
  69521. /**
  69522. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  69523. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69524. * Contact Hardening
  69525. */
  69526. static readonly FILTER_PCSS: number;
  69527. /**
  69528. * Reserved for PCF and PCSS
  69529. * Highest Quality.
  69530. *
  69531. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  69532. *
  69533. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  69534. */
  69535. static readonly QUALITY_HIGH: number;
  69536. /**
  69537. * Reserved for PCF and PCSS
  69538. * Good tradeoff for quality/perf cross devices
  69539. *
  69540. * Execute PCF on a 3*3 kernel.
  69541. *
  69542. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  69543. */
  69544. static readonly QUALITY_MEDIUM: number;
  69545. /**
  69546. * Reserved for PCF and PCSS
  69547. * The lowest quality but the fastest.
  69548. *
  69549. * Execute PCF on a 1*1 kernel.
  69550. *
  69551. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  69552. */
  69553. static readonly QUALITY_LOW: number;
  69554. /** Gets or sets the custom shader name to use */
  69555. customShaderOptions: ICustomShaderOptions;
  69556. /**
  69557. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  69558. */
  69559. onBeforeShadowMapRenderObservable: Observable<Effect>;
  69560. /**
  69561. * Observable triggered before a mesh is rendered in the shadow map.
  69562. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  69563. */
  69564. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  69565. private _bias;
  69566. /**
  69567. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  69568. */
  69569. /**
  69570. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  69571. */
  69572. bias: number;
  69573. private _normalBias;
  69574. /**
  69575. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69576. */
  69577. /**
  69578. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69579. */
  69580. normalBias: number;
  69581. private _blurBoxOffset;
  69582. /**
  69583. * Gets the blur box offset: offset applied during the blur pass.
  69584. * Only useful if useKernelBlur = false
  69585. */
  69586. /**
  69587. * Sets the blur box offset: offset applied during the blur pass.
  69588. * Only useful if useKernelBlur = false
  69589. */
  69590. blurBoxOffset: number;
  69591. private _blurScale;
  69592. /**
  69593. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  69594. * 2 means half of the size.
  69595. */
  69596. /**
  69597. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  69598. * 2 means half of the size.
  69599. */
  69600. blurScale: number;
  69601. private _blurKernel;
  69602. /**
  69603. * Gets the blur kernel: kernel size of the blur pass.
  69604. * Only useful if useKernelBlur = true
  69605. */
  69606. /**
  69607. * Sets the blur kernel: kernel size of the blur pass.
  69608. * Only useful if useKernelBlur = true
  69609. */
  69610. blurKernel: number;
  69611. private _useKernelBlur;
  69612. /**
  69613. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  69614. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69615. */
  69616. /**
  69617. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  69618. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69619. */
  69620. useKernelBlur: boolean;
  69621. private _depthScale;
  69622. /**
  69623. * Gets the depth scale used in ESM mode.
  69624. */
  69625. /**
  69626. * Sets the depth scale used in ESM mode.
  69627. * This can override the scale stored on the light.
  69628. */
  69629. depthScale: number;
  69630. private _filter;
  69631. /**
  69632. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  69633. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69634. */
  69635. /**
  69636. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  69637. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69638. */
  69639. filter: number;
  69640. /**
  69641. * Gets if the current filter is set to Poisson Sampling.
  69642. */
  69643. /**
  69644. * Sets the current filter to Poisson Sampling.
  69645. */
  69646. usePoissonSampling: boolean;
  69647. /**
  69648. * Gets if the current filter is set to ESM.
  69649. */
  69650. /**
  69651. * Sets the current filter is to ESM.
  69652. */
  69653. useExponentialShadowMap: boolean;
  69654. /**
  69655. * Gets if the current filter is set to filtered ESM.
  69656. */
  69657. /**
  69658. * Gets if the current filter is set to filtered ESM.
  69659. */
  69660. useBlurExponentialShadowMap: boolean;
  69661. /**
  69662. * Gets if the current filter is set to "close ESM" (using the inverse of the
  69663. * exponential to prevent steep falloff artifacts).
  69664. */
  69665. /**
  69666. * Sets the current filter to "close ESM" (using the inverse of the
  69667. * exponential to prevent steep falloff artifacts).
  69668. */
  69669. useCloseExponentialShadowMap: boolean;
  69670. /**
  69671. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  69672. * exponential to prevent steep falloff artifacts).
  69673. */
  69674. /**
  69675. * Sets the current filter to filtered "close ESM" (using the inverse of the
  69676. * exponential to prevent steep falloff artifacts).
  69677. */
  69678. useBlurCloseExponentialShadowMap: boolean;
  69679. /**
  69680. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  69681. */
  69682. /**
  69683. * Sets the current filter to "PCF" (percentage closer filtering).
  69684. */
  69685. usePercentageCloserFiltering: boolean;
  69686. private _filteringQuality;
  69687. /**
  69688. * Gets the PCF or PCSS Quality.
  69689. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69690. */
  69691. /**
  69692. * Sets the PCF or PCSS Quality.
  69693. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69694. */
  69695. filteringQuality: number;
  69696. /**
  69697. * Gets if the current filter is set to "PCSS" (contact hardening).
  69698. */
  69699. /**
  69700. * Sets the current filter to "PCSS" (contact hardening).
  69701. */
  69702. useContactHardeningShadow: boolean;
  69703. private _contactHardeningLightSizeUVRatio;
  69704. /**
  69705. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69706. * Using a ratio helps keeping shape stability independently of the map size.
  69707. *
  69708. * It does not account for the light projection as it was having too much
  69709. * instability during the light setup or during light position changes.
  69710. *
  69711. * Only valid if useContactHardeningShadow is true.
  69712. */
  69713. /**
  69714. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69715. * Using a ratio helps keeping shape stability independently of the map size.
  69716. *
  69717. * It does not account for the light projection as it was having too much
  69718. * instability during the light setup or during light position changes.
  69719. *
  69720. * Only valid if useContactHardeningShadow is true.
  69721. */
  69722. contactHardeningLightSizeUVRatio: number;
  69723. private _darkness;
  69724. /**
  69725. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  69726. * 0 means strongest and 1 would means no shadow.
  69727. * @returns the darkness.
  69728. */
  69729. getDarkness(): number;
  69730. /**
  69731. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  69732. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  69733. * @returns the shadow generator allowing fluent coding.
  69734. */
  69735. setDarkness(darkness: number): ShadowGenerator;
  69736. private _transparencyShadow;
  69737. /**
  69738. * Sets the ability to have transparent shadow (boolean).
  69739. * @param transparent True if transparent else False
  69740. * @returns the shadow generator allowing fluent coding
  69741. */
  69742. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  69743. private _shadowMap;
  69744. private _shadowMap2;
  69745. /**
  69746. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69747. * @returns The render target texture if present otherwise, null
  69748. */
  69749. getShadowMap(): Nullable<RenderTargetTexture>;
  69750. /**
  69751. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69752. * @returns The render target texture if the shadow map is present otherwise, null
  69753. */
  69754. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69755. /**
  69756. * Helper function to add a mesh and its descendants to the list of shadow casters.
  69757. * @param mesh Mesh to add
  69758. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  69759. * @returns the Shadow Generator itself
  69760. */
  69761. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69762. /**
  69763. * Helper function to remove a mesh and its descendants from the list of shadow casters
  69764. * @param mesh Mesh to remove
  69765. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  69766. * @returns the Shadow Generator itself
  69767. */
  69768. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69769. /**
  69770. * Controls the extent to which the shadows fade out at the edge of the frustum
  69771. * Used only by directionals and spots
  69772. */
  69773. frustumEdgeFalloff: number;
  69774. private _light;
  69775. /**
  69776. * Returns the associated light object.
  69777. * @returns the light generating the shadow
  69778. */
  69779. getLight(): IShadowLight;
  69780. /**
  69781. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  69782. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  69783. * It might on the other hand introduce peter panning.
  69784. */
  69785. forceBackFacesOnly: boolean;
  69786. private _scene;
  69787. private _lightDirection;
  69788. private _effect;
  69789. private _viewMatrix;
  69790. private _projectionMatrix;
  69791. private _transformMatrix;
  69792. private _cachedPosition;
  69793. private _cachedDirection;
  69794. private _cachedDefines;
  69795. private _currentRenderID;
  69796. private _boxBlurPostprocess;
  69797. private _kernelBlurXPostprocess;
  69798. private _kernelBlurYPostprocess;
  69799. private _blurPostProcesses;
  69800. private _mapSize;
  69801. private _currentFaceIndex;
  69802. private _currentFaceIndexCache;
  69803. private _textureType;
  69804. private _defaultTextureMatrix;
  69805. /** @hidden */
  69806. static _SceneComponentInitialization: (scene: Scene) => void;
  69807. /**
  69808. * Creates a ShadowGenerator object.
  69809. * A ShadowGenerator is the required tool to use the shadows.
  69810. * Each light casting shadows needs to use its own ShadowGenerator.
  69811. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  69812. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  69813. * @param light The light object generating the shadows.
  69814. * @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.
  69815. */
  69816. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  69817. private _initializeGenerator;
  69818. private _initializeShadowMap;
  69819. private _initializeBlurRTTAndPostProcesses;
  69820. private _renderForShadowMap;
  69821. private _renderSubMeshForShadowMap;
  69822. private _applyFilterValues;
  69823. /**
  69824. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69825. * @param onCompiled Callback triggered at the and of the effects compilation
  69826. * @param options Sets of optional options forcing the compilation with different modes
  69827. */
  69828. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69829. useInstances: boolean;
  69830. }>): void;
  69831. /**
  69832. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69833. * @param options Sets of optional options forcing the compilation with different modes
  69834. * @returns A promise that resolves when the compilation completes
  69835. */
  69836. forceCompilationAsync(options?: Partial<{
  69837. useInstances: boolean;
  69838. }>): Promise<void>;
  69839. /**
  69840. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  69841. * @param subMesh The submesh we want to render in the shadow map
  69842. * @param useInstances Defines wether will draw in the map using instances
  69843. * @returns true if ready otherwise, false
  69844. */
  69845. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69846. /**
  69847. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  69848. * @param defines Defines of the material we want to update
  69849. * @param lightIndex Index of the light in the enabled light list of the material
  69850. */
  69851. prepareDefines(defines: any, lightIndex: number): void;
  69852. /**
  69853. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  69854. * defined in the generator but impacting the effect).
  69855. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  69856. * @param effect The effect we are binfing the information for
  69857. */
  69858. bindShadowLight(lightIndex: string, effect: Effect): void;
  69859. /**
  69860. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  69861. * (eq to shadow prjection matrix * light transform matrix)
  69862. * @returns The transform matrix used to create the shadow map
  69863. */
  69864. getTransformMatrix(): Matrix;
  69865. /**
  69866. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  69867. * Cube and 2D textures for instance.
  69868. */
  69869. recreateShadowMap(): void;
  69870. private _disposeBlurPostProcesses;
  69871. private _disposeRTTandPostProcesses;
  69872. /**
  69873. * Disposes the ShadowGenerator.
  69874. * Returns nothing.
  69875. */
  69876. dispose(): void;
  69877. /**
  69878. * Serializes the shadow generator setup to a json object.
  69879. * @returns The serialized JSON object
  69880. */
  69881. serialize(): any;
  69882. /**
  69883. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  69884. * @param parsedShadowGenerator The JSON object to parse
  69885. * @param scene The scene to create the shadow map for
  69886. * @returns The parsed shadow generator
  69887. */
  69888. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  69889. }
  69890. }
  69891. declare module BABYLON {
  69892. /**
  69893. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  69894. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  69895. * 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.
  69896. */
  69897. export abstract class Light extends Node {
  69898. /**
  69899. * Falloff Default: light is falling off following the material specification:
  69900. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  69901. */
  69902. static readonly FALLOFF_DEFAULT: number;
  69903. /**
  69904. * Falloff Physical: light is falling off following the inverse squared distance law.
  69905. */
  69906. static readonly FALLOFF_PHYSICAL: number;
  69907. /**
  69908. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  69909. * to enhance interoperability with other engines.
  69910. */
  69911. static readonly FALLOFF_GLTF: number;
  69912. /**
  69913. * Falloff Standard: light is falling off like in the standard material
  69914. * to enhance interoperability with other materials.
  69915. */
  69916. static readonly FALLOFF_STANDARD: number;
  69917. /**
  69918. * If every light affecting the material is in this lightmapMode,
  69919. * material.lightmapTexture adds or multiplies
  69920. * (depends on material.useLightmapAsShadowmap)
  69921. * after every other light calculations.
  69922. */
  69923. static readonly LIGHTMAP_DEFAULT: number;
  69924. /**
  69925. * material.lightmapTexture as only diffuse lighting from this light
  69926. * adds only specular lighting from this light
  69927. * adds dynamic shadows
  69928. */
  69929. static readonly LIGHTMAP_SPECULAR: number;
  69930. /**
  69931. * material.lightmapTexture as only lighting
  69932. * no light calculation from this light
  69933. * only adds dynamic shadows from this light
  69934. */
  69935. static readonly LIGHTMAP_SHADOWSONLY: number;
  69936. /**
  69937. * Each light type uses the default quantity according to its type:
  69938. * point/spot lights use luminous intensity
  69939. * directional lights use illuminance
  69940. */
  69941. static readonly INTENSITYMODE_AUTOMATIC: number;
  69942. /**
  69943. * lumen (lm)
  69944. */
  69945. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  69946. /**
  69947. * candela (lm/sr)
  69948. */
  69949. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  69950. /**
  69951. * lux (lm/m^2)
  69952. */
  69953. static readonly INTENSITYMODE_ILLUMINANCE: number;
  69954. /**
  69955. * nit (cd/m^2)
  69956. */
  69957. static readonly INTENSITYMODE_LUMINANCE: number;
  69958. /**
  69959. * Light type const id of the point light.
  69960. */
  69961. static readonly LIGHTTYPEID_POINTLIGHT: number;
  69962. /**
  69963. * Light type const id of the directional light.
  69964. */
  69965. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  69966. /**
  69967. * Light type const id of the spot light.
  69968. */
  69969. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  69970. /**
  69971. * Light type const id of the hemispheric light.
  69972. */
  69973. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  69974. /**
  69975. * Diffuse gives the basic color to an object.
  69976. */
  69977. diffuse: Color3;
  69978. /**
  69979. * Specular produces a highlight color on an object.
  69980. * Note: This is note affecting PBR materials.
  69981. */
  69982. specular: Color3;
  69983. /**
  69984. * Defines the falloff type for this light. This lets overrriding how punctual light are
  69985. * falling off base on range or angle.
  69986. * This can be set to any values in Light.FALLOFF_x.
  69987. *
  69988. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  69989. * other types of materials.
  69990. */
  69991. falloffType: number;
  69992. /**
  69993. * Strength of the light.
  69994. * Note: By default it is define in the framework own unit.
  69995. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  69996. */
  69997. intensity: number;
  69998. private _range;
  69999. protected _inverseSquaredRange: number;
  70000. /**
  70001. * Defines how far from the source the light is impacting in scene units.
  70002. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  70003. */
  70004. /**
  70005. * Defines how far from the source the light is impacting in scene units.
  70006. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  70007. */
  70008. range: number;
  70009. /**
  70010. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  70011. * of light.
  70012. */
  70013. private _photometricScale;
  70014. private _intensityMode;
  70015. /**
  70016. * Gets the photometric scale used to interpret the intensity.
  70017. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  70018. */
  70019. /**
  70020. * Sets the photometric scale used to interpret the intensity.
  70021. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  70022. */
  70023. intensityMode: number;
  70024. private _radius;
  70025. /**
  70026. * Gets the light radius used by PBR Materials to simulate soft area lights.
  70027. */
  70028. /**
  70029. * sets the light radius used by PBR Materials to simulate soft area lights.
  70030. */
  70031. radius: number;
  70032. private _renderPriority;
  70033. /**
  70034. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  70035. * exceeding the number allowed of the materials.
  70036. */
  70037. renderPriority: number;
  70038. private _shadowEnabled;
  70039. /**
  70040. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  70041. * the current shadow generator.
  70042. */
  70043. /**
  70044. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  70045. * the current shadow generator.
  70046. */
  70047. shadowEnabled: boolean;
  70048. private _includedOnlyMeshes;
  70049. /**
  70050. * Gets the only meshes impacted by this light.
  70051. */
  70052. /**
  70053. * Sets the only meshes impacted by this light.
  70054. */
  70055. includedOnlyMeshes: AbstractMesh[];
  70056. private _excludedMeshes;
  70057. /**
  70058. * Gets the meshes not impacted by this light.
  70059. */
  70060. /**
  70061. * Sets the meshes not impacted by this light.
  70062. */
  70063. excludedMeshes: AbstractMesh[];
  70064. private _excludeWithLayerMask;
  70065. /**
  70066. * Gets the layer id use to find what meshes are not impacted by the light.
  70067. * Inactive if 0
  70068. */
  70069. /**
  70070. * Sets the layer id use to find what meshes are not impacted by the light.
  70071. * Inactive if 0
  70072. */
  70073. excludeWithLayerMask: number;
  70074. private _includeOnlyWithLayerMask;
  70075. /**
  70076. * Gets the layer id use to find what meshes are impacted by the light.
  70077. * Inactive if 0
  70078. */
  70079. /**
  70080. * Sets the layer id use to find what meshes are impacted by the light.
  70081. * Inactive if 0
  70082. */
  70083. includeOnlyWithLayerMask: number;
  70084. private _lightmapMode;
  70085. /**
  70086. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  70087. */
  70088. /**
  70089. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  70090. */
  70091. lightmapMode: number;
  70092. /**
  70093. * Shadow generator associted to the light.
  70094. * @hidden Internal use only.
  70095. */
  70096. _shadowGenerator: Nullable<IShadowGenerator>;
  70097. /**
  70098. * @hidden Internal use only.
  70099. */
  70100. _excludedMeshesIds: string[];
  70101. /**
  70102. * @hidden Internal use only.
  70103. */
  70104. _includedOnlyMeshesIds: string[];
  70105. /**
  70106. * The current light unifom buffer.
  70107. * @hidden Internal use only.
  70108. */
  70109. _uniformBuffer: UniformBuffer;
  70110. /**
  70111. * Creates a Light object in the scene.
  70112. * Documentation : https://doc.babylonjs.com/babylon101/lights
  70113. * @param name The firendly name of the light
  70114. * @param scene The scene the light belongs too
  70115. */
  70116. constructor(name: string, scene: Scene);
  70117. protected abstract _buildUniformLayout(): void;
  70118. /**
  70119. * Sets the passed Effect "effect" with the Light information.
  70120. * @param effect The effect to update
  70121. * @param lightIndex The index of the light in the effect to update
  70122. * @returns The light
  70123. */
  70124. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  70125. /**
  70126. * Returns the string "Light".
  70127. * @returns the class name
  70128. */
  70129. getClassName(): string;
  70130. /** @hidden */
  70131. readonly _isLight: boolean;
  70132. /**
  70133. * Converts the light information to a readable string for debug purpose.
  70134. * @param fullDetails Supports for multiple levels of logging within scene loading
  70135. * @returns the human readable light info
  70136. */
  70137. toString(fullDetails?: boolean): string;
  70138. /** @hidden */
  70139. protected _syncParentEnabledState(): void;
  70140. /**
  70141. * Set the enabled state of this node.
  70142. * @param value - the new enabled state
  70143. */
  70144. setEnabled(value: boolean): void;
  70145. /**
  70146. * Returns the Light associated shadow generator if any.
  70147. * @return the associated shadow generator.
  70148. */
  70149. getShadowGenerator(): Nullable<IShadowGenerator>;
  70150. /**
  70151. * Returns a Vector3, the absolute light position in the World.
  70152. * @returns the world space position of the light
  70153. */
  70154. getAbsolutePosition(): Vector3;
  70155. /**
  70156. * Specifies if the light will affect the passed mesh.
  70157. * @param mesh The mesh to test against the light
  70158. * @return true the mesh is affected otherwise, false.
  70159. */
  70160. canAffectMesh(mesh: AbstractMesh): boolean;
  70161. /**
  70162. * Sort function to order lights for rendering.
  70163. * @param a First Light object to compare to second.
  70164. * @param b Second Light object to compare first.
  70165. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  70166. */
  70167. static CompareLightsPriority(a: Light, b: Light): number;
  70168. /**
  70169. * Releases resources associated with this node.
  70170. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  70171. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  70172. */
  70173. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  70174. /**
  70175. * Returns the light type ID (integer).
  70176. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  70177. */
  70178. getTypeID(): number;
  70179. /**
  70180. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  70181. * @returns the scaled intensity in intensity mode unit
  70182. */
  70183. getScaledIntensity(): number;
  70184. /**
  70185. * Returns a new Light object, named "name", from the current one.
  70186. * @param name The name of the cloned light
  70187. * @returns the new created light
  70188. */
  70189. clone(name: string): Nullable<Light>;
  70190. /**
  70191. * Serializes the current light into a Serialization object.
  70192. * @returns the serialized object.
  70193. */
  70194. serialize(): any;
  70195. /**
  70196. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  70197. * This new light is named "name" and added to the passed scene.
  70198. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  70199. * @param name The friendly name of the light
  70200. * @param scene The scene the new light will belong to
  70201. * @returns the constructor function
  70202. */
  70203. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  70204. /**
  70205. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  70206. * @param parsedLight The JSON representation of the light
  70207. * @param scene The scene to create the parsed light in
  70208. * @returns the created light after parsing
  70209. */
  70210. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  70211. private _hookArrayForExcluded;
  70212. private _hookArrayForIncludedOnly;
  70213. private _resyncMeshes;
  70214. /**
  70215. * Forces the meshes to update their light related information in their rendering used effects
  70216. * @hidden Internal Use Only
  70217. */
  70218. _markMeshesAsLightDirty(): void;
  70219. /**
  70220. * Recomputes the cached photometric scale if needed.
  70221. */
  70222. private _computePhotometricScale;
  70223. /**
  70224. * Returns the Photometric Scale according to the light type and intensity mode.
  70225. */
  70226. private _getPhotometricScale;
  70227. /**
  70228. * Reorder the light in the scene according to their defined priority.
  70229. * @hidden Internal Use Only
  70230. */
  70231. _reorderLightsInScene(): void;
  70232. /**
  70233. * Prepares the list of defines specific to the light type.
  70234. * @param defines the list of defines
  70235. * @param lightIndex defines the index of the light for the effect
  70236. */
  70237. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  70238. }
  70239. }
  70240. declare module BABYLON {
  70241. /**
  70242. * Interface used to define Action
  70243. */
  70244. export interface IAction {
  70245. /**
  70246. * Trigger for the action
  70247. */
  70248. trigger: number;
  70249. /** Options of the trigger */
  70250. triggerOptions: any;
  70251. /**
  70252. * Gets the trigger parameters
  70253. * @returns the trigger parameters
  70254. */
  70255. getTriggerParameter(): any;
  70256. /**
  70257. * Internal only - executes current action event
  70258. * @hidden
  70259. */
  70260. _executeCurrent(evt?: ActionEvent): void;
  70261. /**
  70262. * Serialize placeholder for child classes
  70263. * @param parent of child
  70264. * @returns the serialized object
  70265. */
  70266. serialize(parent: any): any;
  70267. /**
  70268. * Internal only
  70269. * @hidden
  70270. */
  70271. _prepare(): void;
  70272. /**
  70273. * Internal only - manager for action
  70274. * @hidden
  70275. */
  70276. _actionManager: AbstractActionManager;
  70277. }
  70278. /**
  70279. * The action to be carried out following a trigger
  70280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  70281. */
  70282. export class Action implements IAction {
  70283. /** the trigger, with or without parameters, for the action */
  70284. triggerOptions: any;
  70285. /**
  70286. * Trigger for the action
  70287. */
  70288. trigger: number;
  70289. /**
  70290. * Internal only - manager for action
  70291. * @hidden
  70292. */
  70293. _actionManager: ActionManager;
  70294. private _nextActiveAction;
  70295. private _child;
  70296. private _condition?;
  70297. private _triggerParameter;
  70298. /**
  70299. * An event triggered prior to action being executed.
  70300. */
  70301. onBeforeExecuteObservable: Observable<Action>;
  70302. /**
  70303. * Creates a new Action
  70304. * @param triggerOptions the trigger, with or without parameters, for the action
  70305. * @param condition an optional determinant of action
  70306. */
  70307. constructor(
  70308. /** the trigger, with or without parameters, for the action */
  70309. triggerOptions: any, condition?: Condition);
  70310. /**
  70311. * Internal only
  70312. * @hidden
  70313. */
  70314. _prepare(): void;
  70315. /**
  70316. * Gets the trigger parameters
  70317. * @returns the trigger parameters
  70318. */
  70319. getTriggerParameter(): any;
  70320. /**
  70321. * Internal only - executes current action event
  70322. * @hidden
  70323. */
  70324. _executeCurrent(evt?: ActionEvent): void;
  70325. /**
  70326. * Execute placeholder for child classes
  70327. * @param evt optional action event
  70328. */
  70329. execute(evt?: ActionEvent): void;
  70330. /**
  70331. * Skips to next active action
  70332. */
  70333. skipToNextActiveAction(): void;
  70334. /**
  70335. * Adds action to chain of actions, may be a DoNothingAction
  70336. * @param action defines the next action to execute
  70337. * @returns The action passed in
  70338. * @see https://www.babylonjs-playground.com/#1T30HR#0
  70339. */
  70340. then(action: Action): Action;
  70341. /**
  70342. * Internal only
  70343. * @hidden
  70344. */
  70345. _getProperty(propertyPath: string): string;
  70346. /**
  70347. * Internal only
  70348. * @hidden
  70349. */
  70350. _getEffectiveTarget(target: any, propertyPath: string): any;
  70351. /**
  70352. * Serialize placeholder for child classes
  70353. * @param parent of child
  70354. * @returns the serialized object
  70355. */
  70356. serialize(parent: any): any;
  70357. /**
  70358. * Internal only called by serialize
  70359. * @hidden
  70360. */
  70361. protected _serialize(serializedAction: any, parent?: any): any;
  70362. /**
  70363. * Internal only
  70364. * @hidden
  70365. */
  70366. static _SerializeValueAsString: (value: any) => string;
  70367. /**
  70368. * Internal only
  70369. * @hidden
  70370. */
  70371. static _GetTargetProperty: (target: Scene | Node) => {
  70372. name: string;
  70373. targetType: string;
  70374. value: string;
  70375. };
  70376. }
  70377. }
  70378. declare module BABYLON {
  70379. /**
  70380. * A Condition applied to an Action
  70381. */
  70382. export class Condition {
  70383. /**
  70384. * Internal only - manager for action
  70385. * @hidden
  70386. */
  70387. _actionManager: ActionManager;
  70388. /**
  70389. * Internal only
  70390. * @hidden
  70391. */
  70392. _evaluationId: number;
  70393. /**
  70394. * Internal only
  70395. * @hidden
  70396. */
  70397. _currentResult: boolean;
  70398. /**
  70399. * Creates a new Condition
  70400. * @param actionManager the manager of the action the condition is applied to
  70401. */
  70402. constructor(actionManager: ActionManager);
  70403. /**
  70404. * Check if the current condition is valid
  70405. * @returns a boolean
  70406. */
  70407. isValid(): boolean;
  70408. /**
  70409. * Internal only
  70410. * @hidden
  70411. */
  70412. _getProperty(propertyPath: string): string;
  70413. /**
  70414. * Internal only
  70415. * @hidden
  70416. */
  70417. _getEffectiveTarget(target: any, propertyPath: string): any;
  70418. /**
  70419. * Serialize placeholder for child classes
  70420. * @returns the serialized object
  70421. */
  70422. serialize(): any;
  70423. /**
  70424. * Internal only
  70425. * @hidden
  70426. */
  70427. protected _serialize(serializedCondition: any): any;
  70428. }
  70429. /**
  70430. * Defines specific conditional operators as extensions of Condition
  70431. */
  70432. export class ValueCondition extends Condition {
  70433. /** path to specify the property of the target the conditional operator uses */
  70434. propertyPath: string;
  70435. /** the value compared by the conditional operator against the current value of the property */
  70436. value: any;
  70437. /** the conditional operator, default ValueCondition.IsEqual */
  70438. operator: number;
  70439. /**
  70440. * Internal only
  70441. * @hidden
  70442. */
  70443. private static _IsEqual;
  70444. /**
  70445. * Internal only
  70446. * @hidden
  70447. */
  70448. private static _IsDifferent;
  70449. /**
  70450. * Internal only
  70451. * @hidden
  70452. */
  70453. private static _IsGreater;
  70454. /**
  70455. * Internal only
  70456. * @hidden
  70457. */
  70458. private static _IsLesser;
  70459. /**
  70460. * returns the number for IsEqual
  70461. */
  70462. static readonly IsEqual: number;
  70463. /**
  70464. * Returns the number for IsDifferent
  70465. */
  70466. static readonly IsDifferent: number;
  70467. /**
  70468. * Returns the number for IsGreater
  70469. */
  70470. static readonly IsGreater: number;
  70471. /**
  70472. * Returns the number for IsLesser
  70473. */
  70474. static readonly IsLesser: number;
  70475. /**
  70476. * Internal only The action manager for the condition
  70477. * @hidden
  70478. */
  70479. _actionManager: ActionManager;
  70480. /**
  70481. * Internal only
  70482. * @hidden
  70483. */
  70484. private _target;
  70485. /**
  70486. * Internal only
  70487. * @hidden
  70488. */
  70489. private _effectiveTarget;
  70490. /**
  70491. * Internal only
  70492. * @hidden
  70493. */
  70494. private _property;
  70495. /**
  70496. * Creates a new ValueCondition
  70497. * @param actionManager manager for the action the condition applies to
  70498. * @param target for the action
  70499. * @param propertyPath path to specify the property of the target the conditional operator uses
  70500. * @param value the value compared by the conditional operator against the current value of the property
  70501. * @param operator the conditional operator, default ValueCondition.IsEqual
  70502. */
  70503. constructor(actionManager: ActionManager, target: any,
  70504. /** path to specify the property of the target the conditional operator uses */
  70505. propertyPath: string,
  70506. /** the value compared by the conditional operator against the current value of the property */
  70507. value: any,
  70508. /** the conditional operator, default ValueCondition.IsEqual */
  70509. operator?: number);
  70510. /**
  70511. * Compares the given value with the property value for the specified conditional operator
  70512. * @returns the result of the comparison
  70513. */
  70514. isValid(): boolean;
  70515. /**
  70516. * Serialize the ValueCondition into a JSON compatible object
  70517. * @returns serialization object
  70518. */
  70519. serialize(): any;
  70520. /**
  70521. * Gets the name of the conditional operator for the ValueCondition
  70522. * @param operator the conditional operator
  70523. * @returns the name
  70524. */
  70525. static GetOperatorName(operator: number): string;
  70526. }
  70527. /**
  70528. * Defines a predicate condition as an extension of Condition
  70529. */
  70530. export class PredicateCondition extends Condition {
  70531. /** defines the predicate function used to validate the condition */
  70532. predicate: () => boolean;
  70533. /**
  70534. * Internal only - manager for action
  70535. * @hidden
  70536. */
  70537. _actionManager: ActionManager;
  70538. /**
  70539. * Creates a new PredicateCondition
  70540. * @param actionManager manager for the action the condition applies to
  70541. * @param predicate defines the predicate function used to validate the condition
  70542. */
  70543. constructor(actionManager: ActionManager,
  70544. /** defines the predicate function used to validate the condition */
  70545. predicate: () => boolean);
  70546. /**
  70547. * @returns the validity of the predicate condition
  70548. */
  70549. isValid(): boolean;
  70550. }
  70551. /**
  70552. * Defines a state condition as an extension of Condition
  70553. */
  70554. export class StateCondition extends Condition {
  70555. /** Value to compare with target state */
  70556. value: string;
  70557. /**
  70558. * Internal only - manager for action
  70559. * @hidden
  70560. */
  70561. _actionManager: ActionManager;
  70562. /**
  70563. * Internal only
  70564. * @hidden
  70565. */
  70566. private _target;
  70567. /**
  70568. * Creates a new StateCondition
  70569. * @param actionManager manager for the action the condition applies to
  70570. * @param target of the condition
  70571. * @param value to compare with target state
  70572. */
  70573. constructor(actionManager: ActionManager, target: any,
  70574. /** Value to compare with target state */
  70575. value: string);
  70576. /**
  70577. * Gets a boolean indicating if the current condition is met
  70578. * @returns the validity of the state
  70579. */
  70580. isValid(): boolean;
  70581. /**
  70582. * Serialize the StateCondition into a JSON compatible object
  70583. * @returns serialization object
  70584. */
  70585. serialize(): any;
  70586. }
  70587. }
  70588. declare module BABYLON {
  70589. /**
  70590. * This defines an action responsible to toggle a boolean once triggered.
  70591. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70592. */
  70593. export class SwitchBooleanAction extends Action {
  70594. /**
  70595. * The path to the boolean property in the target object
  70596. */
  70597. propertyPath: string;
  70598. private _target;
  70599. private _effectiveTarget;
  70600. private _property;
  70601. /**
  70602. * Instantiate the action
  70603. * @param triggerOptions defines the trigger options
  70604. * @param target defines the object containing the boolean
  70605. * @param propertyPath defines the path to the boolean property in the target object
  70606. * @param condition defines the trigger related conditions
  70607. */
  70608. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  70609. /** @hidden */
  70610. _prepare(): void;
  70611. /**
  70612. * Execute the action toggle the boolean value.
  70613. */
  70614. execute(): void;
  70615. /**
  70616. * Serializes the actions and its related information.
  70617. * @param parent defines the object to serialize in
  70618. * @returns the serialized object
  70619. */
  70620. serialize(parent: any): any;
  70621. }
  70622. /**
  70623. * This defines an action responsible to set a the state field of the target
  70624. * to a desired value once triggered.
  70625. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70626. */
  70627. export class SetStateAction extends Action {
  70628. /**
  70629. * The value to store in the state field.
  70630. */
  70631. value: string;
  70632. private _target;
  70633. /**
  70634. * Instantiate the action
  70635. * @param triggerOptions defines the trigger options
  70636. * @param target defines the object containing the state property
  70637. * @param value defines the value to store in the state field
  70638. * @param condition defines the trigger related conditions
  70639. */
  70640. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  70641. /**
  70642. * Execute the action and store the value on the target state property.
  70643. */
  70644. execute(): void;
  70645. /**
  70646. * Serializes the actions and its related information.
  70647. * @param parent defines the object to serialize in
  70648. * @returns the serialized object
  70649. */
  70650. serialize(parent: any): any;
  70651. }
  70652. /**
  70653. * This defines an action responsible to set a property of the target
  70654. * to a desired value once triggered.
  70655. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70656. */
  70657. export class SetValueAction extends Action {
  70658. /**
  70659. * The path of the property to set in the target.
  70660. */
  70661. propertyPath: string;
  70662. /**
  70663. * The value to set in the property
  70664. */
  70665. value: any;
  70666. private _target;
  70667. private _effectiveTarget;
  70668. private _property;
  70669. /**
  70670. * Instantiate the action
  70671. * @param triggerOptions defines the trigger options
  70672. * @param target defines the object containing the property
  70673. * @param propertyPath defines the path of the property to set in the target
  70674. * @param value defines the value to set in the property
  70675. * @param condition defines the trigger related conditions
  70676. */
  70677. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70678. /** @hidden */
  70679. _prepare(): void;
  70680. /**
  70681. * Execute the action and set the targetted property to the desired value.
  70682. */
  70683. execute(): void;
  70684. /**
  70685. * Serializes the actions and its related information.
  70686. * @param parent defines the object to serialize in
  70687. * @returns the serialized object
  70688. */
  70689. serialize(parent: any): any;
  70690. }
  70691. /**
  70692. * This defines an action responsible to increment the target value
  70693. * to a desired value once triggered.
  70694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70695. */
  70696. export class IncrementValueAction extends Action {
  70697. /**
  70698. * The path of the property to increment in the target.
  70699. */
  70700. propertyPath: string;
  70701. /**
  70702. * The value we should increment the property by.
  70703. */
  70704. value: any;
  70705. private _target;
  70706. private _effectiveTarget;
  70707. private _property;
  70708. /**
  70709. * Instantiate the action
  70710. * @param triggerOptions defines the trigger options
  70711. * @param target defines the object containing the property
  70712. * @param propertyPath defines the path of the property to increment in the target
  70713. * @param value defines the value value we should increment the property by
  70714. * @param condition defines the trigger related conditions
  70715. */
  70716. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70717. /** @hidden */
  70718. _prepare(): void;
  70719. /**
  70720. * Execute the action and increment the target of the value amount.
  70721. */
  70722. execute(): void;
  70723. /**
  70724. * Serializes the actions and its related information.
  70725. * @param parent defines the object to serialize in
  70726. * @returns the serialized object
  70727. */
  70728. serialize(parent: any): any;
  70729. }
  70730. /**
  70731. * This defines an action responsible to start an animation once triggered.
  70732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70733. */
  70734. export class PlayAnimationAction extends Action {
  70735. /**
  70736. * Where the animation should start (animation frame)
  70737. */
  70738. from: number;
  70739. /**
  70740. * Where the animation should stop (animation frame)
  70741. */
  70742. to: number;
  70743. /**
  70744. * Define if the animation should loop or stop after the first play.
  70745. */
  70746. loop?: boolean;
  70747. private _target;
  70748. /**
  70749. * Instantiate the action
  70750. * @param triggerOptions defines the trigger options
  70751. * @param target defines the target animation or animation name
  70752. * @param from defines from where the animation should start (animation frame)
  70753. * @param end defines where the animation should stop (animation frame)
  70754. * @param loop defines if the animation should loop or stop after the first play
  70755. * @param condition defines the trigger related conditions
  70756. */
  70757. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  70758. /** @hidden */
  70759. _prepare(): void;
  70760. /**
  70761. * Execute the action and play the animation.
  70762. */
  70763. execute(): void;
  70764. /**
  70765. * Serializes the actions and its related information.
  70766. * @param parent defines the object to serialize in
  70767. * @returns the serialized object
  70768. */
  70769. serialize(parent: any): any;
  70770. }
  70771. /**
  70772. * This defines an action responsible to stop an animation once triggered.
  70773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70774. */
  70775. export class StopAnimationAction extends Action {
  70776. private _target;
  70777. /**
  70778. * Instantiate the action
  70779. * @param triggerOptions defines the trigger options
  70780. * @param target defines the target animation or animation name
  70781. * @param condition defines the trigger related conditions
  70782. */
  70783. constructor(triggerOptions: any, target: any, condition?: Condition);
  70784. /** @hidden */
  70785. _prepare(): void;
  70786. /**
  70787. * Execute the action and stop the animation.
  70788. */
  70789. execute(): void;
  70790. /**
  70791. * Serializes the actions and its related information.
  70792. * @param parent defines the object to serialize in
  70793. * @returns the serialized object
  70794. */
  70795. serialize(parent: any): any;
  70796. }
  70797. /**
  70798. * This defines an action responsible that does nothing once triggered.
  70799. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70800. */
  70801. export class DoNothingAction extends Action {
  70802. /**
  70803. * Instantiate the action
  70804. * @param triggerOptions defines the trigger options
  70805. * @param condition defines the trigger related conditions
  70806. */
  70807. constructor(triggerOptions?: any, condition?: Condition);
  70808. /**
  70809. * Execute the action and do nothing.
  70810. */
  70811. execute(): void;
  70812. /**
  70813. * Serializes the actions and its related information.
  70814. * @param parent defines the object to serialize in
  70815. * @returns the serialized object
  70816. */
  70817. serialize(parent: any): any;
  70818. }
  70819. /**
  70820. * This defines an action responsible to trigger several actions once triggered.
  70821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70822. */
  70823. export class CombineAction extends Action {
  70824. /**
  70825. * The list of aggregated animations to run.
  70826. */
  70827. children: Action[];
  70828. /**
  70829. * Instantiate the action
  70830. * @param triggerOptions defines the trigger options
  70831. * @param children defines the list of aggregated animations to run
  70832. * @param condition defines the trigger related conditions
  70833. */
  70834. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  70835. /** @hidden */
  70836. _prepare(): void;
  70837. /**
  70838. * Execute the action and executes all the aggregated actions.
  70839. */
  70840. execute(evt: ActionEvent): void;
  70841. /**
  70842. * Serializes the actions and its related information.
  70843. * @param parent defines the object to serialize in
  70844. * @returns the serialized object
  70845. */
  70846. serialize(parent: any): any;
  70847. }
  70848. /**
  70849. * This defines an action responsible to run code (external event) once triggered.
  70850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70851. */
  70852. export class ExecuteCodeAction extends Action {
  70853. /**
  70854. * The callback function to run.
  70855. */
  70856. func: (evt: ActionEvent) => void;
  70857. /**
  70858. * Instantiate the action
  70859. * @param triggerOptions defines the trigger options
  70860. * @param func defines the callback function to run
  70861. * @param condition defines the trigger related conditions
  70862. */
  70863. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  70864. /**
  70865. * Execute the action and run the attached code.
  70866. */
  70867. execute(evt: ActionEvent): void;
  70868. }
  70869. /**
  70870. * This defines an action responsible to set the parent property of the target once triggered.
  70871. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70872. */
  70873. export class SetParentAction extends Action {
  70874. private _parent;
  70875. private _target;
  70876. /**
  70877. * Instantiate the action
  70878. * @param triggerOptions defines the trigger options
  70879. * @param target defines the target containing the parent property
  70880. * @param parent defines from where the animation should start (animation frame)
  70881. * @param condition defines the trigger related conditions
  70882. */
  70883. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  70884. /** @hidden */
  70885. _prepare(): void;
  70886. /**
  70887. * Execute the action and set the parent property.
  70888. */
  70889. execute(): void;
  70890. /**
  70891. * Serializes the actions and its related information.
  70892. * @param parent defines the object to serialize in
  70893. * @returns the serialized object
  70894. */
  70895. serialize(parent: any): any;
  70896. }
  70897. }
  70898. declare module BABYLON {
  70899. /**
  70900. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  70901. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  70902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70903. */
  70904. export class ActionManager extends AbstractActionManager {
  70905. /**
  70906. * Nothing
  70907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70908. */
  70909. static readonly NothingTrigger: number;
  70910. /**
  70911. * On pick
  70912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70913. */
  70914. static readonly OnPickTrigger: number;
  70915. /**
  70916. * On left pick
  70917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70918. */
  70919. static readonly OnLeftPickTrigger: number;
  70920. /**
  70921. * On right pick
  70922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70923. */
  70924. static readonly OnRightPickTrigger: number;
  70925. /**
  70926. * On center pick
  70927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70928. */
  70929. static readonly OnCenterPickTrigger: number;
  70930. /**
  70931. * On pick down
  70932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70933. */
  70934. static readonly OnPickDownTrigger: number;
  70935. /**
  70936. * On double pick
  70937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70938. */
  70939. static readonly OnDoublePickTrigger: number;
  70940. /**
  70941. * On pick up
  70942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70943. */
  70944. static readonly OnPickUpTrigger: number;
  70945. /**
  70946. * On pick out.
  70947. * This trigger will only be raised if you also declared a OnPickDown
  70948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70949. */
  70950. static readonly OnPickOutTrigger: number;
  70951. /**
  70952. * On long press
  70953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70954. */
  70955. static readonly OnLongPressTrigger: number;
  70956. /**
  70957. * On pointer over
  70958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70959. */
  70960. static readonly OnPointerOverTrigger: number;
  70961. /**
  70962. * On pointer out
  70963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70964. */
  70965. static readonly OnPointerOutTrigger: number;
  70966. /**
  70967. * On every frame
  70968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70969. */
  70970. static readonly OnEveryFrameTrigger: number;
  70971. /**
  70972. * On intersection enter
  70973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70974. */
  70975. static readonly OnIntersectionEnterTrigger: number;
  70976. /**
  70977. * On intersection exit
  70978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70979. */
  70980. static readonly OnIntersectionExitTrigger: number;
  70981. /**
  70982. * On key down
  70983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70984. */
  70985. static readonly OnKeyDownTrigger: number;
  70986. /**
  70987. * On key up
  70988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70989. */
  70990. static readonly OnKeyUpTrigger: number;
  70991. private _scene;
  70992. /**
  70993. * Creates a new action manager
  70994. * @param scene defines the hosting scene
  70995. */
  70996. constructor(scene: Scene);
  70997. /**
  70998. * Releases all associated resources
  70999. */
  71000. dispose(): void;
  71001. /**
  71002. * Gets hosting scene
  71003. * @returns the hosting scene
  71004. */
  71005. getScene(): Scene;
  71006. /**
  71007. * Does this action manager handles actions of any of the given triggers
  71008. * @param triggers defines the triggers to be tested
  71009. * @return a boolean indicating whether one (or more) of the triggers is handled
  71010. */
  71011. hasSpecificTriggers(triggers: number[]): boolean;
  71012. /**
  71013. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  71014. * speed.
  71015. * @param triggerA defines the trigger to be tested
  71016. * @param triggerB defines the trigger to be tested
  71017. * @return a boolean indicating whether one (or more) of the triggers is handled
  71018. */
  71019. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  71020. /**
  71021. * Does this action manager handles actions of a given trigger
  71022. * @param trigger defines the trigger to be tested
  71023. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  71024. * @return whether the trigger is handled
  71025. */
  71026. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  71027. /**
  71028. * Does this action manager has pointer triggers
  71029. */
  71030. readonly hasPointerTriggers: boolean;
  71031. /**
  71032. * Does this action manager has pick triggers
  71033. */
  71034. readonly hasPickTriggers: boolean;
  71035. /**
  71036. * Registers an action to this action manager
  71037. * @param action defines the action to be registered
  71038. * @return the action amended (prepared) after registration
  71039. */
  71040. registerAction(action: IAction): Nullable<IAction>;
  71041. /**
  71042. * Unregisters an action to this action manager
  71043. * @param action defines the action to be unregistered
  71044. * @return a boolean indicating whether the action has been unregistered
  71045. */
  71046. unregisterAction(action: IAction): Boolean;
  71047. /**
  71048. * Process a specific trigger
  71049. * @param trigger defines the trigger to process
  71050. * @param evt defines the event details to be processed
  71051. */
  71052. processTrigger(trigger: number, evt?: IActionEvent): void;
  71053. /** @hidden */
  71054. _getEffectiveTarget(target: any, propertyPath: string): any;
  71055. /** @hidden */
  71056. _getProperty(propertyPath: string): string;
  71057. /**
  71058. * Serialize this manager to a JSON object
  71059. * @param name defines the property name to store this manager
  71060. * @returns a JSON representation of this manager
  71061. */
  71062. serialize(name: string): any;
  71063. /**
  71064. * Creates a new ActionManager from a JSON data
  71065. * @param parsedActions defines the JSON data to read from
  71066. * @param object defines the hosting mesh
  71067. * @param scene defines the hosting scene
  71068. */
  71069. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  71070. /**
  71071. * Get a trigger name by index
  71072. * @param trigger defines the trigger index
  71073. * @returns a trigger name
  71074. */
  71075. static GetTriggerName(trigger: number): string;
  71076. }
  71077. }
  71078. declare module BABYLON {
  71079. /**
  71080. * Class representing a ray with position and direction
  71081. */
  71082. export class Ray {
  71083. /** origin point */
  71084. origin: Vector3;
  71085. /** direction */
  71086. direction: Vector3;
  71087. /** length of the ray */
  71088. length: number;
  71089. private static readonly TmpVector3;
  71090. private _tmpRay;
  71091. /**
  71092. * Creates a new ray
  71093. * @param origin origin point
  71094. * @param direction direction
  71095. * @param length length of the ray
  71096. */
  71097. constructor(
  71098. /** origin point */
  71099. origin: Vector3,
  71100. /** direction */
  71101. direction: Vector3,
  71102. /** length of the ray */
  71103. length?: number);
  71104. /**
  71105. * Checks if the ray intersects a box
  71106. * @param minimum bound of the box
  71107. * @param maximum bound of the box
  71108. * @param intersectionTreshold extra extend to be added to the box in all direction
  71109. * @returns if the box was hit
  71110. */
  71111. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  71112. /**
  71113. * Checks if the ray intersects a box
  71114. * @param box the bounding box to check
  71115. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  71116. * @returns if the box was hit
  71117. */
  71118. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  71119. /**
  71120. * If the ray hits a sphere
  71121. * @param sphere the bounding sphere to check
  71122. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  71123. * @returns true if it hits the sphere
  71124. */
  71125. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  71126. /**
  71127. * If the ray hits a triange
  71128. * @param vertex0 triangle vertex
  71129. * @param vertex1 triangle vertex
  71130. * @param vertex2 triangle vertex
  71131. * @returns intersection information if hit
  71132. */
  71133. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  71134. /**
  71135. * Checks if ray intersects a plane
  71136. * @param plane the plane to check
  71137. * @returns the distance away it was hit
  71138. */
  71139. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  71140. /**
  71141. * Checks if ray intersects a mesh
  71142. * @param mesh the mesh to check
  71143. * @param fastCheck if only the bounding box should checked
  71144. * @returns picking info of the intersecton
  71145. */
  71146. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  71147. /**
  71148. * Checks if ray intersects a mesh
  71149. * @param meshes the meshes to check
  71150. * @param fastCheck if only the bounding box should checked
  71151. * @param results array to store result in
  71152. * @returns Array of picking infos
  71153. */
  71154. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  71155. private _comparePickingInfo;
  71156. private static smallnum;
  71157. private static rayl;
  71158. /**
  71159. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  71160. * @param sega the first point of the segment to test the intersection against
  71161. * @param segb the second point of the segment to test the intersection against
  71162. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  71163. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  71164. */
  71165. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  71166. /**
  71167. * Update the ray from viewport position
  71168. * @param x position
  71169. * @param y y position
  71170. * @param viewportWidth viewport width
  71171. * @param viewportHeight viewport height
  71172. * @param world world matrix
  71173. * @param view view matrix
  71174. * @param projection projection matrix
  71175. * @returns this ray updated
  71176. */
  71177. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  71178. /**
  71179. * Creates a ray with origin and direction of 0,0,0
  71180. * @returns the new ray
  71181. */
  71182. static Zero(): Ray;
  71183. /**
  71184. * Creates a new ray from screen space and viewport
  71185. * @param x position
  71186. * @param y y position
  71187. * @param viewportWidth viewport width
  71188. * @param viewportHeight viewport height
  71189. * @param world world matrix
  71190. * @param view view matrix
  71191. * @param projection projection matrix
  71192. * @returns new ray
  71193. */
  71194. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  71195. /**
  71196. * 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
  71197. * transformed to the given world matrix.
  71198. * @param origin The origin point
  71199. * @param end The end point
  71200. * @param world a matrix to transform the ray to. Default is the identity matrix.
  71201. * @returns the new ray
  71202. */
  71203. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  71204. /**
  71205. * Transforms a ray by a matrix
  71206. * @param ray ray to transform
  71207. * @param matrix matrix to apply
  71208. * @returns the resulting new ray
  71209. */
  71210. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  71211. /**
  71212. * Transforms a ray by a matrix
  71213. * @param ray ray to transform
  71214. * @param matrix matrix to apply
  71215. * @param result ray to store result in
  71216. */
  71217. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  71218. /**
  71219. * Unproject a ray from screen space to object space
  71220. * @param sourceX defines the screen space x coordinate to use
  71221. * @param sourceY defines the screen space y coordinate to use
  71222. * @param viewportWidth defines the current width of the viewport
  71223. * @param viewportHeight defines the current height of the viewport
  71224. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71225. * @param view defines the view matrix to use
  71226. * @param projection defines the projection matrix to use
  71227. */
  71228. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  71229. }
  71230. /**
  71231. * Type used to define predicate used to select faces when a mesh intersection is detected
  71232. */
  71233. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  71234. interface Scene {
  71235. /** @hidden */
  71236. _tempPickingRay: Nullable<Ray>;
  71237. /** @hidden */
  71238. _cachedRayForTransform: Ray;
  71239. /** @hidden */
  71240. _pickWithRayInverseMatrix: Matrix;
  71241. /** @hidden */
  71242. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  71243. /** @hidden */
  71244. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  71245. }
  71246. }
  71247. declare module BABYLON {
  71248. /**
  71249. * Groups all the scene component constants in one place to ease maintenance.
  71250. * @hidden
  71251. */
  71252. export class SceneComponentConstants {
  71253. static readonly NAME_EFFECTLAYER: string;
  71254. static readonly NAME_LAYER: string;
  71255. static readonly NAME_LENSFLARESYSTEM: string;
  71256. static readonly NAME_BOUNDINGBOXRENDERER: string;
  71257. static readonly NAME_PARTICLESYSTEM: string;
  71258. static readonly NAME_GAMEPAD: string;
  71259. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  71260. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  71261. static readonly NAME_DEPTHRENDERER: string;
  71262. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  71263. static readonly NAME_SPRITE: string;
  71264. static readonly NAME_OUTLINERENDERER: string;
  71265. static readonly NAME_PROCEDURALTEXTURE: string;
  71266. static readonly NAME_SHADOWGENERATOR: string;
  71267. static readonly NAME_OCTREE: string;
  71268. static readonly NAME_PHYSICSENGINE: string;
  71269. static readonly NAME_AUDIO: string;
  71270. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  71271. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  71272. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  71273. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  71274. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  71275. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  71276. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  71277. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  71278. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  71279. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  71280. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  71281. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  71282. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  71283. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  71284. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  71285. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  71286. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  71287. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  71288. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  71289. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  71290. static readonly STEP_AFTERRENDER_AUDIO: number;
  71291. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  71292. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  71293. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  71294. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  71295. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  71296. static readonly STEP_POINTERMOVE_SPRITE: number;
  71297. static readonly STEP_POINTERDOWN_SPRITE: number;
  71298. static readonly STEP_POINTERUP_SPRITE: number;
  71299. }
  71300. /**
  71301. * This represents a scene component.
  71302. *
  71303. * This is used to decouple the dependency the scene is having on the different workloads like
  71304. * layers, post processes...
  71305. */
  71306. export interface ISceneComponent {
  71307. /**
  71308. * The name of the component. Each component must have a unique name.
  71309. */
  71310. name: string;
  71311. /**
  71312. * The scene the component belongs to.
  71313. */
  71314. scene: Scene;
  71315. /**
  71316. * Register the component to one instance of a scene.
  71317. */
  71318. register(): void;
  71319. /**
  71320. * Rebuilds the elements related to this component in case of
  71321. * context lost for instance.
  71322. */
  71323. rebuild(): void;
  71324. /**
  71325. * Disposes the component and the associated ressources.
  71326. */
  71327. dispose(): void;
  71328. }
  71329. /**
  71330. * This represents a SERIALIZABLE scene component.
  71331. *
  71332. * This extends Scene Component to add Serialization methods on top.
  71333. */
  71334. export interface ISceneSerializableComponent extends ISceneComponent {
  71335. /**
  71336. * Adds all the element from the container to the scene
  71337. * @param container the container holding the elements
  71338. */
  71339. addFromContainer(container: AbstractScene): void;
  71340. /**
  71341. * Removes all the elements in the container from the scene
  71342. * @param container contains the elements to remove
  71343. * @param dispose if the removed element should be disposed (default: false)
  71344. */
  71345. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71346. /**
  71347. * Serializes the component data to the specified json object
  71348. * @param serializationObject The object to serialize to
  71349. */
  71350. serialize(serializationObject: any): void;
  71351. }
  71352. /**
  71353. * Strong typing of a Mesh related stage step action
  71354. */
  71355. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  71356. /**
  71357. * Strong typing of a Evaluate Sub Mesh related stage step action
  71358. */
  71359. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  71360. /**
  71361. * Strong typing of a Active Mesh related stage step action
  71362. */
  71363. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  71364. /**
  71365. * Strong typing of a Camera related stage step action
  71366. */
  71367. export type CameraStageAction = (camera: Camera) => void;
  71368. /**
  71369. * Strong typing of a Camera Frame buffer related stage step action
  71370. */
  71371. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  71372. /**
  71373. * Strong typing of a Render Target related stage step action
  71374. */
  71375. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  71376. /**
  71377. * Strong typing of a RenderingGroup related stage step action
  71378. */
  71379. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  71380. /**
  71381. * Strong typing of a Mesh Render related stage step action
  71382. */
  71383. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  71384. /**
  71385. * Strong typing of a simple stage step action
  71386. */
  71387. export type SimpleStageAction = () => void;
  71388. /**
  71389. * Strong typing of a render target action.
  71390. */
  71391. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  71392. /**
  71393. * Strong typing of a pointer move action.
  71394. */
  71395. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  71396. /**
  71397. * Strong typing of a pointer up/down action.
  71398. */
  71399. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  71400. /**
  71401. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  71402. * @hidden
  71403. */
  71404. export class Stage<T extends Function> extends Array<{
  71405. index: number;
  71406. component: ISceneComponent;
  71407. action: T;
  71408. }> {
  71409. /**
  71410. * Hide ctor from the rest of the world.
  71411. * @param items The items to add.
  71412. */
  71413. private constructor();
  71414. /**
  71415. * Creates a new Stage.
  71416. * @returns A new instance of a Stage
  71417. */
  71418. static Create<T extends Function>(): Stage<T>;
  71419. /**
  71420. * Registers a step in an ordered way in the targeted stage.
  71421. * @param index Defines the position to register the step in
  71422. * @param component Defines the component attached to the step
  71423. * @param action Defines the action to launch during the step
  71424. */
  71425. registerStep(index: number, component: ISceneComponent, action: T): void;
  71426. /**
  71427. * Clears all the steps from the stage.
  71428. */
  71429. clear(): void;
  71430. }
  71431. }
  71432. declare module BABYLON {
  71433. interface Scene {
  71434. /** @hidden */
  71435. _pointerOverSprite: Nullable<Sprite>;
  71436. /** @hidden */
  71437. _pickedDownSprite: Nullable<Sprite>;
  71438. /** @hidden */
  71439. _tempSpritePickingRay: Nullable<Ray>;
  71440. /**
  71441. * All of the sprite managers added to this scene
  71442. * @see http://doc.babylonjs.com/babylon101/sprites
  71443. */
  71444. spriteManagers: Array<ISpriteManager>;
  71445. /**
  71446. * An event triggered when sprites rendering is about to start
  71447. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71448. */
  71449. onBeforeSpritesRenderingObservable: Observable<Scene>;
  71450. /**
  71451. * An event triggered when sprites rendering is done
  71452. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71453. */
  71454. onAfterSpritesRenderingObservable: Observable<Scene>;
  71455. /** @hidden */
  71456. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71457. /** Launch a ray to try to pick a sprite in the scene
  71458. * @param x position on screen
  71459. * @param y position on screen
  71460. * @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
  71461. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71462. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  71463. * @returns a PickingInfo
  71464. */
  71465. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71466. /** Use the given ray to pick a sprite in the scene
  71467. * @param ray The ray (in world space) to use to pick meshes
  71468. * @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
  71469. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71470. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  71471. * @returns a PickingInfo
  71472. */
  71473. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71474. /**
  71475. * Force the sprite under the pointer
  71476. * @param sprite defines the sprite to use
  71477. */
  71478. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  71479. /**
  71480. * Gets the sprite under the pointer
  71481. * @returns a Sprite or null if no sprite is under the pointer
  71482. */
  71483. getPointerOverSprite(): Nullable<Sprite>;
  71484. }
  71485. /**
  71486. * Defines the sprite scene component responsible to manage sprites
  71487. * in a given scene.
  71488. */
  71489. export class SpriteSceneComponent implements ISceneComponent {
  71490. /**
  71491. * The component name helpfull to identify the component in the list of scene components.
  71492. */
  71493. readonly name: string;
  71494. /**
  71495. * The scene the component belongs to.
  71496. */
  71497. scene: Scene;
  71498. /** @hidden */
  71499. private _spritePredicate;
  71500. /**
  71501. * Creates a new instance of the component for the given scene
  71502. * @param scene Defines the scene to register the component in
  71503. */
  71504. constructor(scene: Scene);
  71505. /**
  71506. * Registers the component in a given scene
  71507. */
  71508. register(): void;
  71509. /**
  71510. * Rebuilds the elements related to this component in case of
  71511. * context lost for instance.
  71512. */
  71513. rebuild(): void;
  71514. /**
  71515. * Disposes the component and the associated ressources.
  71516. */
  71517. dispose(): void;
  71518. private _pickSpriteButKeepRay;
  71519. private _pointerMove;
  71520. private _pointerDown;
  71521. private _pointerUp;
  71522. }
  71523. }
  71524. declare module BABYLON {
  71525. /** @hidden */
  71526. export var fogFragmentDeclaration: {
  71527. name: string;
  71528. shader: string;
  71529. };
  71530. }
  71531. declare module BABYLON {
  71532. /** @hidden */
  71533. export var fogFragment: {
  71534. name: string;
  71535. shader: string;
  71536. };
  71537. }
  71538. declare module BABYLON {
  71539. /** @hidden */
  71540. export var spritesPixelShader: {
  71541. name: string;
  71542. shader: string;
  71543. };
  71544. }
  71545. declare module BABYLON {
  71546. /** @hidden */
  71547. export var fogVertexDeclaration: {
  71548. name: string;
  71549. shader: string;
  71550. };
  71551. }
  71552. declare module BABYLON {
  71553. /** @hidden */
  71554. export var spritesVertexShader: {
  71555. name: string;
  71556. shader: string;
  71557. };
  71558. }
  71559. declare module BABYLON {
  71560. /**
  71561. * Defines the minimum interface to fullfil in order to be a sprite manager.
  71562. */
  71563. export interface ISpriteManager extends IDisposable {
  71564. /**
  71565. * Restricts the camera to viewing objects with the same layerMask.
  71566. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  71567. */
  71568. layerMask: number;
  71569. /**
  71570. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  71571. */
  71572. isPickable: boolean;
  71573. /**
  71574. * Specifies the rendering group id for this mesh (0 by default)
  71575. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  71576. */
  71577. renderingGroupId: number;
  71578. /**
  71579. * Defines the list of sprites managed by the manager.
  71580. */
  71581. sprites: Array<Sprite>;
  71582. /**
  71583. * Tests the intersection of a sprite with a specific ray.
  71584. * @param ray The ray we are sending to test the collision
  71585. * @param camera The camera space we are sending rays in
  71586. * @param predicate A predicate allowing excluding sprites from the list of object to test
  71587. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  71588. * @returns picking info or null.
  71589. */
  71590. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71591. /**
  71592. * Renders the list of sprites on screen.
  71593. */
  71594. render(): void;
  71595. }
  71596. /**
  71597. * Class used to manage multiple sprites on the same spritesheet
  71598. * @see http://doc.babylonjs.com/babylon101/sprites
  71599. */
  71600. export class SpriteManager implements ISpriteManager {
  71601. /** defines the manager's name */
  71602. name: string;
  71603. /** Gets the list of sprites */
  71604. sprites: Sprite[];
  71605. /** Gets or sets the rendering group id (0 by default) */
  71606. renderingGroupId: number;
  71607. /** Gets or sets camera layer mask */
  71608. layerMask: number;
  71609. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  71610. fogEnabled: boolean;
  71611. /** Gets or sets a boolean indicating if the sprites are pickable */
  71612. isPickable: boolean;
  71613. /** Defines the default width of a cell in the spritesheet */
  71614. cellWidth: number;
  71615. /** Defines the default height of a cell in the spritesheet */
  71616. cellHeight: number;
  71617. /**
  71618. * An event triggered when the manager is disposed.
  71619. */
  71620. onDisposeObservable: Observable<SpriteManager>;
  71621. private _onDisposeObserver;
  71622. /**
  71623. * Callback called when the manager is disposed
  71624. */
  71625. onDispose: () => void;
  71626. private _capacity;
  71627. private _spriteTexture;
  71628. private _epsilon;
  71629. private _scene;
  71630. private _vertexData;
  71631. private _buffer;
  71632. private _vertexBuffers;
  71633. private _indexBuffer;
  71634. private _effectBase;
  71635. private _effectFog;
  71636. /**
  71637. * Gets or sets the spritesheet texture
  71638. */
  71639. texture: Texture;
  71640. /**
  71641. * Creates a new sprite manager
  71642. * @param name defines the manager's name
  71643. * @param imgUrl defines the sprite sheet url
  71644. * @param capacity defines the maximum allowed number of sprites
  71645. * @param cellSize defines the size of a sprite cell
  71646. * @param scene defines the hosting scene
  71647. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71648. * @param samplingMode defines the smapling mode to use with spritesheet
  71649. */
  71650. constructor(
  71651. /** defines the manager's name */
  71652. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  71653. private _appendSpriteVertex;
  71654. /**
  71655. * Intersects the sprites with a ray
  71656. * @param ray defines the ray to intersect with
  71657. * @param camera defines the current active camera
  71658. * @param predicate defines a predicate used to select candidate sprites
  71659. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  71660. * @returns null if no hit or a PickingInfo
  71661. */
  71662. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71663. /**
  71664. * Render all child sprites
  71665. */
  71666. render(): void;
  71667. /**
  71668. * Release associated resources
  71669. */
  71670. dispose(): void;
  71671. }
  71672. }
  71673. declare module BABYLON {
  71674. /**
  71675. * Class used to represent a sprite
  71676. * @see http://doc.babylonjs.com/babylon101/sprites
  71677. */
  71678. export class Sprite {
  71679. /** defines the name */
  71680. name: string;
  71681. /** Gets or sets the current world position */
  71682. position: Vector3;
  71683. /** Gets or sets the main color */
  71684. color: Color4;
  71685. /** Gets or sets the width */
  71686. width: number;
  71687. /** Gets or sets the height */
  71688. height: number;
  71689. /** Gets or sets rotation angle */
  71690. angle: number;
  71691. /** Gets or sets the cell index in the sprite sheet */
  71692. cellIndex: number;
  71693. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  71694. invertU: number;
  71695. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  71696. invertV: number;
  71697. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  71698. disposeWhenFinishedAnimating: boolean;
  71699. /** Gets the list of attached animations */
  71700. animations: Animation[];
  71701. /** Gets or sets a boolean indicating if the sprite can be picked */
  71702. isPickable: boolean;
  71703. /**
  71704. * Gets or sets the associated action manager
  71705. */
  71706. actionManager: Nullable<ActionManager>;
  71707. private _animationStarted;
  71708. private _loopAnimation;
  71709. private _fromIndex;
  71710. private _toIndex;
  71711. private _delay;
  71712. private _direction;
  71713. private _manager;
  71714. private _time;
  71715. private _onAnimationEnd;
  71716. /**
  71717. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  71718. */
  71719. isVisible: boolean;
  71720. /**
  71721. * Gets or sets the sprite size
  71722. */
  71723. size: number;
  71724. /**
  71725. * Creates a new Sprite
  71726. * @param name defines the name
  71727. * @param manager defines the manager
  71728. */
  71729. constructor(
  71730. /** defines the name */
  71731. name: string, manager: ISpriteManager);
  71732. /**
  71733. * Starts an animation
  71734. * @param from defines the initial key
  71735. * @param to defines the end key
  71736. * @param loop defines if the animation must loop
  71737. * @param delay defines the start delay (in ms)
  71738. * @param onAnimationEnd defines a callback to call when animation ends
  71739. */
  71740. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  71741. /** Stops current animation (if any) */
  71742. stopAnimation(): void;
  71743. /** @hidden */
  71744. _animate(deltaTime: number): void;
  71745. /** Release associated resources */
  71746. dispose(): void;
  71747. }
  71748. }
  71749. declare module BABYLON {
  71750. /**
  71751. * Information about the result of picking within a scene
  71752. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  71753. */
  71754. export class PickingInfo {
  71755. /** @hidden */
  71756. _pickingUnavailable: boolean;
  71757. /**
  71758. * If the pick collided with an object
  71759. */
  71760. hit: boolean;
  71761. /**
  71762. * Distance away where the pick collided
  71763. */
  71764. distance: number;
  71765. /**
  71766. * The location of pick collision
  71767. */
  71768. pickedPoint: Nullable<Vector3>;
  71769. /**
  71770. * The mesh corresponding the the pick collision
  71771. */
  71772. pickedMesh: Nullable<AbstractMesh>;
  71773. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  71774. bu: number;
  71775. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  71776. bv: number;
  71777. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  71778. faceId: number;
  71779. /** Id of the the submesh that was picked */
  71780. subMeshId: number;
  71781. /** If a sprite was picked, this will be the sprite the pick collided with */
  71782. pickedSprite: Nullable<Sprite>;
  71783. /**
  71784. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  71785. */
  71786. originMesh: Nullable<AbstractMesh>;
  71787. /**
  71788. * The ray that was used to perform the picking.
  71789. */
  71790. ray: Nullable<Ray>;
  71791. /**
  71792. * Gets the normal correspodning to the face the pick collided with
  71793. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  71794. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  71795. * @returns The normal correspodning to the face the pick collided with
  71796. */
  71797. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  71798. /**
  71799. * Gets the texture coordinates of where the pick occured
  71800. * @returns the vector containing the coordnates of the texture
  71801. */
  71802. getTextureCoordinates(): Nullable<Vector2>;
  71803. }
  71804. }
  71805. declare module BABYLON {
  71806. /**
  71807. * Gather the list of pointer event types as constants.
  71808. */
  71809. export class PointerEventTypes {
  71810. /**
  71811. * 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.
  71812. */
  71813. static readonly POINTERDOWN: number;
  71814. /**
  71815. * The pointerup event is fired when a pointer is no longer active.
  71816. */
  71817. static readonly POINTERUP: number;
  71818. /**
  71819. * The pointermove event is fired when a pointer changes coordinates.
  71820. */
  71821. static readonly POINTERMOVE: number;
  71822. /**
  71823. * The pointerwheel event is fired when a mouse wheel has been rotated.
  71824. */
  71825. static readonly POINTERWHEEL: number;
  71826. /**
  71827. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  71828. */
  71829. static readonly POINTERPICK: number;
  71830. /**
  71831. * The pointertap event is fired when a the object has been touched and released without drag.
  71832. */
  71833. static readonly POINTERTAP: number;
  71834. /**
  71835. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  71836. */
  71837. static readonly POINTERDOUBLETAP: number;
  71838. }
  71839. /**
  71840. * Base class of pointer info types.
  71841. */
  71842. export class PointerInfoBase {
  71843. /**
  71844. * Defines the type of event (PointerEventTypes)
  71845. */
  71846. type: number;
  71847. /**
  71848. * Defines the related dom event
  71849. */
  71850. event: PointerEvent | MouseWheelEvent;
  71851. /**
  71852. * Instantiates the base class of pointers info.
  71853. * @param type Defines the type of event (PointerEventTypes)
  71854. * @param event Defines the related dom event
  71855. */
  71856. constructor(
  71857. /**
  71858. * Defines the type of event (PointerEventTypes)
  71859. */
  71860. type: number,
  71861. /**
  71862. * Defines the related dom event
  71863. */
  71864. event: PointerEvent | MouseWheelEvent);
  71865. }
  71866. /**
  71867. * This class is used to store pointer related info for the onPrePointerObservable event.
  71868. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  71869. */
  71870. export class PointerInfoPre extends PointerInfoBase {
  71871. /**
  71872. * Ray from a pointer if availible (eg. 6dof controller)
  71873. */
  71874. ray: Nullable<Ray>;
  71875. /**
  71876. * Defines the local position of the pointer on the canvas.
  71877. */
  71878. localPosition: Vector2;
  71879. /**
  71880. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  71881. */
  71882. skipOnPointerObservable: boolean;
  71883. /**
  71884. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  71885. * @param type Defines the type of event (PointerEventTypes)
  71886. * @param event Defines the related dom event
  71887. * @param localX Defines the local x coordinates of the pointer when the event occured
  71888. * @param localY Defines the local y coordinates of the pointer when the event occured
  71889. */
  71890. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  71891. }
  71892. /**
  71893. * This type contains all the data related to a pointer event in Babylon.js.
  71894. * 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.
  71895. */
  71896. export class PointerInfo extends PointerInfoBase {
  71897. /**
  71898. * Defines the picking info associated to the info (if any)\
  71899. */
  71900. pickInfo: Nullable<PickingInfo>;
  71901. /**
  71902. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  71903. * @param type Defines the type of event (PointerEventTypes)
  71904. * @param event Defines the related dom event
  71905. * @param pickInfo Defines the picking info associated to the info (if any)\
  71906. */
  71907. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  71908. /**
  71909. * Defines the picking info associated to the info (if any)\
  71910. */
  71911. pickInfo: Nullable<PickingInfo>);
  71912. }
  71913. /**
  71914. * Data relating to a touch event on the screen.
  71915. */
  71916. export interface PointerTouch {
  71917. /**
  71918. * X coordinate of touch.
  71919. */
  71920. x: number;
  71921. /**
  71922. * Y coordinate of touch.
  71923. */
  71924. y: number;
  71925. /**
  71926. * Id of touch. Unique for each finger.
  71927. */
  71928. pointerId: number;
  71929. /**
  71930. * Event type passed from DOM.
  71931. */
  71932. type: any;
  71933. }
  71934. }
  71935. declare module BABYLON {
  71936. /**
  71937. * Manage the mouse inputs to control the movement of a free camera.
  71938. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71939. */
  71940. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  71941. /**
  71942. * Define if touch is enabled in the mouse input
  71943. */
  71944. touchEnabled: boolean;
  71945. /**
  71946. * Defines the camera the input is attached to.
  71947. */
  71948. camera: FreeCamera;
  71949. /**
  71950. * Defines the buttons associated with the input to handle camera move.
  71951. */
  71952. buttons: number[];
  71953. /**
  71954. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  71955. */
  71956. angularSensibility: number;
  71957. private _pointerInput;
  71958. private _onMouseMove;
  71959. private _observer;
  71960. private previousPosition;
  71961. /**
  71962. * Observable for when a pointer move event occurs containing the move offset
  71963. */
  71964. onPointerMovedObservable: Observable<{
  71965. offsetX: number;
  71966. offsetY: number;
  71967. }>;
  71968. /**
  71969. * @hidden
  71970. * If the camera should be rotated automatically based on pointer movement
  71971. */
  71972. _allowCameraRotation: boolean;
  71973. /**
  71974. * Manage the mouse inputs to control the movement of a free camera.
  71975. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71976. * @param touchEnabled Defines if touch is enabled or not
  71977. */
  71978. constructor(
  71979. /**
  71980. * Define if touch is enabled in the mouse input
  71981. */
  71982. touchEnabled?: boolean);
  71983. /**
  71984. * Attach the input controls to a specific dom element to get the input from.
  71985. * @param element Defines the element the controls should be listened from
  71986. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71987. */
  71988. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71989. /**
  71990. * Called on JS contextmenu event.
  71991. * Override this method to provide functionality.
  71992. */
  71993. protected onContextMenu(evt: PointerEvent): void;
  71994. /**
  71995. * Detach the current controls from the specified dom element.
  71996. * @param element Defines the element to stop listening the inputs from
  71997. */
  71998. detachControl(element: Nullable<HTMLElement>): void;
  71999. /**
  72000. * Gets the class name of the current intput.
  72001. * @returns the class name
  72002. */
  72003. getClassName(): string;
  72004. /**
  72005. * Get the friendly name associated with the input class.
  72006. * @returns the input friendly name
  72007. */
  72008. getSimpleName(): string;
  72009. }
  72010. }
  72011. declare module BABYLON {
  72012. /**
  72013. * Manage the touch inputs to control the movement of a free camera.
  72014. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72015. */
  72016. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  72017. /**
  72018. * Defines the camera the input is attached to.
  72019. */
  72020. camera: FreeCamera;
  72021. /**
  72022. * Defines the touch sensibility for rotation.
  72023. * The higher the faster.
  72024. */
  72025. touchAngularSensibility: number;
  72026. /**
  72027. * Defines the touch sensibility for move.
  72028. * The higher the faster.
  72029. */
  72030. touchMoveSensibility: number;
  72031. private _offsetX;
  72032. private _offsetY;
  72033. private _pointerPressed;
  72034. private _pointerInput;
  72035. private _observer;
  72036. private _onLostFocus;
  72037. /**
  72038. * Attach the input controls to a specific dom element to get the input from.
  72039. * @param element Defines the element the controls should be listened from
  72040. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72041. */
  72042. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72043. /**
  72044. * Detach the current controls from the specified dom element.
  72045. * @param element Defines the element to stop listening the inputs from
  72046. */
  72047. detachControl(element: Nullable<HTMLElement>): void;
  72048. /**
  72049. * Update the current camera state depending on the inputs that have been used this frame.
  72050. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72051. */
  72052. checkInputs(): void;
  72053. /**
  72054. * Gets the class name of the current intput.
  72055. * @returns the class name
  72056. */
  72057. getClassName(): string;
  72058. /**
  72059. * Get the friendly name associated with the input class.
  72060. * @returns the input friendly name
  72061. */
  72062. getSimpleName(): string;
  72063. }
  72064. }
  72065. declare module BABYLON {
  72066. /**
  72067. * Default Inputs manager for the FreeCamera.
  72068. * It groups all the default supported inputs for ease of use.
  72069. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72070. */
  72071. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  72072. /**
  72073. * @hidden
  72074. */
  72075. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  72076. /**
  72077. * @hidden
  72078. */
  72079. _mouseInput: Nullable<FreeCameraMouseInput>;
  72080. /**
  72081. * Instantiates a new FreeCameraInputsManager.
  72082. * @param camera Defines the camera the inputs belong to
  72083. */
  72084. constructor(camera: FreeCamera);
  72085. /**
  72086. * Add keyboard input support to the input manager.
  72087. * @returns the current input manager
  72088. */
  72089. addKeyboard(): FreeCameraInputsManager;
  72090. /**
  72091. * Add mouse input support to the input manager.
  72092. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  72093. * @returns the current input manager
  72094. */
  72095. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  72096. /**
  72097. * Removes the mouse input support from the manager
  72098. * @returns the current input manager
  72099. */
  72100. removeMouse(): FreeCameraInputsManager;
  72101. /**
  72102. * Add touch input support to the input manager.
  72103. * @returns the current input manager
  72104. */
  72105. addTouch(): FreeCameraInputsManager;
  72106. }
  72107. }
  72108. declare module BABYLON {
  72109. /**
  72110. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  72111. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  72112. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  72113. */
  72114. export class FreeCamera extends TargetCamera {
  72115. /**
  72116. * Define the collision ellipsoid of the camera.
  72117. * This is helpful to simulate a camera body like the player body around the camera
  72118. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  72119. */
  72120. ellipsoid: Vector3;
  72121. /**
  72122. * Define an offset for the position of the ellipsoid around the camera.
  72123. * This can be helpful to determine the center of the body near the gravity center of the body
  72124. * instead of its head.
  72125. */
  72126. ellipsoidOffset: Vector3;
  72127. /**
  72128. * Enable or disable collisions of the camera with the rest of the scene objects.
  72129. */
  72130. checkCollisions: boolean;
  72131. /**
  72132. * Enable or disable gravity on the camera.
  72133. */
  72134. applyGravity: boolean;
  72135. /**
  72136. * Define the input manager associated to the camera.
  72137. */
  72138. inputs: FreeCameraInputsManager;
  72139. /**
  72140. * Gets the input sensibility for a mouse input. (default is 2000.0)
  72141. * Higher values reduce sensitivity.
  72142. */
  72143. /**
  72144. * Sets the input sensibility for a mouse input. (default is 2000.0)
  72145. * Higher values reduce sensitivity.
  72146. */
  72147. angularSensibility: number;
  72148. /**
  72149. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  72150. */
  72151. keysUp: number[];
  72152. /**
  72153. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  72154. */
  72155. keysDown: number[];
  72156. /**
  72157. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  72158. */
  72159. keysLeft: number[];
  72160. /**
  72161. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  72162. */
  72163. keysRight: number[];
  72164. /**
  72165. * Event raised when the camera collide with a mesh in the scene.
  72166. */
  72167. onCollide: (collidedMesh: AbstractMesh) => void;
  72168. private _collider;
  72169. private _needMoveForGravity;
  72170. private _oldPosition;
  72171. private _diffPosition;
  72172. private _newPosition;
  72173. /** @hidden */
  72174. _localDirection: Vector3;
  72175. /** @hidden */
  72176. _transformedDirection: Vector3;
  72177. /**
  72178. * Instantiates a Free Camera.
  72179. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  72180. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  72181. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  72182. * @param name Define the name of the camera in the scene
  72183. * @param position Define the start position of the camera in the scene
  72184. * @param scene Define the scene the camera belongs to
  72185. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  72186. */
  72187. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  72188. /**
  72189. * Attached controls to the current camera.
  72190. * @param element Defines the element the controls should be listened from
  72191. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72192. */
  72193. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72194. /**
  72195. * Detach the current controls from the camera.
  72196. * The camera will stop reacting to inputs.
  72197. * @param element Defines the element to stop listening the inputs from
  72198. */
  72199. detachControl(element: HTMLElement): void;
  72200. private _collisionMask;
  72201. /**
  72202. * Define a collision mask to limit the list of object the camera can collide with
  72203. */
  72204. collisionMask: number;
  72205. /** @hidden */
  72206. _collideWithWorld(displacement: Vector3): void;
  72207. private _onCollisionPositionChange;
  72208. /** @hidden */
  72209. _checkInputs(): void;
  72210. /** @hidden */
  72211. _decideIfNeedsToMove(): boolean;
  72212. /** @hidden */
  72213. _updatePosition(): void;
  72214. /**
  72215. * Destroy the camera and release the current resources hold by it.
  72216. */
  72217. dispose(): void;
  72218. /**
  72219. * Gets the current object class name.
  72220. * @return the class name
  72221. */
  72222. getClassName(): string;
  72223. }
  72224. }
  72225. declare module BABYLON {
  72226. /**
  72227. * Represents a gamepad control stick position
  72228. */
  72229. export class StickValues {
  72230. /**
  72231. * The x component of the control stick
  72232. */
  72233. x: number;
  72234. /**
  72235. * The y component of the control stick
  72236. */
  72237. y: number;
  72238. /**
  72239. * Initializes the gamepad x and y control stick values
  72240. * @param x The x component of the gamepad control stick value
  72241. * @param y The y component of the gamepad control stick value
  72242. */
  72243. constructor(
  72244. /**
  72245. * The x component of the control stick
  72246. */
  72247. x: number,
  72248. /**
  72249. * The y component of the control stick
  72250. */
  72251. y: number);
  72252. }
  72253. /**
  72254. * An interface which manages callbacks for gamepad button changes
  72255. */
  72256. export interface GamepadButtonChanges {
  72257. /**
  72258. * Called when a gamepad has been changed
  72259. */
  72260. changed: boolean;
  72261. /**
  72262. * Called when a gamepad press event has been triggered
  72263. */
  72264. pressChanged: boolean;
  72265. /**
  72266. * Called when a touch event has been triggered
  72267. */
  72268. touchChanged: boolean;
  72269. /**
  72270. * Called when a value has changed
  72271. */
  72272. valueChanged: boolean;
  72273. }
  72274. /**
  72275. * Represents a gamepad
  72276. */
  72277. export class Gamepad {
  72278. /**
  72279. * The id of the gamepad
  72280. */
  72281. id: string;
  72282. /**
  72283. * The index of the gamepad
  72284. */
  72285. index: number;
  72286. /**
  72287. * The browser gamepad
  72288. */
  72289. browserGamepad: any;
  72290. /**
  72291. * Specifies what type of gamepad this represents
  72292. */
  72293. type: number;
  72294. private _leftStick;
  72295. private _rightStick;
  72296. /** @hidden */
  72297. _isConnected: boolean;
  72298. private _leftStickAxisX;
  72299. private _leftStickAxisY;
  72300. private _rightStickAxisX;
  72301. private _rightStickAxisY;
  72302. /**
  72303. * Triggered when the left control stick has been changed
  72304. */
  72305. private _onleftstickchanged;
  72306. /**
  72307. * Triggered when the right control stick has been changed
  72308. */
  72309. private _onrightstickchanged;
  72310. /**
  72311. * Represents a gamepad controller
  72312. */
  72313. static GAMEPAD: number;
  72314. /**
  72315. * Represents a generic controller
  72316. */
  72317. static GENERIC: number;
  72318. /**
  72319. * Represents an XBox controller
  72320. */
  72321. static XBOX: number;
  72322. /**
  72323. * Represents a pose-enabled controller
  72324. */
  72325. static POSE_ENABLED: number;
  72326. /**
  72327. * Specifies whether the left control stick should be Y-inverted
  72328. */
  72329. protected _invertLeftStickY: boolean;
  72330. /**
  72331. * Specifies if the gamepad has been connected
  72332. */
  72333. readonly isConnected: boolean;
  72334. /**
  72335. * Initializes the gamepad
  72336. * @param id The id of the gamepad
  72337. * @param index The index of the gamepad
  72338. * @param browserGamepad The browser gamepad
  72339. * @param leftStickX The x component of the left joystick
  72340. * @param leftStickY The y component of the left joystick
  72341. * @param rightStickX The x component of the right joystick
  72342. * @param rightStickY The y component of the right joystick
  72343. */
  72344. constructor(
  72345. /**
  72346. * The id of the gamepad
  72347. */
  72348. id: string,
  72349. /**
  72350. * The index of the gamepad
  72351. */
  72352. index: number,
  72353. /**
  72354. * The browser gamepad
  72355. */
  72356. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  72357. /**
  72358. * Callback triggered when the left joystick has changed
  72359. * @param callback
  72360. */
  72361. onleftstickchanged(callback: (values: StickValues) => void): void;
  72362. /**
  72363. * Callback triggered when the right joystick has changed
  72364. * @param callback
  72365. */
  72366. onrightstickchanged(callback: (values: StickValues) => void): void;
  72367. /**
  72368. * Gets the left joystick
  72369. */
  72370. /**
  72371. * Sets the left joystick values
  72372. */
  72373. leftStick: StickValues;
  72374. /**
  72375. * Gets the right joystick
  72376. */
  72377. /**
  72378. * Sets the right joystick value
  72379. */
  72380. rightStick: StickValues;
  72381. /**
  72382. * Updates the gamepad joystick positions
  72383. */
  72384. update(): void;
  72385. /**
  72386. * Disposes the gamepad
  72387. */
  72388. dispose(): void;
  72389. }
  72390. /**
  72391. * Represents a generic gamepad
  72392. */
  72393. export class GenericPad extends Gamepad {
  72394. private _buttons;
  72395. private _onbuttondown;
  72396. private _onbuttonup;
  72397. /**
  72398. * Observable triggered when a button has been pressed
  72399. */
  72400. onButtonDownObservable: Observable<number>;
  72401. /**
  72402. * Observable triggered when a button has been released
  72403. */
  72404. onButtonUpObservable: Observable<number>;
  72405. /**
  72406. * Callback triggered when a button has been pressed
  72407. * @param callback Called when a button has been pressed
  72408. */
  72409. onbuttondown(callback: (buttonPressed: number) => void): void;
  72410. /**
  72411. * Callback triggered when a button has been released
  72412. * @param callback Called when a button has been released
  72413. */
  72414. onbuttonup(callback: (buttonReleased: number) => void): void;
  72415. /**
  72416. * Initializes the generic gamepad
  72417. * @param id The id of the generic gamepad
  72418. * @param index The index of the generic gamepad
  72419. * @param browserGamepad The browser gamepad
  72420. */
  72421. constructor(id: string, index: number, browserGamepad: any);
  72422. private _setButtonValue;
  72423. /**
  72424. * Updates the generic gamepad
  72425. */
  72426. update(): void;
  72427. /**
  72428. * Disposes the generic gamepad
  72429. */
  72430. dispose(): void;
  72431. }
  72432. }
  72433. declare module BABYLON {
  72434. /**
  72435. * Defines the types of pose enabled controllers that are supported
  72436. */
  72437. export enum PoseEnabledControllerType {
  72438. /**
  72439. * HTC Vive
  72440. */
  72441. VIVE = 0,
  72442. /**
  72443. * Oculus Rift
  72444. */
  72445. OCULUS = 1,
  72446. /**
  72447. * Windows mixed reality
  72448. */
  72449. WINDOWS = 2,
  72450. /**
  72451. * Samsung gear VR
  72452. */
  72453. GEAR_VR = 3,
  72454. /**
  72455. * Google Daydream
  72456. */
  72457. DAYDREAM = 4,
  72458. /**
  72459. * Generic
  72460. */
  72461. GENERIC = 5
  72462. }
  72463. /**
  72464. * Defines the MutableGamepadButton interface for the state of a gamepad button
  72465. */
  72466. export interface MutableGamepadButton {
  72467. /**
  72468. * Value of the button/trigger
  72469. */
  72470. value: number;
  72471. /**
  72472. * If the button/trigger is currently touched
  72473. */
  72474. touched: boolean;
  72475. /**
  72476. * If the button/trigger is currently pressed
  72477. */
  72478. pressed: boolean;
  72479. }
  72480. /**
  72481. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  72482. * @hidden
  72483. */
  72484. export interface ExtendedGamepadButton extends GamepadButton {
  72485. /**
  72486. * If the button/trigger is currently pressed
  72487. */
  72488. readonly pressed: boolean;
  72489. /**
  72490. * If the button/trigger is currently touched
  72491. */
  72492. readonly touched: boolean;
  72493. /**
  72494. * Value of the button/trigger
  72495. */
  72496. readonly value: number;
  72497. }
  72498. /** @hidden */
  72499. export interface _GamePadFactory {
  72500. /**
  72501. * Returns wether or not the current gamepad can be created for this type of controller.
  72502. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72503. * @returns true if it can be created, otherwise false
  72504. */
  72505. canCreate(gamepadInfo: any): boolean;
  72506. /**
  72507. * Creates a new instance of the Gamepad.
  72508. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72509. * @returns the new gamepad instance
  72510. */
  72511. create(gamepadInfo: any): Gamepad;
  72512. }
  72513. /**
  72514. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72515. */
  72516. export class PoseEnabledControllerHelper {
  72517. /** @hidden */
  72518. static _ControllerFactories: _GamePadFactory[];
  72519. /** @hidden */
  72520. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  72521. /**
  72522. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72523. * @param vrGamepad the gamepad to initialized
  72524. * @returns a vr controller of the type the gamepad identified as
  72525. */
  72526. static InitiateController(vrGamepad: any): Gamepad;
  72527. }
  72528. /**
  72529. * Defines the PoseEnabledController object that contains state of a vr capable controller
  72530. */
  72531. export class PoseEnabledController extends Gamepad implements PoseControlled {
  72532. private _deviceRoomPosition;
  72533. private _deviceRoomRotationQuaternion;
  72534. /**
  72535. * The device position in babylon space
  72536. */
  72537. devicePosition: Vector3;
  72538. /**
  72539. * The device rotation in babylon space
  72540. */
  72541. deviceRotationQuaternion: Quaternion;
  72542. /**
  72543. * The scale factor of the device in babylon space
  72544. */
  72545. deviceScaleFactor: number;
  72546. /**
  72547. * (Likely devicePosition should be used instead) The device position in its room space
  72548. */
  72549. position: Vector3;
  72550. /**
  72551. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  72552. */
  72553. rotationQuaternion: Quaternion;
  72554. /**
  72555. * The type of controller (Eg. Windows mixed reality)
  72556. */
  72557. controllerType: PoseEnabledControllerType;
  72558. protected _calculatedPosition: Vector3;
  72559. private _calculatedRotation;
  72560. /**
  72561. * The raw pose from the device
  72562. */
  72563. rawPose: DevicePose;
  72564. private _trackPosition;
  72565. private _maxRotationDistFromHeadset;
  72566. private _draggedRoomRotation;
  72567. /**
  72568. * @hidden
  72569. */
  72570. _disableTrackPosition(fixedPosition: Vector3): void;
  72571. /**
  72572. * Internal, the mesh attached to the controller
  72573. * @hidden
  72574. */
  72575. _mesh: Nullable<AbstractMesh>;
  72576. private _poseControlledCamera;
  72577. private _leftHandSystemQuaternion;
  72578. /**
  72579. * Internal, matrix used to convert room space to babylon space
  72580. * @hidden
  72581. */
  72582. _deviceToWorld: Matrix;
  72583. /**
  72584. * Node to be used when casting a ray from the controller
  72585. * @hidden
  72586. */
  72587. _pointingPoseNode: Nullable<TransformNode>;
  72588. /**
  72589. * Name of the child mesh that can be used to cast a ray from the controller
  72590. */
  72591. static readonly POINTING_POSE: string;
  72592. /**
  72593. * Creates a new PoseEnabledController from a gamepad
  72594. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  72595. */
  72596. constructor(browserGamepad: any);
  72597. private _workingMatrix;
  72598. /**
  72599. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  72600. */
  72601. update(): void;
  72602. /**
  72603. * Updates only the pose device and mesh without doing any button event checking
  72604. */
  72605. protected _updatePoseAndMesh(): void;
  72606. /**
  72607. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  72608. * @param poseData raw pose fromthe device
  72609. */
  72610. updateFromDevice(poseData: DevicePose): void;
  72611. /**
  72612. * @hidden
  72613. */
  72614. _meshAttachedObservable: Observable<AbstractMesh>;
  72615. /**
  72616. * Attaches a mesh to the controller
  72617. * @param mesh the mesh to be attached
  72618. */
  72619. attachToMesh(mesh: AbstractMesh): void;
  72620. /**
  72621. * Attaches the controllers mesh to a camera
  72622. * @param camera the camera the mesh should be attached to
  72623. */
  72624. attachToPoseControlledCamera(camera: TargetCamera): void;
  72625. /**
  72626. * Disposes of the controller
  72627. */
  72628. dispose(): void;
  72629. /**
  72630. * The mesh that is attached to the controller
  72631. */
  72632. readonly mesh: Nullable<AbstractMesh>;
  72633. /**
  72634. * Gets the ray of the controller in the direction the controller is pointing
  72635. * @param length the length the resulting ray should be
  72636. * @returns a ray in the direction the controller is pointing
  72637. */
  72638. getForwardRay(length?: number): Ray;
  72639. }
  72640. }
  72641. declare module BABYLON {
  72642. /**
  72643. * Defines the WebVRController object that represents controllers tracked in 3D space
  72644. */
  72645. export abstract class WebVRController extends PoseEnabledController {
  72646. /**
  72647. * Internal, the default controller model for the controller
  72648. */
  72649. protected _defaultModel: AbstractMesh;
  72650. /**
  72651. * Fired when the trigger state has changed
  72652. */
  72653. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  72654. /**
  72655. * Fired when the main button state has changed
  72656. */
  72657. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72658. /**
  72659. * Fired when the secondary button state has changed
  72660. */
  72661. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72662. /**
  72663. * Fired when the pad state has changed
  72664. */
  72665. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  72666. /**
  72667. * Fired when controllers stick values have changed
  72668. */
  72669. onPadValuesChangedObservable: Observable<StickValues>;
  72670. /**
  72671. * Array of button availible on the controller
  72672. */
  72673. protected _buttons: Array<MutableGamepadButton>;
  72674. private _onButtonStateChange;
  72675. /**
  72676. * Fired when a controller button's state has changed
  72677. * @param callback the callback containing the button that was modified
  72678. */
  72679. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  72680. /**
  72681. * X and Y axis corrisponding to the controllers joystick
  72682. */
  72683. pad: StickValues;
  72684. /**
  72685. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  72686. */
  72687. hand: string;
  72688. /**
  72689. * The default controller model for the controller
  72690. */
  72691. readonly defaultModel: AbstractMesh;
  72692. /**
  72693. * Creates a new WebVRController from a gamepad
  72694. * @param vrGamepad the gamepad that the WebVRController should be created from
  72695. */
  72696. constructor(vrGamepad: any);
  72697. /**
  72698. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  72699. */
  72700. update(): void;
  72701. /**
  72702. * Function to be called when a button is modified
  72703. */
  72704. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  72705. /**
  72706. * Loads a mesh and attaches it to the controller
  72707. * @param scene the scene the mesh should be added to
  72708. * @param meshLoaded callback for when the mesh has been loaded
  72709. */
  72710. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  72711. private _setButtonValue;
  72712. private _changes;
  72713. private _checkChanges;
  72714. /**
  72715. * Disposes of th webVRCOntroller
  72716. */
  72717. dispose(): void;
  72718. }
  72719. }
  72720. declare module BABYLON {
  72721. /**
  72722. * The HemisphericLight simulates the ambient environment light,
  72723. * so the passed direction is the light reflection direction, not the incoming direction.
  72724. */
  72725. export class HemisphericLight extends Light {
  72726. /**
  72727. * The groundColor is the light in the opposite direction to the one specified during creation.
  72728. * 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.
  72729. */
  72730. groundColor: Color3;
  72731. /**
  72732. * The light reflection direction, not the incoming direction.
  72733. */
  72734. direction: Vector3;
  72735. /**
  72736. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  72737. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  72738. * The HemisphericLight can't cast shadows.
  72739. * Documentation : https://doc.babylonjs.com/babylon101/lights
  72740. * @param name The friendly name of the light
  72741. * @param direction The direction of the light reflection
  72742. * @param scene The scene the light belongs to
  72743. */
  72744. constructor(name: string, direction: Vector3, scene: Scene);
  72745. protected _buildUniformLayout(): void;
  72746. /**
  72747. * Returns the string "HemisphericLight".
  72748. * @return The class name
  72749. */
  72750. getClassName(): string;
  72751. /**
  72752. * Sets the HemisphericLight direction towards the passed target (Vector3).
  72753. * Returns the updated direction.
  72754. * @param target The target the direction should point to
  72755. * @return The computed direction
  72756. */
  72757. setDirectionToTarget(target: Vector3): Vector3;
  72758. /**
  72759. * Returns the shadow generator associated to the light.
  72760. * @returns Always null for hemispheric lights because it does not support shadows.
  72761. */
  72762. getShadowGenerator(): Nullable<IShadowGenerator>;
  72763. /**
  72764. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  72765. * @param effect The effect to update
  72766. * @param lightIndex The index of the light in the effect to update
  72767. * @returns The hemispheric light
  72768. */
  72769. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  72770. /**
  72771. * Computes the world matrix of the node
  72772. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  72773. * @param useWasUpdatedFlag defines a reserved property
  72774. * @returns the world matrix
  72775. */
  72776. computeWorldMatrix(): Matrix;
  72777. /**
  72778. * Returns the integer 3.
  72779. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  72780. */
  72781. getTypeID(): number;
  72782. /**
  72783. * Prepares the list of defines specific to the light type.
  72784. * @param defines the list of defines
  72785. * @param lightIndex defines the index of the light for the effect
  72786. */
  72787. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  72788. }
  72789. }
  72790. declare module BABYLON {
  72791. /** @hidden */
  72792. export var vrMultiviewToSingleviewPixelShader: {
  72793. name: string;
  72794. shader: string;
  72795. };
  72796. }
  72797. declare module BABYLON {
  72798. /**
  72799. * Renders to multiple views with a single draw call
  72800. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  72801. */
  72802. export class MultiviewRenderTarget extends RenderTargetTexture {
  72803. /**
  72804. * Creates a multiview render target
  72805. * @param scene scene used with the render target
  72806. * @param size the size of the render target (used for each view)
  72807. */
  72808. constructor(scene: Scene, size?: number | {
  72809. width: number;
  72810. height: number;
  72811. } | {
  72812. ratio: number;
  72813. });
  72814. /**
  72815. * @hidden
  72816. * @param faceIndex the face index, if its a cube texture
  72817. */
  72818. _bindFrameBuffer(faceIndex?: number): void;
  72819. /**
  72820. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  72821. * @returns the view count
  72822. */
  72823. getViewCount(): number;
  72824. }
  72825. }
  72826. declare module BABYLON {
  72827. interface Engine {
  72828. /**
  72829. * Creates a new multiview render target
  72830. * @param width defines the width of the texture
  72831. * @param height defines the height of the texture
  72832. * @returns the created multiview texture
  72833. */
  72834. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  72835. /**
  72836. * Binds a multiview framebuffer to be drawn to
  72837. * @param multiviewTexture texture to bind
  72838. */
  72839. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  72840. }
  72841. interface Camera {
  72842. /**
  72843. * @hidden
  72844. * 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)
  72845. */
  72846. _useMultiviewToSingleView: boolean;
  72847. /**
  72848. * @hidden
  72849. * 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)
  72850. */
  72851. _multiviewTexture: Nullable<RenderTargetTexture>;
  72852. /**
  72853. * @hidden
  72854. * ensures the multiview texture of the camera exists and has the specified width/height
  72855. * @param width height to set on the multiview texture
  72856. * @param height width to set on the multiview texture
  72857. */
  72858. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  72859. }
  72860. interface Scene {
  72861. /** @hidden */
  72862. _transformMatrixR: Matrix;
  72863. /** @hidden */
  72864. _multiviewSceneUbo: Nullable<UniformBuffer>;
  72865. /** @hidden */
  72866. _createMultiviewUbo(): void;
  72867. /** @hidden */
  72868. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  72869. /** @hidden */
  72870. _renderMultiviewToSingleView(camera: Camera): void;
  72871. }
  72872. }
  72873. declare module BABYLON {
  72874. /**
  72875. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  72876. * This will not be used for webXR as it supports displaying texture arrays directly
  72877. */
  72878. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  72879. /**
  72880. * Initializes a VRMultiviewToSingleview
  72881. * @param name name of the post process
  72882. * @param camera camera to be applied to
  72883. * @param scaleFactor scaling factor to the size of the output texture
  72884. */
  72885. constructor(name: string, camera: Camera, scaleFactor: number);
  72886. }
  72887. }
  72888. declare module BABYLON {
  72889. /**
  72890. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  72891. * IMPORTANT!! The data is right-hand data.
  72892. * @export
  72893. * @interface DevicePose
  72894. */
  72895. export interface DevicePose {
  72896. /**
  72897. * The position of the device, values in array are [x,y,z].
  72898. */
  72899. readonly position: Nullable<Float32Array>;
  72900. /**
  72901. * The linearVelocity of the device, values in array are [x,y,z].
  72902. */
  72903. readonly linearVelocity: Nullable<Float32Array>;
  72904. /**
  72905. * The linearAcceleration of the device, values in array are [x,y,z].
  72906. */
  72907. readonly linearAcceleration: Nullable<Float32Array>;
  72908. /**
  72909. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  72910. */
  72911. readonly orientation: Nullable<Float32Array>;
  72912. /**
  72913. * The angularVelocity of the device, values in array are [x,y,z].
  72914. */
  72915. readonly angularVelocity: Nullable<Float32Array>;
  72916. /**
  72917. * The angularAcceleration of the device, values in array are [x,y,z].
  72918. */
  72919. readonly angularAcceleration: Nullable<Float32Array>;
  72920. }
  72921. /**
  72922. * Interface representing a pose controlled object in Babylon.
  72923. * A pose controlled object has both regular pose values as well as pose values
  72924. * from an external device such as a VR head mounted display
  72925. */
  72926. export interface PoseControlled {
  72927. /**
  72928. * The position of the object in babylon space.
  72929. */
  72930. position: Vector3;
  72931. /**
  72932. * The rotation quaternion of the object in babylon space.
  72933. */
  72934. rotationQuaternion: Quaternion;
  72935. /**
  72936. * The position of the device in babylon space.
  72937. */
  72938. devicePosition?: Vector3;
  72939. /**
  72940. * The rotation quaternion of the device in babylon space.
  72941. */
  72942. deviceRotationQuaternion: Quaternion;
  72943. /**
  72944. * The raw pose coming from the device.
  72945. */
  72946. rawPose: Nullable<DevicePose>;
  72947. /**
  72948. * The scale of the device to be used when translating from device space to babylon space.
  72949. */
  72950. deviceScaleFactor: number;
  72951. /**
  72952. * Updates the poseControlled values based on the input device pose.
  72953. * @param poseData the pose data to update the object with
  72954. */
  72955. updateFromDevice(poseData: DevicePose): void;
  72956. }
  72957. /**
  72958. * Set of options to customize the webVRCamera
  72959. */
  72960. export interface WebVROptions {
  72961. /**
  72962. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  72963. */
  72964. trackPosition?: boolean;
  72965. /**
  72966. * Sets the scale of the vrDevice in babylon space. (default: 1)
  72967. */
  72968. positionScale?: number;
  72969. /**
  72970. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  72971. */
  72972. displayName?: string;
  72973. /**
  72974. * Should the native controller meshes be initialized. (default: true)
  72975. */
  72976. controllerMeshes?: boolean;
  72977. /**
  72978. * Creating a default HemiLight only on controllers. (default: true)
  72979. */
  72980. defaultLightingOnControllers?: boolean;
  72981. /**
  72982. * If you don't want to use the default VR button of the helper. (default: false)
  72983. */
  72984. useCustomVRButton?: boolean;
  72985. /**
  72986. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  72987. */
  72988. customVRButton?: HTMLButtonElement;
  72989. /**
  72990. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  72991. */
  72992. rayLength?: number;
  72993. /**
  72994. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  72995. */
  72996. defaultHeight?: number;
  72997. /**
  72998. * If multiview should be used if availible (default: false)
  72999. */
  73000. useMultiview?: boolean;
  73001. }
  73002. /**
  73003. * This represents a WebVR camera.
  73004. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  73005. * @example http://doc.babylonjs.com/how_to/webvr_camera
  73006. */
  73007. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  73008. private webVROptions;
  73009. /**
  73010. * @hidden
  73011. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  73012. */
  73013. _vrDevice: any;
  73014. /**
  73015. * The rawPose of the vrDevice.
  73016. */
  73017. rawPose: Nullable<DevicePose>;
  73018. private _onVREnabled;
  73019. private _specsVersion;
  73020. private _attached;
  73021. private _frameData;
  73022. protected _descendants: Array<Node>;
  73023. private _deviceRoomPosition;
  73024. /** @hidden */
  73025. _deviceRoomRotationQuaternion: Quaternion;
  73026. private _standingMatrix;
  73027. /**
  73028. * Represents device position in babylon space.
  73029. */
  73030. devicePosition: Vector3;
  73031. /**
  73032. * Represents device rotation in babylon space.
  73033. */
  73034. deviceRotationQuaternion: Quaternion;
  73035. /**
  73036. * The scale of the device to be used when translating from device space to babylon space.
  73037. */
  73038. deviceScaleFactor: number;
  73039. private _deviceToWorld;
  73040. private _worldToDevice;
  73041. /**
  73042. * References to the webVR controllers for the vrDevice.
  73043. */
  73044. controllers: Array<WebVRController>;
  73045. /**
  73046. * Emits an event when a controller is attached.
  73047. */
  73048. onControllersAttachedObservable: Observable<WebVRController[]>;
  73049. /**
  73050. * Emits an event when a controller's mesh has been loaded;
  73051. */
  73052. onControllerMeshLoadedObservable: Observable<WebVRController>;
  73053. /**
  73054. * Emits an event when the HMD's pose has been updated.
  73055. */
  73056. onPoseUpdatedFromDeviceObservable: Observable<any>;
  73057. private _poseSet;
  73058. /**
  73059. * If the rig cameras be used as parent instead of this camera.
  73060. */
  73061. rigParenting: boolean;
  73062. private _lightOnControllers;
  73063. private _defaultHeight?;
  73064. /**
  73065. * Instantiates a WebVRFreeCamera.
  73066. * @param name The name of the WebVRFreeCamera
  73067. * @param position The starting anchor position for the camera
  73068. * @param scene The scene the camera belongs to
  73069. * @param webVROptions a set of customizable options for the webVRCamera
  73070. */
  73071. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  73072. /**
  73073. * Gets the device distance from the ground in meters.
  73074. * @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.
  73075. */
  73076. deviceDistanceToRoomGround(): number;
  73077. /**
  73078. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  73079. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  73080. */
  73081. useStandingMatrix(callback?: (bool: boolean) => void): void;
  73082. /**
  73083. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  73084. * @returns A promise with a boolean set to if the standing matrix is supported.
  73085. */
  73086. useStandingMatrixAsync(): Promise<boolean>;
  73087. /**
  73088. * Disposes the camera
  73089. */
  73090. dispose(): void;
  73091. /**
  73092. * Gets a vrController by name.
  73093. * @param name The name of the controller to retreive
  73094. * @returns the controller matching the name specified or null if not found
  73095. */
  73096. getControllerByName(name: string): Nullable<WebVRController>;
  73097. private _leftController;
  73098. /**
  73099. * The controller corrisponding to the users left hand.
  73100. */
  73101. readonly leftController: Nullable<WebVRController>;
  73102. private _rightController;
  73103. /**
  73104. * The controller corrisponding to the users right hand.
  73105. */
  73106. readonly rightController: Nullable<WebVRController>;
  73107. /**
  73108. * Casts a ray forward from the vrCamera's gaze.
  73109. * @param length Length of the ray (default: 100)
  73110. * @returns the ray corrisponding to the gaze
  73111. */
  73112. getForwardRay(length?: number): Ray;
  73113. /**
  73114. * @hidden
  73115. * Updates the camera based on device's frame data
  73116. */
  73117. _checkInputs(): void;
  73118. /**
  73119. * Updates the poseControlled values based on the input device pose.
  73120. * @param poseData Pose coming from the device
  73121. */
  73122. updateFromDevice(poseData: DevicePose): void;
  73123. private _htmlElementAttached;
  73124. private _detachIfAttached;
  73125. /**
  73126. * WebVR's attach control will start broadcasting frames to the device.
  73127. * Note that in certain browsers (chrome for example) this function must be called
  73128. * within a user-interaction callback. Example:
  73129. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  73130. *
  73131. * @param element html element to attach the vrDevice to
  73132. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  73133. */
  73134. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73135. /**
  73136. * Detaches the camera from the html element and disables VR
  73137. *
  73138. * @param element html element to detach from
  73139. */
  73140. detachControl(element: HTMLElement): void;
  73141. /**
  73142. * @returns the name of this class
  73143. */
  73144. getClassName(): string;
  73145. /**
  73146. * Calls resetPose on the vrDisplay
  73147. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  73148. */
  73149. resetToCurrentRotation(): void;
  73150. /**
  73151. * @hidden
  73152. * Updates the rig cameras (left and right eye)
  73153. */
  73154. _updateRigCameras(): void;
  73155. private _workingVector;
  73156. private _oneVector;
  73157. private _workingMatrix;
  73158. private updateCacheCalled;
  73159. private _correctPositionIfNotTrackPosition;
  73160. /**
  73161. * @hidden
  73162. * Updates the cached values of the camera
  73163. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  73164. */
  73165. _updateCache(ignoreParentClass?: boolean): void;
  73166. /**
  73167. * @hidden
  73168. * Get current device position in babylon world
  73169. */
  73170. _computeDevicePosition(): void;
  73171. /**
  73172. * Updates the current device position and rotation in the babylon world
  73173. */
  73174. update(): void;
  73175. /**
  73176. * @hidden
  73177. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  73178. * @returns an identity matrix
  73179. */
  73180. _getViewMatrix(): Matrix;
  73181. private _tmpMatrix;
  73182. /**
  73183. * This function is called by the two RIG cameras.
  73184. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  73185. * @hidden
  73186. */
  73187. _getWebVRViewMatrix(): Matrix;
  73188. /** @hidden */
  73189. _getWebVRProjectionMatrix(): Matrix;
  73190. private _onGamepadConnectedObserver;
  73191. private _onGamepadDisconnectedObserver;
  73192. private _updateCacheWhenTrackingDisabledObserver;
  73193. /**
  73194. * Initializes the controllers and their meshes
  73195. */
  73196. initControllers(): void;
  73197. }
  73198. }
  73199. declare module BABYLON {
  73200. /**
  73201. * Size options for a post process
  73202. */
  73203. export type PostProcessOptions = {
  73204. width: number;
  73205. height: number;
  73206. };
  73207. /**
  73208. * PostProcess can be used to apply a shader to a texture after it has been rendered
  73209. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73210. */
  73211. export class PostProcess {
  73212. /** Name of the PostProcess. */
  73213. name: string;
  73214. /**
  73215. * Gets or sets the unique id of the post process
  73216. */
  73217. uniqueId: number;
  73218. /**
  73219. * Width of the texture to apply the post process on
  73220. */
  73221. width: number;
  73222. /**
  73223. * Height of the texture to apply the post process on
  73224. */
  73225. height: number;
  73226. /**
  73227. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  73228. * @hidden
  73229. */
  73230. _outputTexture: Nullable<InternalTexture>;
  73231. /**
  73232. * Sampling mode used by the shader
  73233. * See https://doc.babylonjs.com/classes/3.1/texture
  73234. */
  73235. renderTargetSamplingMode: number;
  73236. /**
  73237. * Clear color to use when screen clearing
  73238. */
  73239. clearColor: Color4;
  73240. /**
  73241. * If the buffer needs to be cleared before applying the post process. (default: true)
  73242. * Should be set to false if shader will overwrite all previous pixels.
  73243. */
  73244. autoClear: boolean;
  73245. /**
  73246. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  73247. */
  73248. alphaMode: number;
  73249. /**
  73250. * Sets the setAlphaBlendConstants of the babylon engine
  73251. */
  73252. alphaConstants: Color4;
  73253. /**
  73254. * Animations to be used for the post processing
  73255. */
  73256. animations: Animation[];
  73257. /**
  73258. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  73259. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  73260. */
  73261. enablePixelPerfectMode: boolean;
  73262. /**
  73263. * Force the postprocess to be applied without taking in account viewport
  73264. */
  73265. forceFullscreenViewport: boolean;
  73266. /**
  73267. * List of inspectable custom properties (used by the Inspector)
  73268. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73269. */
  73270. inspectableCustomProperties: IInspectable[];
  73271. /**
  73272. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  73273. *
  73274. * | Value | Type | Description |
  73275. * | ----- | ----------------------------------- | ----------- |
  73276. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  73277. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  73278. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  73279. *
  73280. */
  73281. scaleMode: number;
  73282. /**
  73283. * Force textures to be a power of two (default: false)
  73284. */
  73285. alwaysForcePOT: boolean;
  73286. private _samples;
  73287. /**
  73288. * Number of sample textures (default: 1)
  73289. */
  73290. samples: number;
  73291. /**
  73292. * Modify the scale of the post process to be the same as the viewport (default: false)
  73293. */
  73294. adaptScaleToCurrentViewport: boolean;
  73295. private _camera;
  73296. private _scene;
  73297. private _engine;
  73298. private _options;
  73299. private _reusable;
  73300. private _textureType;
  73301. /**
  73302. * Smart array of input and output textures for the post process.
  73303. * @hidden
  73304. */
  73305. _textures: SmartArray<InternalTexture>;
  73306. /**
  73307. * The index in _textures that corresponds to the output texture.
  73308. * @hidden
  73309. */
  73310. _currentRenderTextureInd: number;
  73311. private _effect;
  73312. private _samplers;
  73313. private _fragmentUrl;
  73314. private _vertexUrl;
  73315. private _parameters;
  73316. private _scaleRatio;
  73317. protected _indexParameters: any;
  73318. private _shareOutputWithPostProcess;
  73319. private _texelSize;
  73320. private _forcedOutputTexture;
  73321. /**
  73322. * Returns the fragment url or shader name used in the post process.
  73323. * @returns the fragment url or name in the shader store.
  73324. */
  73325. getEffectName(): string;
  73326. /**
  73327. * An event triggered when the postprocess is activated.
  73328. */
  73329. onActivateObservable: Observable<Camera>;
  73330. private _onActivateObserver;
  73331. /**
  73332. * A function that is added to the onActivateObservable
  73333. */
  73334. onActivate: Nullable<(camera: Camera) => void>;
  73335. /**
  73336. * An event triggered when the postprocess changes its size.
  73337. */
  73338. onSizeChangedObservable: Observable<PostProcess>;
  73339. private _onSizeChangedObserver;
  73340. /**
  73341. * A function that is added to the onSizeChangedObservable
  73342. */
  73343. onSizeChanged: (postProcess: PostProcess) => void;
  73344. /**
  73345. * An event triggered when the postprocess applies its effect.
  73346. */
  73347. onApplyObservable: Observable<Effect>;
  73348. private _onApplyObserver;
  73349. /**
  73350. * A function that is added to the onApplyObservable
  73351. */
  73352. onApply: (effect: Effect) => void;
  73353. /**
  73354. * An event triggered before rendering the postprocess
  73355. */
  73356. onBeforeRenderObservable: Observable<Effect>;
  73357. private _onBeforeRenderObserver;
  73358. /**
  73359. * A function that is added to the onBeforeRenderObservable
  73360. */
  73361. onBeforeRender: (effect: Effect) => void;
  73362. /**
  73363. * An event triggered after rendering the postprocess
  73364. */
  73365. onAfterRenderObservable: Observable<Effect>;
  73366. private _onAfterRenderObserver;
  73367. /**
  73368. * A function that is added to the onAfterRenderObservable
  73369. */
  73370. onAfterRender: (efect: Effect) => void;
  73371. /**
  73372. * 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
  73373. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  73374. */
  73375. inputTexture: InternalTexture;
  73376. /**
  73377. * Gets the camera which post process is applied to.
  73378. * @returns The camera the post process is applied to.
  73379. */
  73380. getCamera(): Camera;
  73381. /**
  73382. * Gets the texel size of the postprocess.
  73383. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  73384. */
  73385. readonly texelSize: Vector2;
  73386. /**
  73387. * Creates a new instance PostProcess
  73388. * @param name The name of the PostProcess.
  73389. * @param fragmentUrl The url of the fragment shader to be used.
  73390. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  73391. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  73392. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  73393. * @param camera The camera to apply the render pass to.
  73394. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73395. * @param engine The engine which the post process will be applied. (default: current engine)
  73396. * @param reusable If the post process can be reused on the same frame. (default: false)
  73397. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  73398. * @param textureType Type of textures used when performing the post process. (default: 0)
  73399. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  73400. * @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
  73401. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  73402. */
  73403. constructor(
  73404. /** Name of the PostProcess. */
  73405. 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);
  73406. /**
  73407. * Gets a string idenfifying the name of the class
  73408. * @returns "PostProcess" string
  73409. */
  73410. getClassName(): string;
  73411. /**
  73412. * Gets the engine which this post process belongs to.
  73413. * @returns The engine the post process was enabled with.
  73414. */
  73415. getEngine(): Engine;
  73416. /**
  73417. * The effect that is created when initializing the post process.
  73418. * @returns The created effect corrisponding the the postprocess.
  73419. */
  73420. getEffect(): Effect;
  73421. /**
  73422. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  73423. * @param postProcess The post process to share the output with.
  73424. * @returns This post process.
  73425. */
  73426. shareOutputWith(postProcess: PostProcess): PostProcess;
  73427. /**
  73428. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  73429. * This should be called if the post process that shares output with this post process is disabled/disposed.
  73430. */
  73431. useOwnOutput(): void;
  73432. /**
  73433. * Updates the effect with the current post process compile time values and recompiles the shader.
  73434. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73435. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73436. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73437. * @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
  73438. * @param onCompiled Called when the shader has been compiled.
  73439. * @param onError Called if there is an error when compiling a shader.
  73440. */
  73441. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73442. /**
  73443. * The post process is reusable if it can be used multiple times within one frame.
  73444. * @returns If the post process is reusable
  73445. */
  73446. isReusable(): boolean;
  73447. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  73448. markTextureDirty(): void;
  73449. /**
  73450. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  73451. * 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.
  73452. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  73453. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  73454. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  73455. * @returns The target texture that was bound to be written to.
  73456. */
  73457. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  73458. /**
  73459. * If the post process is supported.
  73460. */
  73461. readonly isSupported: boolean;
  73462. /**
  73463. * The aspect ratio of the output texture.
  73464. */
  73465. readonly aspectRatio: number;
  73466. /**
  73467. * Get a value indicating if the post-process is ready to be used
  73468. * @returns true if the post-process is ready (shader is compiled)
  73469. */
  73470. isReady(): boolean;
  73471. /**
  73472. * Binds all textures and uniforms to the shader, this will be run on every pass.
  73473. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  73474. */
  73475. apply(): Nullable<Effect>;
  73476. private _disposeTextures;
  73477. /**
  73478. * Disposes the post process.
  73479. * @param camera The camera to dispose the post process on.
  73480. */
  73481. dispose(camera?: Camera): void;
  73482. }
  73483. }
  73484. declare module BABYLON {
  73485. /**
  73486. * PostProcessManager is used to manage one or more post processes or post process pipelines
  73487. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73488. */
  73489. export class PostProcessManager {
  73490. private _scene;
  73491. private _indexBuffer;
  73492. private _vertexBuffers;
  73493. /**
  73494. * Creates a new instance PostProcess
  73495. * @param scene The scene that the post process is associated with.
  73496. */
  73497. constructor(scene: Scene);
  73498. private _prepareBuffers;
  73499. private _buildIndexBuffer;
  73500. /**
  73501. * Rebuilds the vertex buffers of the manager.
  73502. * @hidden
  73503. */
  73504. _rebuild(): void;
  73505. /**
  73506. * Prepares a frame to be run through a post process.
  73507. * @param sourceTexture The input texture to the post procesess. (default: null)
  73508. * @param postProcesses An array of post processes to be run. (default: null)
  73509. * @returns True if the post processes were able to be run.
  73510. * @hidden
  73511. */
  73512. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  73513. /**
  73514. * Manually render a set of post processes to a texture.
  73515. * @param postProcesses An array of post processes to be run.
  73516. * @param targetTexture The target texture to render to.
  73517. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  73518. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  73519. * @param lodLevel defines which lod of the texture to render to
  73520. */
  73521. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  73522. /**
  73523. * Finalize the result of the output of the postprocesses.
  73524. * @param doNotPresent If true the result will not be displayed to the screen.
  73525. * @param targetTexture The target texture to render to.
  73526. * @param faceIndex The index of the face to bind the target texture to.
  73527. * @param postProcesses The array of post processes to render.
  73528. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  73529. * @hidden
  73530. */
  73531. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  73532. /**
  73533. * Disposes of the post process manager.
  73534. */
  73535. dispose(): void;
  73536. }
  73537. }
  73538. declare module BABYLON {
  73539. interface AbstractScene {
  73540. /**
  73541. * The list of layers (background and foreground) of the scene
  73542. */
  73543. layers: Array<Layer>;
  73544. }
  73545. /**
  73546. * Defines the layer scene component responsible to manage any layers
  73547. * in a given scene.
  73548. */
  73549. export class LayerSceneComponent implements ISceneComponent {
  73550. /**
  73551. * The component name helpfull to identify the component in the list of scene components.
  73552. */
  73553. readonly name: string;
  73554. /**
  73555. * The scene the component belongs to.
  73556. */
  73557. scene: Scene;
  73558. private _engine;
  73559. /**
  73560. * Creates a new instance of the component for the given scene
  73561. * @param scene Defines the scene to register the component in
  73562. */
  73563. constructor(scene: Scene);
  73564. /**
  73565. * Registers the component in a given scene
  73566. */
  73567. register(): void;
  73568. /**
  73569. * Rebuilds the elements related to this component in case of
  73570. * context lost for instance.
  73571. */
  73572. rebuild(): void;
  73573. /**
  73574. * Disposes the component and the associated ressources.
  73575. */
  73576. dispose(): void;
  73577. private _draw;
  73578. private _drawCameraPredicate;
  73579. private _drawCameraBackground;
  73580. private _drawCameraForeground;
  73581. private _drawRenderTargetPredicate;
  73582. private _drawRenderTargetBackground;
  73583. private _drawRenderTargetForeground;
  73584. }
  73585. }
  73586. declare module BABYLON {
  73587. /** @hidden */
  73588. export var layerPixelShader: {
  73589. name: string;
  73590. shader: string;
  73591. };
  73592. }
  73593. declare module BABYLON {
  73594. /** @hidden */
  73595. export var layerVertexShader: {
  73596. name: string;
  73597. shader: string;
  73598. };
  73599. }
  73600. declare module BABYLON {
  73601. /**
  73602. * This represents a full screen 2d layer.
  73603. * This can be useful to display a picture in the background of your scene for instance.
  73604. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73605. */
  73606. export class Layer {
  73607. /**
  73608. * Define the name of the layer.
  73609. */
  73610. name: string;
  73611. /**
  73612. * Define the texture the layer should display.
  73613. */
  73614. texture: Nullable<Texture>;
  73615. /**
  73616. * Is the layer in background or foreground.
  73617. */
  73618. isBackground: boolean;
  73619. /**
  73620. * Define the color of the layer (instead of texture).
  73621. */
  73622. color: Color4;
  73623. /**
  73624. * Define the scale of the layer in order to zoom in out of the texture.
  73625. */
  73626. scale: Vector2;
  73627. /**
  73628. * Define an offset for the layer in order to shift the texture.
  73629. */
  73630. offset: Vector2;
  73631. /**
  73632. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  73633. */
  73634. alphaBlendingMode: number;
  73635. /**
  73636. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  73637. * Alpha test will not mix with the background color in case of transparency.
  73638. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  73639. */
  73640. alphaTest: boolean;
  73641. /**
  73642. * Define a mask to restrict the layer to only some of the scene cameras.
  73643. */
  73644. layerMask: number;
  73645. /**
  73646. * Define the list of render target the layer is visible into.
  73647. */
  73648. renderTargetTextures: RenderTargetTexture[];
  73649. /**
  73650. * Define if the layer is only used in renderTarget or if it also
  73651. * renders in the main frame buffer of the canvas.
  73652. */
  73653. renderOnlyInRenderTargetTextures: boolean;
  73654. private _scene;
  73655. private _vertexBuffers;
  73656. private _indexBuffer;
  73657. private _effect;
  73658. private _alphaTestEffect;
  73659. /**
  73660. * An event triggered when the layer is disposed.
  73661. */
  73662. onDisposeObservable: Observable<Layer>;
  73663. private _onDisposeObserver;
  73664. /**
  73665. * Back compatibility with callback before the onDisposeObservable existed.
  73666. * The set callback will be triggered when the layer has been disposed.
  73667. */
  73668. onDispose: () => void;
  73669. /**
  73670. * An event triggered before rendering the scene
  73671. */
  73672. onBeforeRenderObservable: Observable<Layer>;
  73673. private _onBeforeRenderObserver;
  73674. /**
  73675. * Back compatibility with callback before the onBeforeRenderObservable existed.
  73676. * The set callback will be triggered just before rendering the layer.
  73677. */
  73678. onBeforeRender: () => void;
  73679. /**
  73680. * An event triggered after rendering the scene
  73681. */
  73682. onAfterRenderObservable: Observable<Layer>;
  73683. private _onAfterRenderObserver;
  73684. /**
  73685. * Back compatibility with callback before the onAfterRenderObservable existed.
  73686. * The set callback will be triggered just after rendering the layer.
  73687. */
  73688. onAfterRender: () => void;
  73689. /**
  73690. * Instantiates a new layer.
  73691. * This represents a full screen 2d layer.
  73692. * This can be useful to display a picture in the background of your scene for instance.
  73693. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73694. * @param name Define the name of the layer in the scene
  73695. * @param imgUrl Define the url of the texture to display in the layer
  73696. * @param scene Define the scene the layer belongs to
  73697. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  73698. * @param color Defines a color for the layer
  73699. */
  73700. constructor(
  73701. /**
  73702. * Define the name of the layer.
  73703. */
  73704. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  73705. private _createIndexBuffer;
  73706. /** @hidden */
  73707. _rebuild(): void;
  73708. /**
  73709. * Renders the layer in the scene.
  73710. */
  73711. render(): void;
  73712. /**
  73713. * Disposes and releases the associated ressources.
  73714. */
  73715. dispose(): void;
  73716. }
  73717. }
  73718. declare module BABYLON {
  73719. interface AbstractScene {
  73720. /**
  73721. * The list of procedural textures added to the scene
  73722. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73723. */
  73724. proceduralTextures: Array<ProceduralTexture>;
  73725. }
  73726. /**
  73727. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  73728. * in a given scene.
  73729. */
  73730. export class ProceduralTextureSceneComponent implements ISceneComponent {
  73731. /**
  73732. * The component name helpfull to identify the component in the list of scene components.
  73733. */
  73734. readonly name: string;
  73735. /**
  73736. * The scene the component belongs to.
  73737. */
  73738. scene: Scene;
  73739. /**
  73740. * Creates a new instance of the component for the given scene
  73741. * @param scene Defines the scene to register the component in
  73742. */
  73743. constructor(scene: Scene);
  73744. /**
  73745. * Registers the component in a given scene
  73746. */
  73747. register(): void;
  73748. /**
  73749. * Rebuilds the elements related to this component in case of
  73750. * context lost for instance.
  73751. */
  73752. rebuild(): void;
  73753. /**
  73754. * Disposes the component and the associated ressources.
  73755. */
  73756. dispose(): void;
  73757. private _beforeClear;
  73758. }
  73759. }
  73760. declare module BABYLON {
  73761. interface Engine {
  73762. /**
  73763. * Creates a new render target cube texture
  73764. * @param size defines the size of the texture
  73765. * @param options defines the options used to create the texture
  73766. * @returns a new render target cube texture stored in an InternalTexture
  73767. */
  73768. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  73769. }
  73770. }
  73771. declare module BABYLON {
  73772. /** @hidden */
  73773. export var proceduralVertexShader: {
  73774. name: string;
  73775. shader: string;
  73776. };
  73777. }
  73778. declare module BABYLON {
  73779. /**
  73780. * 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.
  73781. * This is the base class of any Procedural texture and contains most of the shareable code.
  73782. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73783. */
  73784. export class ProceduralTexture extends Texture {
  73785. isCube: boolean;
  73786. /**
  73787. * Define if the texture is enabled or not (disabled texture will not render)
  73788. */
  73789. isEnabled: boolean;
  73790. /**
  73791. * Define if the texture must be cleared before rendering (default is true)
  73792. */
  73793. autoClear: boolean;
  73794. /**
  73795. * Callback called when the texture is generated
  73796. */
  73797. onGenerated: () => void;
  73798. /**
  73799. * Event raised when the texture is generated
  73800. */
  73801. onGeneratedObservable: Observable<ProceduralTexture>;
  73802. /** @hidden */
  73803. _generateMipMaps: boolean;
  73804. /** @hidden **/
  73805. _effect: Effect;
  73806. /** @hidden */
  73807. _textures: {
  73808. [key: string]: Texture;
  73809. };
  73810. private _size;
  73811. private _currentRefreshId;
  73812. private _refreshRate;
  73813. private _vertexBuffers;
  73814. private _indexBuffer;
  73815. private _uniforms;
  73816. private _samplers;
  73817. private _fragment;
  73818. private _floats;
  73819. private _ints;
  73820. private _floatsArrays;
  73821. private _colors3;
  73822. private _colors4;
  73823. private _vectors2;
  73824. private _vectors3;
  73825. private _matrices;
  73826. private _fallbackTexture;
  73827. private _fallbackTextureUsed;
  73828. private _engine;
  73829. private _cachedDefines;
  73830. private _contentUpdateId;
  73831. private _contentData;
  73832. /**
  73833. * Instantiates a new procedural texture.
  73834. * 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.
  73835. * This is the base class of any Procedural texture and contains most of the shareable code.
  73836. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73837. * @param name Define the name of the texture
  73838. * @param size Define the size of the texture to create
  73839. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  73840. * @param scene Define the scene the texture belongs to
  73841. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  73842. * @param generateMipMaps Define if the texture should creates mip maps or not
  73843. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  73844. */
  73845. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  73846. /**
  73847. * The effect that is created when initializing the post process.
  73848. * @returns The created effect corrisponding the the postprocess.
  73849. */
  73850. getEffect(): Effect;
  73851. /**
  73852. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  73853. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  73854. */
  73855. getContent(): Nullable<ArrayBufferView>;
  73856. private _createIndexBuffer;
  73857. /** @hidden */
  73858. _rebuild(): void;
  73859. /**
  73860. * Resets the texture in order to recreate its associated resources.
  73861. * This can be called in case of context loss
  73862. */
  73863. reset(): void;
  73864. protected _getDefines(): string;
  73865. /**
  73866. * Is the texture ready to be used ? (rendered at least once)
  73867. * @returns true if ready, otherwise, false.
  73868. */
  73869. isReady(): boolean;
  73870. /**
  73871. * Resets the refresh counter of the texture and start bak from scratch.
  73872. * Could be useful to regenerate the texture if it is setup to render only once.
  73873. */
  73874. resetRefreshCounter(): void;
  73875. /**
  73876. * Set the fragment shader to use in order to render the texture.
  73877. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  73878. */
  73879. setFragment(fragment: any): void;
  73880. /**
  73881. * Define the refresh rate of the texture or the rendering frequency.
  73882. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  73883. */
  73884. refreshRate: number;
  73885. /** @hidden */
  73886. _shouldRender(): boolean;
  73887. /**
  73888. * Get the size the texture is rendering at.
  73889. * @returns the size (texture is always squared)
  73890. */
  73891. getRenderSize(): number;
  73892. /**
  73893. * Resize the texture to new value.
  73894. * @param size Define the new size the texture should have
  73895. * @param generateMipMaps Define whether the new texture should create mip maps
  73896. */
  73897. resize(size: number, generateMipMaps: boolean): void;
  73898. private _checkUniform;
  73899. /**
  73900. * Set a texture in the shader program used to render.
  73901. * @param name Define the name of the uniform samplers as defined in the shader
  73902. * @param texture Define the texture to bind to this sampler
  73903. * @return the texture itself allowing "fluent" like uniform updates
  73904. */
  73905. setTexture(name: string, texture: Texture): ProceduralTexture;
  73906. /**
  73907. * Set a float in the shader.
  73908. * @param name Define the name of the uniform as defined in the shader
  73909. * @param value Define the value to give to the uniform
  73910. * @return the texture itself allowing "fluent" like uniform updates
  73911. */
  73912. setFloat(name: string, value: number): ProceduralTexture;
  73913. /**
  73914. * Set a int in the shader.
  73915. * @param name Define the name of the uniform as defined in the shader
  73916. * @param value Define the value to give to the uniform
  73917. * @return the texture itself allowing "fluent" like uniform updates
  73918. */
  73919. setInt(name: string, value: number): ProceduralTexture;
  73920. /**
  73921. * Set an array of floats in the shader.
  73922. * @param name Define the name of the uniform as defined in the shader
  73923. * @param value Define the value to give to the uniform
  73924. * @return the texture itself allowing "fluent" like uniform updates
  73925. */
  73926. setFloats(name: string, value: number[]): ProceduralTexture;
  73927. /**
  73928. * Set a vec3 in the shader from a Color3.
  73929. * @param name Define the name of the uniform as defined in the shader
  73930. * @param value Define the value to give to the uniform
  73931. * @return the texture itself allowing "fluent" like uniform updates
  73932. */
  73933. setColor3(name: string, value: Color3): ProceduralTexture;
  73934. /**
  73935. * Set a vec4 in the shader from a Color4.
  73936. * @param name Define the name of the uniform as defined in the shader
  73937. * @param value Define the value to give to the uniform
  73938. * @return the texture itself allowing "fluent" like uniform updates
  73939. */
  73940. setColor4(name: string, value: Color4): ProceduralTexture;
  73941. /**
  73942. * Set a vec2 in the shader from a Vector2.
  73943. * @param name Define the name of the uniform as defined in the shader
  73944. * @param value Define the value to give to the uniform
  73945. * @return the texture itself allowing "fluent" like uniform updates
  73946. */
  73947. setVector2(name: string, value: Vector2): ProceduralTexture;
  73948. /**
  73949. * Set a vec3 in the shader from a Vector3.
  73950. * @param name Define the name of the uniform as defined in the shader
  73951. * @param value Define the value to give to the uniform
  73952. * @return the texture itself allowing "fluent" like uniform updates
  73953. */
  73954. setVector3(name: string, value: Vector3): ProceduralTexture;
  73955. /**
  73956. * Set a mat4 in the shader from a MAtrix.
  73957. * @param name Define the name of the uniform as defined in the shader
  73958. * @param value Define the value to give to the uniform
  73959. * @return the texture itself allowing "fluent" like uniform updates
  73960. */
  73961. setMatrix(name: string, value: Matrix): ProceduralTexture;
  73962. /**
  73963. * Render the texture to its associated render target.
  73964. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  73965. */
  73966. render(useCameraPostProcess?: boolean): void;
  73967. /**
  73968. * Clone the texture.
  73969. * @returns the cloned texture
  73970. */
  73971. clone(): ProceduralTexture;
  73972. /**
  73973. * Dispose the texture and release its asoociated resources.
  73974. */
  73975. dispose(): void;
  73976. }
  73977. }
  73978. declare module BABYLON {
  73979. /**
  73980. * This represents the base class for particle system in Babylon.
  73981. * 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.
  73982. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  73983. * @example https://doc.babylonjs.com/babylon101/particles
  73984. */
  73985. export class BaseParticleSystem {
  73986. /**
  73987. * Source color is added to the destination color without alpha affecting the result
  73988. */
  73989. static BLENDMODE_ONEONE: number;
  73990. /**
  73991. * Blend current color and particle color using particle’s alpha
  73992. */
  73993. static BLENDMODE_STANDARD: number;
  73994. /**
  73995. * Add current color and particle color multiplied by particle’s alpha
  73996. */
  73997. static BLENDMODE_ADD: number;
  73998. /**
  73999. * Multiply current color with particle color
  74000. */
  74001. static BLENDMODE_MULTIPLY: number;
  74002. /**
  74003. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  74004. */
  74005. static BLENDMODE_MULTIPLYADD: number;
  74006. /**
  74007. * List of animations used by the particle system.
  74008. */
  74009. animations: Animation[];
  74010. /**
  74011. * The id of the Particle system.
  74012. */
  74013. id: string;
  74014. /**
  74015. * The friendly name of the Particle system.
  74016. */
  74017. name: string;
  74018. /**
  74019. * The rendering group used by the Particle system to chose when to render.
  74020. */
  74021. renderingGroupId: number;
  74022. /**
  74023. * The emitter represents the Mesh or position we are attaching the particle system to.
  74024. */
  74025. emitter: Nullable<AbstractMesh | Vector3>;
  74026. /**
  74027. * The maximum number of particles to emit per frame
  74028. */
  74029. emitRate: number;
  74030. /**
  74031. * If you want to launch only a few particles at once, that can be done, as well.
  74032. */
  74033. manualEmitCount: number;
  74034. /**
  74035. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  74036. */
  74037. updateSpeed: number;
  74038. /**
  74039. * The amount of time the particle system is running (depends of the overall update speed).
  74040. */
  74041. targetStopDuration: number;
  74042. /**
  74043. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  74044. */
  74045. disposeOnStop: boolean;
  74046. /**
  74047. * Minimum power of emitting particles.
  74048. */
  74049. minEmitPower: number;
  74050. /**
  74051. * Maximum power of emitting particles.
  74052. */
  74053. maxEmitPower: number;
  74054. /**
  74055. * Minimum life time of emitting particles.
  74056. */
  74057. minLifeTime: number;
  74058. /**
  74059. * Maximum life time of emitting particles.
  74060. */
  74061. maxLifeTime: number;
  74062. /**
  74063. * Minimum Size of emitting particles.
  74064. */
  74065. minSize: number;
  74066. /**
  74067. * Maximum Size of emitting particles.
  74068. */
  74069. maxSize: number;
  74070. /**
  74071. * Minimum scale of emitting particles on X axis.
  74072. */
  74073. minScaleX: number;
  74074. /**
  74075. * Maximum scale of emitting particles on X axis.
  74076. */
  74077. maxScaleX: number;
  74078. /**
  74079. * Minimum scale of emitting particles on Y axis.
  74080. */
  74081. minScaleY: number;
  74082. /**
  74083. * Maximum scale of emitting particles on Y axis.
  74084. */
  74085. maxScaleY: number;
  74086. /**
  74087. * Gets or sets the minimal initial rotation in radians.
  74088. */
  74089. minInitialRotation: number;
  74090. /**
  74091. * Gets or sets the maximal initial rotation in radians.
  74092. */
  74093. maxInitialRotation: number;
  74094. /**
  74095. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  74096. */
  74097. minAngularSpeed: number;
  74098. /**
  74099. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  74100. */
  74101. maxAngularSpeed: number;
  74102. /**
  74103. * The texture used to render each particle. (this can be a spritesheet)
  74104. */
  74105. particleTexture: Nullable<Texture>;
  74106. /**
  74107. * The layer mask we are rendering the particles through.
  74108. */
  74109. layerMask: number;
  74110. /**
  74111. * This can help using your own shader to render the particle system.
  74112. * The according effect will be created
  74113. */
  74114. customShader: any;
  74115. /**
  74116. * By default particle system starts as soon as they are created. This prevents the
  74117. * automatic start to happen and let you decide when to start emitting particles.
  74118. */
  74119. preventAutoStart: boolean;
  74120. private _noiseTexture;
  74121. /**
  74122. * Gets or sets a texture used to add random noise to particle positions
  74123. */
  74124. noiseTexture: Nullable<ProceduralTexture>;
  74125. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  74126. noiseStrength: Vector3;
  74127. /**
  74128. * Callback triggered when the particle animation is ending.
  74129. */
  74130. onAnimationEnd: Nullable<() => void>;
  74131. /**
  74132. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  74133. */
  74134. blendMode: number;
  74135. /**
  74136. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  74137. * to override the particles.
  74138. */
  74139. forceDepthWrite: boolean;
  74140. /** 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 */
  74141. preWarmCycles: number;
  74142. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  74143. preWarmStepOffset: number;
  74144. /**
  74145. * 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)
  74146. */
  74147. spriteCellChangeSpeed: number;
  74148. /**
  74149. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  74150. */
  74151. startSpriteCellID: number;
  74152. /**
  74153. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  74154. */
  74155. endSpriteCellID: number;
  74156. /**
  74157. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  74158. */
  74159. spriteCellWidth: number;
  74160. /**
  74161. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  74162. */
  74163. spriteCellHeight: number;
  74164. /**
  74165. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  74166. */
  74167. spriteRandomStartCell: boolean;
  74168. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  74169. translationPivot: Vector2;
  74170. /** @hidden */
  74171. protected _isAnimationSheetEnabled: boolean;
  74172. /**
  74173. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  74174. */
  74175. beginAnimationOnStart: boolean;
  74176. /**
  74177. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  74178. */
  74179. beginAnimationFrom: number;
  74180. /**
  74181. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  74182. */
  74183. beginAnimationTo: number;
  74184. /**
  74185. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  74186. */
  74187. beginAnimationLoop: boolean;
  74188. /**
  74189. * Gets or sets a world offset applied to all particles
  74190. */
  74191. worldOffset: Vector3;
  74192. /**
  74193. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  74194. */
  74195. isAnimationSheetEnabled: boolean;
  74196. /**
  74197. * Get hosting scene
  74198. * @returns the scene
  74199. */
  74200. getScene(): Scene;
  74201. /**
  74202. * You can use gravity if you want to give an orientation to your particles.
  74203. */
  74204. gravity: Vector3;
  74205. protected _colorGradients: Nullable<Array<ColorGradient>>;
  74206. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  74207. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  74208. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  74209. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  74210. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  74211. protected _dragGradients: Nullable<Array<FactorGradient>>;
  74212. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  74213. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  74214. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  74215. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  74216. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  74217. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  74218. /**
  74219. * Defines the delay in milliseconds before starting the system (0 by default)
  74220. */
  74221. startDelay: number;
  74222. /**
  74223. * Gets the current list of drag gradients.
  74224. * You must use addDragGradient and removeDragGradient to udpate this list
  74225. * @returns the list of drag gradients
  74226. */
  74227. getDragGradients(): Nullable<Array<FactorGradient>>;
  74228. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  74229. limitVelocityDamping: number;
  74230. /**
  74231. * Gets the current list of limit velocity gradients.
  74232. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  74233. * @returns the list of limit velocity gradients
  74234. */
  74235. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  74236. /**
  74237. * Gets the current list of color gradients.
  74238. * You must use addColorGradient and removeColorGradient to udpate this list
  74239. * @returns the list of color gradients
  74240. */
  74241. getColorGradients(): Nullable<Array<ColorGradient>>;
  74242. /**
  74243. * Gets the current list of size gradients.
  74244. * You must use addSizeGradient and removeSizeGradient to udpate this list
  74245. * @returns the list of size gradients
  74246. */
  74247. getSizeGradients(): Nullable<Array<FactorGradient>>;
  74248. /**
  74249. * Gets the current list of color remap gradients.
  74250. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  74251. * @returns the list of color remap gradients
  74252. */
  74253. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  74254. /**
  74255. * Gets the current list of alpha remap gradients.
  74256. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  74257. * @returns the list of alpha remap gradients
  74258. */
  74259. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  74260. /**
  74261. * Gets the current list of life time gradients.
  74262. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  74263. * @returns the list of life time gradients
  74264. */
  74265. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  74266. /**
  74267. * Gets the current list of angular speed gradients.
  74268. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  74269. * @returns the list of angular speed gradients
  74270. */
  74271. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  74272. /**
  74273. * Gets the current list of velocity gradients.
  74274. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  74275. * @returns the list of velocity gradients
  74276. */
  74277. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  74278. /**
  74279. * Gets the current list of start size gradients.
  74280. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  74281. * @returns the list of start size gradients
  74282. */
  74283. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  74284. /**
  74285. * Gets the current list of emit rate gradients.
  74286. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  74287. * @returns the list of emit rate gradients
  74288. */
  74289. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  74290. /**
  74291. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74292. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74293. */
  74294. direction1: Vector3;
  74295. /**
  74296. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74297. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74298. */
  74299. direction2: Vector3;
  74300. /**
  74301. * 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.
  74302. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74303. */
  74304. minEmitBox: Vector3;
  74305. /**
  74306. * 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.
  74307. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74308. */
  74309. maxEmitBox: Vector3;
  74310. /**
  74311. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  74312. */
  74313. color1: Color4;
  74314. /**
  74315. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  74316. */
  74317. color2: Color4;
  74318. /**
  74319. * Color the particle will have at the end of its lifetime
  74320. */
  74321. colorDead: Color4;
  74322. /**
  74323. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  74324. */
  74325. textureMask: Color4;
  74326. /**
  74327. * The particle emitter type defines the emitter used by the particle system.
  74328. * It can be for example box, sphere, or cone...
  74329. */
  74330. particleEmitterType: IParticleEmitterType;
  74331. /** @hidden */
  74332. _isSubEmitter: boolean;
  74333. /**
  74334. * Gets or sets the billboard mode to use when isBillboardBased = true.
  74335. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  74336. */
  74337. billboardMode: number;
  74338. protected _isBillboardBased: boolean;
  74339. /**
  74340. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  74341. */
  74342. isBillboardBased: boolean;
  74343. /**
  74344. * The scene the particle system belongs to.
  74345. */
  74346. protected _scene: Scene;
  74347. /**
  74348. * Local cache of defines for image processing.
  74349. */
  74350. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  74351. /**
  74352. * Default configuration related to image processing available in the standard Material.
  74353. */
  74354. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  74355. /**
  74356. * Gets the image processing configuration used either in this material.
  74357. */
  74358. /**
  74359. * Sets the Default image processing configuration used either in the this material.
  74360. *
  74361. * If sets to null, the scene one is in use.
  74362. */
  74363. imageProcessingConfiguration: ImageProcessingConfiguration;
  74364. /**
  74365. * Attaches a new image processing configuration to the Standard Material.
  74366. * @param configuration
  74367. */
  74368. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  74369. /** @hidden */
  74370. protected _reset(): void;
  74371. /** @hidden */
  74372. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  74373. /**
  74374. * Instantiates a particle system.
  74375. * 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.
  74376. * @param name The name of the particle system
  74377. */
  74378. constructor(name: string);
  74379. /**
  74380. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  74381. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74382. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74383. * @returns the emitter
  74384. */
  74385. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  74386. /**
  74387. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  74388. * @param radius The radius of the hemisphere to emit from
  74389. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74390. * @returns the emitter
  74391. */
  74392. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  74393. /**
  74394. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  74395. * @param radius The radius of the sphere to emit from
  74396. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74397. * @returns the emitter
  74398. */
  74399. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  74400. /**
  74401. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  74402. * @param radius The radius of the sphere to emit from
  74403. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  74404. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  74405. * @returns the emitter
  74406. */
  74407. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  74408. /**
  74409. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  74410. * @param radius The radius of the emission cylinder
  74411. * @param height The height of the emission cylinder
  74412. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  74413. * @param directionRandomizer How much to randomize the particle direction [0-1]
  74414. * @returns the emitter
  74415. */
  74416. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  74417. /**
  74418. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  74419. * @param radius The radius of the cylinder to emit from
  74420. * @param height The height of the emission cylinder
  74421. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74422. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  74423. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  74424. * @returns the emitter
  74425. */
  74426. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  74427. /**
  74428. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  74429. * @param radius The radius of the cone to emit from
  74430. * @param angle The base angle of the cone
  74431. * @returns the emitter
  74432. */
  74433. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  74434. /**
  74435. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  74436. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74437. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74438. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74439. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74440. * @returns the emitter
  74441. */
  74442. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  74443. }
  74444. }
  74445. declare module BABYLON {
  74446. /**
  74447. * Type of sub emitter
  74448. */
  74449. export enum SubEmitterType {
  74450. /**
  74451. * Attached to the particle over it's lifetime
  74452. */
  74453. ATTACHED = 0,
  74454. /**
  74455. * Created when the particle dies
  74456. */
  74457. END = 1
  74458. }
  74459. /**
  74460. * Sub emitter class used to emit particles from an existing particle
  74461. */
  74462. export class SubEmitter {
  74463. /**
  74464. * the particle system to be used by the sub emitter
  74465. */
  74466. particleSystem: ParticleSystem;
  74467. /**
  74468. * Type of the submitter (Default: END)
  74469. */
  74470. type: SubEmitterType;
  74471. /**
  74472. * 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)
  74473. * Note: This only is supported when using an emitter of type Mesh
  74474. */
  74475. inheritDirection: boolean;
  74476. /**
  74477. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  74478. */
  74479. inheritedVelocityAmount: number;
  74480. /**
  74481. * Creates a sub emitter
  74482. * @param particleSystem the particle system to be used by the sub emitter
  74483. */
  74484. constructor(
  74485. /**
  74486. * the particle system to be used by the sub emitter
  74487. */
  74488. particleSystem: ParticleSystem);
  74489. /**
  74490. * Clones the sub emitter
  74491. * @returns the cloned sub emitter
  74492. */
  74493. clone(): SubEmitter;
  74494. /**
  74495. * Serialize current object to a JSON object
  74496. * @returns the serialized object
  74497. */
  74498. serialize(): any;
  74499. /** @hidden */
  74500. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  74501. /**
  74502. * Creates a new SubEmitter from a serialized JSON version
  74503. * @param serializationObject defines the JSON object to read from
  74504. * @param scene defines the hosting scene
  74505. * @param rootUrl defines the rootUrl for data loading
  74506. * @returns a new SubEmitter
  74507. */
  74508. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  74509. /** Release associated resources */
  74510. dispose(): void;
  74511. }
  74512. }
  74513. declare module BABYLON {
  74514. /** @hidden */
  74515. export var clipPlaneFragmentDeclaration: {
  74516. name: string;
  74517. shader: string;
  74518. };
  74519. }
  74520. declare module BABYLON {
  74521. /** @hidden */
  74522. export var imageProcessingDeclaration: {
  74523. name: string;
  74524. shader: string;
  74525. };
  74526. }
  74527. declare module BABYLON {
  74528. /** @hidden */
  74529. export var imageProcessingFunctions: {
  74530. name: string;
  74531. shader: string;
  74532. };
  74533. }
  74534. declare module BABYLON {
  74535. /** @hidden */
  74536. export var clipPlaneFragment: {
  74537. name: string;
  74538. shader: string;
  74539. };
  74540. }
  74541. declare module BABYLON {
  74542. /** @hidden */
  74543. export var particlesPixelShader: {
  74544. name: string;
  74545. shader: string;
  74546. };
  74547. }
  74548. declare module BABYLON {
  74549. /** @hidden */
  74550. export var clipPlaneVertexDeclaration: {
  74551. name: string;
  74552. shader: string;
  74553. };
  74554. }
  74555. declare module BABYLON {
  74556. /** @hidden */
  74557. export var clipPlaneVertex: {
  74558. name: string;
  74559. shader: string;
  74560. };
  74561. }
  74562. declare module BABYLON {
  74563. /** @hidden */
  74564. export var particlesVertexShader: {
  74565. name: string;
  74566. shader: string;
  74567. };
  74568. }
  74569. declare module BABYLON {
  74570. /**
  74571. * This represents a particle system in Babylon.
  74572. * 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.
  74573. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74574. * @example https://doc.babylonjs.com/babylon101/particles
  74575. */
  74576. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  74577. /**
  74578. * Billboard mode will only apply to Y axis
  74579. */
  74580. static readonly BILLBOARDMODE_Y: number;
  74581. /**
  74582. * Billboard mode will apply to all axes
  74583. */
  74584. static readonly BILLBOARDMODE_ALL: number;
  74585. /**
  74586. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74587. */
  74588. static readonly BILLBOARDMODE_STRETCHED: number;
  74589. /**
  74590. * This function can be defined to provide custom update for active particles.
  74591. * This function will be called instead of regular update (age, position, color, etc.).
  74592. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  74593. */
  74594. updateFunction: (particles: Particle[]) => void;
  74595. private _emitterWorldMatrix;
  74596. /**
  74597. * This function can be defined to specify initial direction for every new particle.
  74598. * It by default use the emitterType defined function
  74599. */
  74600. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  74601. /**
  74602. * This function can be defined to specify initial position for every new particle.
  74603. * It by default use the emitterType defined function
  74604. */
  74605. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  74606. /**
  74607. * @hidden
  74608. */
  74609. _inheritedVelocityOffset: Vector3;
  74610. /**
  74611. * An event triggered when the system is disposed
  74612. */
  74613. onDisposeObservable: Observable<ParticleSystem>;
  74614. private _onDisposeObserver;
  74615. /**
  74616. * Sets a callback that will be triggered when the system is disposed
  74617. */
  74618. onDispose: () => void;
  74619. private _particles;
  74620. private _epsilon;
  74621. private _capacity;
  74622. private _stockParticles;
  74623. private _newPartsExcess;
  74624. private _vertexData;
  74625. private _vertexBuffer;
  74626. private _vertexBuffers;
  74627. private _spriteBuffer;
  74628. private _indexBuffer;
  74629. private _effect;
  74630. private _customEffect;
  74631. private _cachedDefines;
  74632. private _scaledColorStep;
  74633. private _colorDiff;
  74634. private _scaledDirection;
  74635. private _scaledGravity;
  74636. private _currentRenderId;
  74637. private _alive;
  74638. private _useInstancing;
  74639. private _started;
  74640. private _stopped;
  74641. private _actualFrame;
  74642. private _scaledUpdateSpeed;
  74643. private _vertexBufferSize;
  74644. /** @hidden */
  74645. _currentEmitRateGradient: Nullable<FactorGradient>;
  74646. /** @hidden */
  74647. _currentEmitRate1: number;
  74648. /** @hidden */
  74649. _currentEmitRate2: number;
  74650. /** @hidden */
  74651. _currentStartSizeGradient: Nullable<FactorGradient>;
  74652. /** @hidden */
  74653. _currentStartSize1: number;
  74654. /** @hidden */
  74655. _currentStartSize2: number;
  74656. private readonly _rawTextureWidth;
  74657. private _rampGradientsTexture;
  74658. private _useRampGradients;
  74659. /** Gets or sets a boolean indicating that ramp gradients must be used
  74660. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  74661. */
  74662. useRampGradients: boolean;
  74663. /**
  74664. * 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.
  74665. * 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: [])
  74666. */
  74667. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  74668. private _subEmitters;
  74669. /**
  74670. * @hidden
  74671. * If the particle systems emitter should be disposed when the particle system is disposed
  74672. */
  74673. _disposeEmitterOnDispose: boolean;
  74674. /**
  74675. * The current active Sub-systems, this property is used by the root particle system only.
  74676. */
  74677. activeSubSystems: Array<ParticleSystem>;
  74678. private _rootParticleSystem;
  74679. /**
  74680. * Gets the current list of active particles
  74681. */
  74682. readonly particles: Particle[];
  74683. /**
  74684. * Returns the string "ParticleSystem"
  74685. * @returns a string containing the class name
  74686. */
  74687. getClassName(): string;
  74688. /**
  74689. * Instantiates a particle system.
  74690. * 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.
  74691. * @param name The name of the particle system
  74692. * @param capacity The max number of particles alive at the same time
  74693. * @param scene The scene the particle system belongs to
  74694. * @param customEffect a custom effect used to change the way particles are rendered by default
  74695. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  74696. * @param epsilon Offset used to render the particles
  74697. */
  74698. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  74699. private _addFactorGradient;
  74700. private _removeFactorGradient;
  74701. /**
  74702. * Adds a new life time gradient
  74703. * @param gradient defines the gradient to use (between 0 and 1)
  74704. * @param factor defines the life time factor to affect to the specified gradient
  74705. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74706. * @returns the current particle system
  74707. */
  74708. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74709. /**
  74710. * Remove a specific life time gradient
  74711. * @param gradient defines the gradient to remove
  74712. * @returns the current particle system
  74713. */
  74714. removeLifeTimeGradient(gradient: number): IParticleSystem;
  74715. /**
  74716. * Adds a new size gradient
  74717. * @param gradient defines the gradient to use (between 0 and 1)
  74718. * @param factor defines the size factor to affect to the specified gradient
  74719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74720. * @returns the current particle system
  74721. */
  74722. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74723. /**
  74724. * Remove a specific size gradient
  74725. * @param gradient defines the gradient to remove
  74726. * @returns the current particle system
  74727. */
  74728. removeSizeGradient(gradient: number): IParticleSystem;
  74729. /**
  74730. * Adds a new color remap gradient
  74731. * @param gradient defines the gradient to use (between 0 and 1)
  74732. * @param min defines the color remap minimal range
  74733. * @param max defines the color remap maximal range
  74734. * @returns the current particle system
  74735. */
  74736. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74737. /**
  74738. * Remove a specific color remap gradient
  74739. * @param gradient defines the gradient to remove
  74740. * @returns the current particle system
  74741. */
  74742. removeColorRemapGradient(gradient: number): IParticleSystem;
  74743. /**
  74744. * Adds a new alpha remap gradient
  74745. * @param gradient defines the gradient to use (between 0 and 1)
  74746. * @param min defines the alpha remap minimal range
  74747. * @param max defines the alpha remap maximal range
  74748. * @returns the current particle system
  74749. */
  74750. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74751. /**
  74752. * Remove a specific alpha remap gradient
  74753. * @param gradient defines the gradient to remove
  74754. * @returns the current particle system
  74755. */
  74756. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  74757. /**
  74758. * Adds a new angular speed gradient
  74759. * @param gradient defines the gradient to use (between 0 and 1)
  74760. * @param factor defines the angular speed to affect to the specified gradient
  74761. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74762. * @returns the current particle system
  74763. */
  74764. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74765. /**
  74766. * Remove a specific angular speed gradient
  74767. * @param gradient defines the gradient to remove
  74768. * @returns the current particle system
  74769. */
  74770. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  74771. /**
  74772. * Adds a new velocity gradient
  74773. * @param gradient defines the gradient to use (between 0 and 1)
  74774. * @param factor defines the velocity to affect to the specified gradient
  74775. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74776. * @returns the current particle system
  74777. */
  74778. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74779. /**
  74780. * Remove a specific velocity gradient
  74781. * @param gradient defines the gradient to remove
  74782. * @returns the current particle system
  74783. */
  74784. removeVelocityGradient(gradient: number): IParticleSystem;
  74785. /**
  74786. * Adds a new limit velocity gradient
  74787. * @param gradient defines the gradient to use (between 0 and 1)
  74788. * @param factor defines the limit velocity value to affect to the specified gradient
  74789. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74790. * @returns the current particle system
  74791. */
  74792. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74793. /**
  74794. * Remove a specific limit velocity gradient
  74795. * @param gradient defines the gradient to remove
  74796. * @returns the current particle system
  74797. */
  74798. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  74799. /**
  74800. * Adds a new drag gradient
  74801. * @param gradient defines the gradient to use (between 0 and 1)
  74802. * @param factor defines the drag value to affect to the specified gradient
  74803. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74804. * @returns the current particle system
  74805. */
  74806. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74807. /**
  74808. * Remove a specific drag gradient
  74809. * @param gradient defines the gradient to remove
  74810. * @returns the current particle system
  74811. */
  74812. removeDragGradient(gradient: number): IParticleSystem;
  74813. /**
  74814. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  74815. * @param gradient defines the gradient to use (between 0 and 1)
  74816. * @param factor defines the emit rate value to affect to the specified gradient
  74817. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74818. * @returns the current particle system
  74819. */
  74820. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74821. /**
  74822. * Remove a specific emit rate gradient
  74823. * @param gradient defines the gradient to remove
  74824. * @returns the current particle system
  74825. */
  74826. removeEmitRateGradient(gradient: number): IParticleSystem;
  74827. /**
  74828. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  74829. * @param gradient defines the gradient to use (between 0 and 1)
  74830. * @param factor defines the start size value to affect to the specified gradient
  74831. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74832. * @returns the current particle system
  74833. */
  74834. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74835. /**
  74836. * Remove a specific start size gradient
  74837. * @param gradient defines the gradient to remove
  74838. * @returns the current particle system
  74839. */
  74840. removeStartSizeGradient(gradient: number): IParticleSystem;
  74841. private _createRampGradientTexture;
  74842. /**
  74843. * Gets the current list of ramp gradients.
  74844. * You must use addRampGradient and removeRampGradient to udpate this list
  74845. * @returns the list of ramp gradients
  74846. */
  74847. getRampGradients(): Nullable<Array<Color3Gradient>>;
  74848. /**
  74849. * Adds a new ramp gradient used to remap particle colors
  74850. * @param gradient defines the gradient to use (between 0 and 1)
  74851. * @param color defines the color to affect to the specified gradient
  74852. * @returns the current particle system
  74853. */
  74854. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  74855. /**
  74856. * Remove a specific ramp gradient
  74857. * @param gradient defines the gradient to remove
  74858. * @returns the current particle system
  74859. */
  74860. removeRampGradient(gradient: number): ParticleSystem;
  74861. /**
  74862. * Adds a new color gradient
  74863. * @param gradient defines the gradient to use (between 0 and 1)
  74864. * @param color1 defines the color to affect to the specified gradient
  74865. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  74866. * @returns this particle system
  74867. */
  74868. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  74869. /**
  74870. * Remove a specific color gradient
  74871. * @param gradient defines the gradient to remove
  74872. * @returns this particle system
  74873. */
  74874. removeColorGradient(gradient: number): IParticleSystem;
  74875. private _fetchR;
  74876. protected _reset(): void;
  74877. private _resetEffect;
  74878. private _createVertexBuffers;
  74879. private _createIndexBuffer;
  74880. /**
  74881. * Gets the maximum number of particles active at the same time.
  74882. * @returns The max number of active particles.
  74883. */
  74884. getCapacity(): number;
  74885. /**
  74886. * Gets whether there are still active particles in the system.
  74887. * @returns True if it is alive, otherwise false.
  74888. */
  74889. isAlive(): boolean;
  74890. /**
  74891. * Gets if the system has been started. (Note: this will still be true after stop is called)
  74892. * @returns True if it has been started, otherwise false.
  74893. */
  74894. isStarted(): boolean;
  74895. private _prepareSubEmitterInternalArray;
  74896. /**
  74897. * Starts the particle system and begins to emit
  74898. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  74899. */
  74900. start(delay?: number): void;
  74901. /**
  74902. * Stops the particle system.
  74903. * @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.
  74904. */
  74905. stop(stopSubEmitters?: boolean): void;
  74906. /**
  74907. * Remove all active particles
  74908. */
  74909. reset(): void;
  74910. /**
  74911. * @hidden (for internal use only)
  74912. */
  74913. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  74914. /**
  74915. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  74916. * Its lifetime will start back at 0.
  74917. */
  74918. recycleParticle: (particle: Particle) => void;
  74919. private _stopSubEmitters;
  74920. private _createParticle;
  74921. private _removeFromRoot;
  74922. private _emitFromParticle;
  74923. private _update;
  74924. /** @hidden */
  74925. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  74926. /** @hidden */
  74927. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  74928. /** @hidden */
  74929. private _getEffect;
  74930. /**
  74931. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  74932. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  74933. */
  74934. animate(preWarmOnly?: boolean): void;
  74935. private _appendParticleVertices;
  74936. /**
  74937. * Rebuilds the particle system.
  74938. */
  74939. rebuild(): void;
  74940. /**
  74941. * Is this system ready to be used/rendered
  74942. * @return true if the system is ready
  74943. */
  74944. isReady(): boolean;
  74945. private _render;
  74946. /**
  74947. * Renders the particle system in its current state.
  74948. * @returns the current number of particles
  74949. */
  74950. render(): number;
  74951. /**
  74952. * Disposes the particle system and free the associated resources
  74953. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  74954. */
  74955. dispose(disposeTexture?: boolean): void;
  74956. /**
  74957. * Clones the particle system.
  74958. * @param name The name of the cloned object
  74959. * @param newEmitter The new emitter to use
  74960. * @returns the cloned particle system
  74961. */
  74962. clone(name: string, newEmitter: any): ParticleSystem;
  74963. /**
  74964. * Serializes the particle system to a JSON object.
  74965. * @returns the JSON object
  74966. */
  74967. serialize(): any;
  74968. /** @hidden */
  74969. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  74970. /** @hidden */
  74971. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  74972. /**
  74973. * Parses a JSON object to create a particle system.
  74974. * @param parsedParticleSystem The JSON object to parse
  74975. * @param scene The scene to create the particle system in
  74976. * @param rootUrl The root url to use to load external dependencies like texture
  74977. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  74978. * @returns the Parsed particle system
  74979. */
  74980. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  74981. }
  74982. }
  74983. declare module BABYLON {
  74984. /**
  74985. * A particle represents one of the element emitted by a particle system.
  74986. * This is mainly define by its coordinates, direction, velocity and age.
  74987. */
  74988. export class Particle {
  74989. /**
  74990. * The particle system the particle belongs to.
  74991. */
  74992. particleSystem: ParticleSystem;
  74993. private static _Count;
  74994. /**
  74995. * Unique ID of the particle
  74996. */
  74997. id: number;
  74998. /**
  74999. * The world position of the particle in the scene.
  75000. */
  75001. position: Vector3;
  75002. /**
  75003. * The world direction of the particle in the scene.
  75004. */
  75005. direction: Vector3;
  75006. /**
  75007. * The color of the particle.
  75008. */
  75009. color: Color4;
  75010. /**
  75011. * The color change of the particle per step.
  75012. */
  75013. colorStep: Color4;
  75014. /**
  75015. * Defines how long will the life of the particle be.
  75016. */
  75017. lifeTime: number;
  75018. /**
  75019. * The current age of the particle.
  75020. */
  75021. age: number;
  75022. /**
  75023. * The current size of the particle.
  75024. */
  75025. size: number;
  75026. /**
  75027. * The current scale of the particle.
  75028. */
  75029. scale: Vector2;
  75030. /**
  75031. * The current angle of the particle.
  75032. */
  75033. angle: number;
  75034. /**
  75035. * Defines how fast is the angle changing.
  75036. */
  75037. angularSpeed: number;
  75038. /**
  75039. * Defines the cell index used by the particle to be rendered from a sprite.
  75040. */
  75041. cellIndex: number;
  75042. /**
  75043. * The information required to support color remapping
  75044. */
  75045. remapData: Vector4;
  75046. /** @hidden */
  75047. _randomCellOffset?: number;
  75048. /** @hidden */
  75049. _initialDirection: Nullable<Vector3>;
  75050. /** @hidden */
  75051. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  75052. /** @hidden */
  75053. _initialStartSpriteCellID: number;
  75054. /** @hidden */
  75055. _initialEndSpriteCellID: number;
  75056. /** @hidden */
  75057. _currentColorGradient: Nullable<ColorGradient>;
  75058. /** @hidden */
  75059. _currentColor1: Color4;
  75060. /** @hidden */
  75061. _currentColor2: Color4;
  75062. /** @hidden */
  75063. _currentSizeGradient: Nullable<FactorGradient>;
  75064. /** @hidden */
  75065. _currentSize1: number;
  75066. /** @hidden */
  75067. _currentSize2: number;
  75068. /** @hidden */
  75069. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  75070. /** @hidden */
  75071. _currentAngularSpeed1: number;
  75072. /** @hidden */
  75073. _currentAngularSpeed2: number;
  75074. /** @hidden */
  75075. _currentVelocityGradient: Nullable<FactorGradient>;
  75076. /** @hidden */
  75077. _currentVelocity1: number;
  75078. /** @hidden */
  75079. _currentVelocity2: number;
  75080. /** @hidden */
  75081. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  75082. /** @hidden */
  75083. _currentLimitVelocity1: number;
  75084. /** @hidden */
  75085. _currentLimitVelocity2: number;
  75086. /** @hidden */
  75087. _currentDragGradient: Nullable<FactorGradient>;
  75088. /** @hidden */
  75089. _currentDrag1: number;
  75090. /** @hidden */
  75091. _currentDrag2: number;
  75092. /** @hidden */
  75093. _randomNoiseCoordinates1: Vector3;
  75094. /** @hidden */
  75095. _randomNoiseCoordinates2: Vector3;
  75096. /**
  75097. * Creates a new instance Particle
  75098. * @param particleSystem the particle system the particle belongs to
  75099. */
  75100. constructor(
  75101. /**
  75102. * The particle system the particle belongs to.
  75103. */
  75104. particleSystem: ParticleSystem);
  75105. private updateCellInfoFromSystem;
  75106. /**
  75107. * Defines how the sprite cell index is updated for the particle
  75108. */
  75109. updateCellIndex(): void;
  75110. /** @hidden */
  75111. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  75112. /** @hidden */
  75113. _inheritParticleInfoToSubEmitters(): void;
  75114. /** @hidden */
  75115. _reset(): void;
  75116. /**
  75117. * Copy the properties of particle to another one.
  75118. * @param other the particle to copy the information to.
  75119. */
  75120. copyTo(other: Particle): void;
  75121. }
  75122. }
  75123. declare module BABYLON {
  75124. /**
  75125. * Particle emitter represents a volume emitting particles.
  75126. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  75127. */
  75128. export interface IParticleEmitterType {
  75129. /**
  75130. * Called by the particle System when the direction is computed for the created particle.
  75131. * @param worldMatrix is the world matrix of the particle system
  75132. * @param directionToUpdate is the direction vector to update with the result
  75133. * @param particle is the particle we are computed the direction for
  75134. */
  75135. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75136. /**
  75137. * Called by the particle System when the position is computed for the created particle.
  75138. * @param worldMatrix is the world matrix of the particle system
  75139. * @param positionToUpdate is the position vector to update with the result
  75140. * @param particle is the particle we are computed the position for
  75141. */
  75142. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75143. /**
  75144. * Clones the current emitter and returns a copy of it
  75145. * @returns the new emitter
  75146. */
  75147. clone(): IParticleEmitterType;
  75148. /**
  75149. * Called by the GPUParticleSystem to setup the update shader
  75150. * @param effect defines the update shader
  75151. */
  75152. applyToShader(effect: Effect): void;
  75153. /**
  75154. * Returns a string to use to update the GPU particles update shader
  75155. * @returns the effect defines string
  75156. */
  75157. getEffectDefines(): string;
  75158. /**
  75159. * Returns a string representing the class name
  75160. * @returns a string containing the class name
  75161. */
  75162. getClassName(): string;
  75163. /**
  75164. * Serializes the particle system to a JSON object.
  75165. * @returns the JSON object
  75166. */
  75167. serialize(): any;
  75168. /**
  75169. * Parse properties from a JSON object
  75170. * @param serializationObject defines the JSON object
  75171. */
  75172. parse(serializationObject: any): void;
  75173. }
  75174. }
  75175. declare module BABYLON {
  75176. /**
  75177. * Particle emitter emitting particles from the inside of a box.
  75178. * It emits the particles randomly between 2 given directions.
  75179. */
  75180. export class BoxParticleEmitter implements IParticleEmitterType {
  75181. /**
  75182. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75183. */
  75184. direction1: Vector3;
  75185. /**
  75186. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75187. */
  75188. direction2: Vector3;
  75189. /**
  75190. * 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.
  75191. */
  75192. minEmitBox: Vector3;
  75193. /**
  75194. * 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.
  75195. */
  75196. maxEmitBox: Vector3;
  75197. /**
  75198. * Creates a new instance BoxParticleEmitter
  75199. */
  75200. constructor();
  75201. /**
  75202. * Called by the particle System when the direction is computed for the created particle.
  75203. * @param worldMatrix is the world matrix of the particle system
  75204. * @param directionToUpdate is the direction vector to update with the result
  75205. * @param particle is the particle we are computed the direction for
  75206. */
  75207. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75208. /**
  75209. * Called by the particle System when the position is computed for the created particle.
  75210. * @param worldMatrix is the world matrix of the particle system
  75211. * @param positionToUpdate is the position vector to update with the result
  75212. * @param particle is the particle we are computed the position for
  75213. */
  75214. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75215. /**
  75216. * Clones the current emitter and returns a copy of it
  75217. * @returns the new emitter
  75218. */
  75219. clone(): BoxParticleEmitter;
  75220. /**
  75221. * Called by the GPUParticleSystem to setup the update shader
  75222. * @param effect defines the update shader
  75223. */
  75224. applyToShader(effect: Effect): void;
  75225. /**
  75226. * Returns a string to use to update the GPU particles update shader
  75227. * @returns a string containng the defines string
  75228. */
  75229. getEffectDefines(): string;
  75230. /**
  75231. * Returns the string "BoxParticleEmitter"
  75232. * @returns a string containing the class name
  75233. */
  75234. getClassName(): string;
  75235. /**
  75236. * Serializes the particle system to a JSON object.
  75237. * @returns the JSON object
  75238. */
  75239. serialize(): any;
  75240. /**
  75241. * Parse properties from a JSON object
  75242. * @param serializationObject defines the JSON object
  75243. */
  75244. parse(serializationObject: any): void;
  75245. }
  75246. }
  75247. declare module BABYLON {
  75248. /**
  75249. * Particle emitter emitting particles from the inside of a cone.
  75250. * It emits the particles alongside the cone volume from the base to the particle.
  75251. * The emission direction might be randomized.
  75252. */
  75253. export class ConeParticleEmitter implements IParticleEmitterType {
  75254. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  75255. directionRandomizer: number;
  75256. private _radius;
  75257. private _angle;
  75258. private _height;
  75259. /**
  75260. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  75261. */
  75262. radiusRange: number;
  75263. /**
  75264. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  75265. */
  75266. heightRange: number;
  75267. /**
  75268. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  75269. */
  75270. emitFromSpawnPointOnly: boolean;
  75271. /**
  75272. * Gets or sets the radius of the emission cone
  75273. */
  75274. radius: number;
  75275. /**
  75276. * Gets or sets the angle of the emission cone
  75277. */
  75278. angle: number;
  75279. private _buildHeight;
  75280. /**
  75281. * Creates a new instance ConeParticleEmitter
  75282. * @param radius the radius of the emission cone (1 by default)
  75283. * @param angle the cone base angle (PI by default)
  75284. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  75285. */
  75286. constructor(radius?: number, angle?: number,
  75287. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  75288. directionRandomizer?: number);
  75289. /**
  75290. * Called by the particle System when the direction is computed for the created particle.
  75291. * @param worldMatrix is the world matrix of the particle system
  75292. * @param directionToUpdate is the direction vector to update with the result
  75293. * @param particle is the particle we are computed the direction for
  75294. */
  75295. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75296. /**
  75297. * Called by the particle System when the position is computed for the created particle.
  75298. * @param worldMatrix is the world matrix of the particle system
  75299. * @param positionToUpdate is the position vector to update with the result
  75300. * @param particle is the particle we are computed the position for
  75301. */
  75302. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75303. /**
  75304. * Clones the current emitter and returns a copy of it
  75305. * @returns the new emitter
  75306. */
  75307. clone(): ConeParticleEmitter;
  75308. /**
  75309. * Called by the GPUParticleSystem to setup the update shader
  75310. * @param effect defines the update shader
  75311. */
  75312. applyToShader(effect: Effect): void;
  75313. /**
  75314. * Returns a string to use to update the GPU particles update shader
  75315. * @returns a string containng the defines string
  75316. */
  75317. getEffectDefines(): string;
  75318. /**
  75319. * Returns the string "ConeParticleEmitter"
  75320. * @returns a string containing the class name
  75321. */
  75322. getClassName(): string;
  75323. /**
  75324. * Serializes the particle system to a JSON object.
  75325. * @returns the JSON object
  75326. */
  75327. serialize(): any;
  75328. /**
  75329. * Parse properties from a JSON object
  75330. * @param serializationObject defines the JSON object
  75331. */
  75332. parse(serializationObject: any): void;
  75333. }
  75334. }
  75335. declare module BABYLON {
  75336. /**
  75337. * Particle emitter emitting particles from the inside of a cylinder.
  75338. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  75339. */
  75340. export class CylinderParticleEmitter implements IParticleEmitterType {
  75341. /**
  75342. * The radius of the emission cylinder.
  75343. */
  75344. radius: number;
  75345. /**
  75346. * The height of the emission cylinder.
  75347. */
  75348. height: number;
  75349. /**
  75350. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75351. */
  75352. radiusRange: number;
  75353. /**
  75354. * How much to randomize the particle direction [0-1].
  75355. */
  75356. directionRandomizer: number;
  75357. /**
  75358. * Creates a new instance CylinderParticleEmitter
  75359. * @param radius the radius of the emission cylinder (1 by default)
  75360. * @param height the height of the emission cylinder (1 by default)
  75361. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75362. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75363. */
  75364. constructor(
  75365. /**
  75366. * The radius of the emission cylinder.
  75367. */
  75368. radius?: number,
  75369. /**
  75370. * The height of the emission cylinder.
  75371. */
  75372. height?: number,
  75373. /**
  75374. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75375. */
  75376. radiusRange?: number,
  75377. /**
  75378. * How much to randomize the particle direction [0-1].
  75379. */
  75380. directionRandomizer?: number);
  75381. /**
  75382. * Called by the particle System when the direction is computed for the created particle.
  75383. * @param worldMatrix is the world matrix of the particle system
  75384. * @param directionToUpdate is the direction vector to update with the result
  75385. * @param particle is the particle we are computed the direction for
  75386. */
  75387. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75388. /**
  75389. * Called by the particle System when the position is computed for the created particle.
  75390. * @param worldMatrix is the world matrix of the particle system
  75391. * @param positionToUpdate is the position vector to update with the result
  75392. * @param particle is the particle we are computed the position for
  75393. */
  75394. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75395. /**
  75396. * Clones the current emitter and returns a copy of it
  75397. * @returns the new emitter
  75398. */
  75399. clone(): CylinderParticleEmitter;
  75400. /**
  75401. * Called by the GPUParticleSystem to setup the update shader
  75402. * @param effect defines the update shader
  75403. */
  75404. applyToShader(effect: Effect): void;
  75405. /**
  75406. * Returns a string to use to update the GPU particles update shader
  75407. * @returns a string containng the defines string
  75408. */
  75409. getEffectDefines(): string;
  75410. /**
  75411. * Returns the string "CylinderParticleEmitter"
  75412. * @returns a string containing the class name
  75413. */
  75414. getClassName(): string;
  75415. /**
  75416. * Serializes the particle system to a JSON object.
  75417. * @returns the JSON object
  75418. */
  75419. serialize(): any;
  75420. /**
  75421. * Parse properties from a JSON object
  75422. * @param serializationObject defines the JSON object
  75423. */
  75424. parse(serializationObject: any): void;
  75425. }
  75426. /**
  75427. * Particle emitter emitting particles from the inside of a cylinder.
  75428. * It emits the particles randomly between two vectors.
  75429. */
  75430. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  75431. /**
  75432. * The min limit of the emission direction.
  75433. */
  75434. direction1: Vector3;
  75435. /**
  75436. * The max limit of the emission direction.
  75437. */
  75438. direction2: Vector3;
  75439. /**
  75440. * Creates a new instance CylinderDirectedParticleEmitter
  75441. * @param radius the radius of the emission cylinder (1 by default)
  75442. * @param height the height of the emission cylinder (1 by default)
  75443. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75444. * @param direction1 the min limit of the emission direction (up vector by default)
  75445. * @param direction2 the max limit of the emission direction (up vector by default)
  75446. */
  75447. constructor(radius?: number, height?: number, radiusRange?: number,
  75448. /**
  75449. * The min limit of the emission direction.
  75450. */
  75451. direction1?: Vector3,
  75452. /**
  75453. * The max limit of the emission direction.
  75454. */
  75455. direction2?: Vector3);
  75456. /**
  75457. * Called by the particle System when the direction is computed for the created particle.
  75458. * @param worldMatrix is the world matrix of the particle system
  75459. * @param directionToUpdate is the direction vector to update with the result
  75460. * @param particle is the particle we are computed the direction for
  75461. */
  75462. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75463. /**
  75464. * Clones the current emitter and returns a copy of it
  75465. * @returns the new emitter
  75466. */
  75467. clone(): CylinderDirectedParticleEmitter;
  75468. /**
  75469. * Called by the GPUParticleSystem to setup the update shader
  75470. * @param effect defines the update shader
  75471. */
  75472. applyToShader(effect: Effect): void;
  75473. /**
  75474. * Returns a string to use to update the GPU particles update shader
  75475. * @returns a string containng the defines string
  75476. */
  75477. getEffectDefines(): string;
  75478. /**
  75479. * Returns the string "CylinderDirectedParticleEmitter"
  75480. * @returns a string containing the class name
  75481. */
  75482. getClassName(): string;
  75483. /**
  75484. * Serializes the particle system to a JSON object.
  75485. * @returns the JSON object
  75486. */
  75487. serialize(): any;
  75488. /**
  75489. * Parse properties from a JSON object
  75490. * @param serializationObject defines the JSON object
  75491. */
  75492. parse(serializationObject: any): void;
  75493. }
  75494. }
  75495. declare module BABYLON {
  75496. /**
  75497. * Particle emitter emitting particles from the inside of a hemisphere.
  75498. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  75499. */
  75500. export class HemisphericParticleEmitter implements IParticleEmitterType {
  75501. /**
  75502. * The radius of the emission hemisphere.
  75503. */
  75504. radius: number;
  75505. /**
  75506. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75507. */
  75508. radiusRange: number;
  75509. /**
  75510. * How much to randomize the particle direction [0-1].
  75511. */
  75512. directionRandomizer: number;
  75513. /**
  75514. * Creates a new instance HemisphericParticleEmitter
  75515. * @param radius the radius of the emission hemisphere (1 by default)
  75516. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75517. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75518. */
  75519. constructor(
  75520. /**
  75521. * The radius of the emission hemisphere.
  75522. */
  75523. radius?: number,
  75524. /**
  75525. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75526. */
  75527. radiusRange?: number,
  75528. /**
  75529. * How much to randomize the particle direction [0-1].
  75530. */
  75531. directionRandomizer?: number);
  75532. /**
  75533. * Called by the particle System when the direction is computed for the created particle.
  75534. * @param worldMatrix is the world matrix of the particle system
  75535. * @param directionToUpdate is the direction vector to update with the result
  75536. * @param particle is the particle we are computed the direction for
  75537. */
  75538. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75539. /**
  75540. * Called by the particle System when the position is computed for the created particle.
  75541. * @param worldMatrix is the world matrix of the particle system
  75542. * @param positionToUpdate is the position vector to update with the result
  75543. * @param particle is the particle we are computed the position for
  75544. */
  75545. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75546. /**
  75547. * Clones the current emitter and returns a copy of it
  75548. * @returns the new emitter
  75549. */
  75550. clone(): HemisphericParticleEmitter;
  75551. /**
  75552. * Called by the GPUParticleSystem to setup the update shader
  75553. * @param effect defines the update shader
  75554. */
  75555. applyToShader(effect: Effect): void;
  75556. /**
  75557. * Returns a string to use to update the GPU particles update shader
  75558. * @returns a string containng the defines string
  75559. */
  75560. getEffectDefines(): string;
  75561. /**
  75562. * Returns the string "HemisphericParticleEmitter"
  75563. * @returns a string containing the class name
  75564. */
  75565. getClassName(): string;
  75566. /**
  75567. * Serializes the particle system to a JSON object.
  75568. * @returns the JSON object
  75569. */
  75570. serialize(): any;
  75571. /**
  75572. * Parse properties from a JSON object
  75573. * @param serializationObject defines the JSON object
  75574. */
  75575. parse(serializationObject: any): void;
  75576. }
  75577. }
  75578. declare module BABYLON {
  75579. /**
  75580. * Particle emitter emitting particles from a point.
  75581. * It emits the particles randomly between 2 given directions.
  75582. */
  75583. export class PointParticleEmitter implements IParticleEmitterType {
  75584. /**
  75585. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75586. */
  75587. direction1: Vector3;
  75588. /**
  75589. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75590. */
  75591. direction2: Vector3;
  75592. /**
  75593. * Creates a new instance PointParticleEmitter
  75594. */
  75595. constructor();
  75596. /**
  75597. * Called by the particle System when the direction is computed for the created particle.
  75598. * @param worldMatrix is the world matrix of the particle system
  75599. * @param directionToUpdate is the direction vector to update with the result
  75600. * @param particle is the particle we are computed the direction for
  75601. */
  75602. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75603. /**
  75604. * Called by the particle System when the position is computed for the created particle.
  75605. * @param worldMatrix is the world matrix of the particle system
  75606. * @param positionToUpdate is the position vector to update with the result
  75607. * @param particle is the particle we are computed the position for
  75608. */
  75609. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75610. /**
  75611. * Clones the current emitter and returns a copy of it
  75612. * @returns the new emitter
  75613. */
  75614. clone(): PointParticleEmitter;
  75615. /**
  75616. * Called by the GPUParticleSystem to setup the update shader
  75617. * @param effect defines the update shader
  75618. */
  75619. applyToShader(effect: Effect): void;
  75620. /**
  75621. * Returns a string to use to update the GPU particles update shader
  75622. * @returns a string containng the defines string
  75623. */
  75624. getEffectDefines(): string;
  75625. /**
  75626. * Returns the string "PointParticleEmitter"
  75627. * @returns a string containing the class name
  75628. */
  75629. getClassName(): string;
  75630. /**
  75631. * Serializes the particle system to a JSON object.
  75632. * @returns the JSON object
  75633. */
  75634. serialize(): any;
  75635. /**
  75636. * Parse properties from a JSON object
  75637. * @param serializationObject defines the JSON object
  75638. */
  75639. parse(serializationObject: any): void;
  75640. }
  75641. }
  75642. declare module BABYLON {
  75643. /**
  75644. * Particle emitter emitting particles from the inside of a sphere.
  75645. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  75646. */
  75647. export class SphereParticleEmitter implements IParticleEmitterType {
  75648. /**
  75649. * The radius of the emission sphere.
  75650. */
  75651. radius: number;
  75652. /**
  75653. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75654. */
  75655. radiusRange: number;
  75656. /**
  75657. * How much to randomize the particle direction [0-1].
  75658. */
  75659. directionRandomizer: number;
  75660. /**
  75661. * Creates a new instance SphereParticleEmitter
  75662. * @param radius the radius of the emission sphere (1 by default)
  75663. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75664. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75665. */
  75666. constructor(
  75667. /**
  75668. * The radius of the emission sphere.
  75669. */
  75670. radius?: number,
  75671. /**
  75672. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75673. */
  75674. radiusRange?: number,
  75675. /**
  75676. * How much to randomize the particle direction [0-1].
  75677. */
  75678. directionRandomizer?: number);
  75679. /**
  75680. * Called by the particle System when the direction is computed for the created particle.
  75681. * @param worldMatrix is the world matrix of the particle system
  75682. * @param directionToUpdate is the direction vector to update with the result
  75683. * @param particle is the particle we are computed the direction for
  75684. */
  75685. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75686. /**
  75687. * Called by the particle System when the position is computed for the created particle.
  75688. * @param worldMatrix is the world matrix of the particle system
  75689. * @param positionToUpdate is the position vector to update with the result
  75690. * @param particle is the particle we are computed the position for
  75691. */
  75692. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75693. /**
  75694. * Clones the current emitter and returns a copy of it
  75695. * @returns the new emitter
  75696. */
  75697. clone(): SphereParticleEmitter;
  75698. /**
  75699. * Called by the GPUParticleSystem to setup the update shader
  75700. * @param effect defines the update shader
  75701. */
  75702. applyToShader(effect: Effect): void;
  75703. /**
  75704. * Returns a string to use to update the GPU particles update shader
  75705. * @returns a string containng the defines string
  75706. */
  75707. getEffectDefines(): string;
  75708. /**
  75709. * Returns the string "SphereParticleEmitter"
  75710. * @returns a string containing the class name
  75711. */
  75712. getClassName(): string;
  75713. /**
  75714. * Serializes the particle system to a JSON object.
  75715. * @returns the JSON object
  75716. */
  75717. serialize(): any;
  75718. /**
  75719. * Parse properties from a JSON object
  75720. * @param serializationObject defines the JSON object
  75721. */
  75722. parse(serializationObject: any): void;
  75723. }
  75724. /**
  75725. * Particle emitter emitting particles from the inside of a sphere.
  75726. * It emits the particles randomly between two vectors.
  75727. */
  75728. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  75729. /**
  75730. * The min limit of the emission direction.
  75731. */
  75732. direction1: Vector3;
  75733. /**
  75734. * The max limit of the emission direction.
  75735. */
  75736. direction2: Vector3;
  75737. /**
  75738. * Creates a new instance SphereDirectedParticleEmitter
  75739. * @param radius the radius of the emission sphere (1 by default)
  75740. * @param direction1 the min limit of the emission direction (up vector by default)
  75741. * @param direction2 the max limit of the emission direction (up vector by default)
  75742. */
  75743. constructor(radius?: number,
  75744. /**
  75745. * The min limit of the emission direction.
  75746. */
  75747. direction1?: Vector3,
  75748. /**
  75749. * The max limit of the emission direction.
  75750. */
  75751. direction2?: Vector3);
  75752. /**
  75753. * Called by the particle System when the direction is computed for the created particle.
  75754. * @param worldMatrix is the world matrix of the particle system
  75755. * @param directionToUpdate is the direction vector to update with the result
  75756. * @param particle is the particle we are computed the direction for
  75757. */
  75758. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75759. /**
  75760. * Clones the current emitter and returns a copy of it
  75761. * @returns the new emitter
  75762. */
  75763. clone(): SphereDirectedParticleEmitter;
  75764. /**
  75765. * Called by the GPUParticleSystem to setup the update shader
  75766. * @param effect defines the update shader
  75767. */
  75768. applyToShader(effect: Effect): void;
  75769. /**
  75770. * Returns a string to use to update the GPU particles update shader
  75771. * @returns a string containng the defines string
  75772. */
  75773. getEffectDefines(): string;
  75774. /**
  75775. * Returns the string "SphereDirectedParticleEmitter"
  75776. * @returns a string containing the class name
  75777. */
  75778. getClassName(): string;
  75779. /**
  75780. * Serializes the particle system to a JSON object.
  75781. * @returns the JSON object
  75782. */
  75783. serialize(): any;
  75784. /**
  75785. * Parse properties from a JSON object
  75786. * @param serializationObject defines the JSON object
  75787. */
  75788. parse(serializationObject: any): void;
  75789. }
  75790. }
  75791. declare module BABYLON {
  75792. /**
  75793. * Interface representing a particle system in Babylon.js.
  75794. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  75795. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  75796. */
  75797. export interface IParticleSystem {
  75798. /**
  75799. * List of animations used by the particle system.
  75800. */
  75801. animations: Animation[];
  75802. /**
  75803. * The id of the Particle system.
  75804. */
  75805. id: string;
  75806. /**
  75807. * The name of the Particle system.
  75808. */
  75809. name: string;
  75810. /**
  75811. * The emitter represents the Mesh or position we are attaching the particle system to.
  75812. */
  75813. emitter: Nullable<AbstractMesh | Vector3>;
  75814. /**
  75815. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  75816. */
  75817. isBillboardBased: boolean;
  75818. /**
  75819. * The rendering group used by the Particle system to chose when to render.
  75820. */
  75821. renderingGroupId: number;
  75822. /**
  75823. * The layer mask we are rendering the particles through.
  75824. */
  75825. layerMask: number;
  75826. /**
  75827. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  75828. */
  75829. updateSpeed: number;
  75830. /**
  75831. * The amount of time the particle system is running (depends of the overall update speed).
  75832. */
  75833. targetStopDuration: number;
  75834. /**
  75835. * The texture used to render each particle. (this can be a spritesheet)
  75836. */
  75837. particleTexture: Nullable<Texture>;
  75838. /**
  75839. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  75840. */
  75841. blendMode: number;
  75842. /**
  75843. * Minimum life time of emitting particles.
  75844. */
  75845. minLifeTime: number;
  75846. /**
  75847. * Maximum life time of emitting particles.
  75848. */
  75849. maxLifeTime: number;
  75850. /**
  75851. * Minimum Size of emitting particles.
  75852. */
  75853. minSize: number;
  75854. /**
  75855. * Maximum Size of emitting particles.
  75856. */
  75857. maxSize: number;
  75858. /**
  75859. * Minimum scale of emitting particles on X axis.
  75860. */
  75861. minScaleX: number;
  75862. /**
  75863. * Maximum scale of emitting particles on X axis.
  75864. */
  75865. maxScaleX: number;
  75866. /**
  75867. * Minimum scale of emitting particles on Y axis.
  75868. */
  75869. minScaleY: number;
  75870. /**
  75871. * Maximum scale of emitting particles on Y axis.
  75872. */
  75873. maxScaleY: number;
  75874. /**
  75875. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  75876. */
  75877. color1: Color4;
  75878. /**
  75879. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  75880. */
  75881. color2: Color4;
  75882. /**
  75883. * Color the particle will have at the end of its lifetime.
  75884. */
  75885. colorDead: Color4;
  75886. /**
  75887. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  75888. */
  75889. emitRate: number;
  75890. /**
  75891. * You can use gravity if you want to give an orientation to your particles.
  75892. */
  75893. gravity: Vector3;
  75894. /**
  75895. * Minimum power of emitting particles.
  75896. */
  75897. minEmitPower: number;
  75898. /**
  75899. * Maximum power of emitting particles.
  75900. */
  75901. maxEmitPower: number;
  75902. /**
  75903. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  75904. */
  75905. minAngularSpeed: number;
  75906. /**
  75907. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  75908. */
  75909. maxAngularSpeed: number;
  75910. /**
  75911. * Gets or sets the minimal initial rotation in radians.
  75912. */
  75913. minInitialRotation: number;
  75914. /**
  75915. * Gets or sets the maximal initial rotation in radians.
  75916. */
  75917. maxInitialRotation: number;
  75918. /**
  75919. * The particle emitter type defines the emitter used by the particle system.
  75920. * It can be for example box, sphere, or cone...
  75921. */
  75922. particleEmitterType: Nullable<IParticleEmitterType>;
  75923. /**
  75924. * Defines the delay in milliseconds before starting the system (0 by default)
  75925. */
  75926. startDelay: number;
  75927. /**
  75928. * 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
  75929. */
  75930. preWarmCycles: number;
  75931. /**
  75932. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  75933. */
  75934. preWarmStepOffset: number;
  75935. /**
  75936. * 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)
  75937. */
  75938. spriteCellChangeSpeed: number;
  75939. /**
  75940. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  75941. */
  75942. startSpriteCellID: number;
  75943. /**
  75944. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  75945. */
  75946. endSpriteCellID: number;
  75947. /**
  75948. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  75949. */
  75950. spriteCellWidth: number;
  75951. /**
  75952. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  75953. */
  75954. spriteCellHeight: number;
  75955. /**
  75956. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  75957. */
  75958. spriteRandomStartCell: boolean;
  75959. /**
  75960. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  75961. */
  75962. isAnimationSheetEnabled: boolean;
  75963. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  75964. translationPivot: Vector2;
  75965. /**
  75966. * Gets or sets a texture used to add random noise to particle positions
  75967. */
  75968. noiseTexture: Nullable<BaseTexture>;
  75969. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  75970. noiseStrength: Vector3;
  75971. /**
  75972. * Gets or sets the billboard mode to use when isBillboardBased = true.
  75973. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  75974. */
  75975. billboardMode: number;
  75976. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  75977. limitVelocityDamping: number;
  75978. /**
  75979. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  75980. */
  75981. beginAnimationOnStart: boolean;
  75982. /**
  75983. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  75984. */
  75985. beginAnimationFrom: number;
  75986. /**
  75987. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  75988. */
  75989. beginAnimationTo: number;
  75990. /**
  75991. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  75992. */
  75993. beginAnimationLoop: boolean;
  75994. /**
  75995. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  75996. */
  75997. disposeOnStop: boolean;
  75998. /**
  75999. * Gets the maximum number of particles active at the same time.
  76000. * @returns The max number of active particles.
  76001. */
  76002. getCapacity(): number;
  76003. /**
  76004. * Gets if the system has been started. (Note: this will still be true after stop is called)
  76005. * @returns True if it has been started, otherwise false.
  76006. */
  76007. isStarted(): boolean;
  76008. /**
  76009. * Animates the particle system for this frame.
  76010. */
  76011. animate(): void;
  76012. /**
  76013. * Renders the particle system in its current state.
  76014. * @returns the current number of particles
  76015. */
  76016. render(): number;
  76017. /**
  76018. * Dispose the particle system and frees its associated resources.
  76019. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  76020. */
  76021. dispose(disposeTexture?: boolean): void;
  76022. /**
  76023. * Clones the particle system.
  76024. * @param name The name of the cloned object
  76025. * @param newEmitter The new emitter to use
  76026. * @returns the cloned particle system
  76027. */
  76028. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  76029. /**
  76030. * Serializes the particle system to a JSON object.
  76031. * @returns the JSON object
  76032. */
  76033. serialize(): any;
  76034. /**
  76035. * Rebuild the particle system
  76036. */
  76037. rebuild(): void;
  76038. /**
  76039. * Starts the particle system and begins to emit
  76040. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  76041. */
  76042. start(delay?: number): void;
  76043. /**
  76044. * Stops the particle system.
  76045. */
  76046. stop(): void;
  76047. /**
  76048. * Remove all active particles
  76049. */
  76050. reset(): void;
  76051. /**
  76052. * Is this system ready to be used/rendered
  76053. * @return true if the system is ready
  76054. */
  76055. isReady(): boolean;
  76056. /**
  76057. * Adds a new color gradient
  76058. * @param gradient defines the gradient to use (between 0 and 1)
  76059. * @param color1 defines the color to affect to the specified gradient
  76060. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  76061. * @returns the current particle system
  76062. */
  76063. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  76064. /**
  76065. * Remove a specific color gradient
  76066. * @param gradient defines the gradient to remove
  76067. * @returns the current particle system
  76068. */
  76069. removeColorGradient(gradient: number): IParticleSystem;
  76070. /**
  76071. * Adds a new size gradient
  76072. * @param gradient defines the gradient to use (between 0 and 1)
  76073. * @param factor defines the size factor to affect to the specified gradient
  76074. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76075. * @returns the current particle system
  76076. */
  76077. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76078. /**
  76079. * Remove a specific size gradient
  76080. * @param gradient defines the gradient to remove
  76081. * @returns the current particle system
  76082. */
  76083. removeSizeGradient(gradient: number): IParticleSystem;
  76084. /**
  76085. * Gets the current list of color gradients.
  76086. * You must use addColorGradient and removeColorGradient to udpate this list
  76087. * @returns the list of color gradients
  76088. */
  76089. getColorGradients(): Nullable<Array<ColorGradient>>;
  76090. /**
  76091. * Gets the current list of size gradients.
  76092. * You must use addSizeGradient and removeSizeGradient to udpate this list
  76093. * @returns the list of size gradients
  76094. */
  76095. getSizeGradients(): Nullable<Array<FactorGradient>>;
  76096. /**
  76097. * Gets the current list of angular speed gradients.
  76098. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  76099. * @returns the list of angular speed gradients
  76100. */
  76101. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  76102. /**
  76103. * Adds a new angular speed gradient
  76104. * @param gradient defines the gradient to use (between 0 and 1)
  76105. * @param factor defines the angular speed to affect to the specified gradient
  76106. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76107. * @returns the current particle system
  76108. */
  76109. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76110. /**
  76111. * Remove a specific angular speed gradient
  76112. * @param gradient defines the gradient to remove
  76113. * @returns the current particle system
  76114. */
  76115. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  76116. /**
  76117. * Gets the current list of velocity gradients.
  76118. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  76119. * @returns the list of velocity gradients
  76120. */
  76121. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  76122. /**
  76123. * Adds a new velocity gradient
  76124. * @param gradient defines the gradient to use (between 0 and 1)
  76125. * @param factor defines the velocity to affect to the specified gradient
  76126. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76127. * @returns the current particle system
  76128. */
  76129. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76130. /**
  76131. * Remove a specific velocity gradient
  76132. * @param gradient defines the gradient to remove
  76133. * @returns the current particle system
  76134. */
  76135. removeVelocityGradient(gradient: number): IParticleSystem;
  76136. /**
  76137. * Gets the current list of limit velocity gradients.
  76138. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  76139. * @returns the list of limit velocity gradients
  76140. */
  76141. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  76142. /**
  76143. * Adds a new limit velocity gradient
  76144. * @param gradient defines the gradient to use (between 0 and 1)
  76145. * @param factor defines the limit velocity to affect to the specified gradient
  76146. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76147. * @returns the current particle system
  76148. */
  76149. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76150. /**
  76151. * Remove a specific limit velocity gradient
  76152. * @param gradient defines the gradient to remove
  76153. * @returns the current particle system
  76154. */
  76155. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  76156. /**
  76157. * Adds a new drag gradient
  76158. * @param gradient defines the gradient to use (between 0 and 1)
  76159. * @param factor defines the drag to affect to the specified gradient
  76160. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76161. * @returns the current particle system
  76162. */
  76163. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76164. /**
  76165. * Remove a specific drag gradient
  76166. * @param gradient defines the gradient to remove
  76167. * @returns the current particle system
  76168. */
  76169. removeDragGradient(gradient: number): IParticleSystem;
  76170. /**
  76171. * Gets the current list of drag gradients.
  76172. * You must use addDragGradient and removeDragGradient to udpate this list
  76173. * @returns the list of drag gradients
  76174. */
  76175. getDragGradients(): Nullable<Array<FactorGradient>>;
  76176. /**
  76177. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  76178. * @param gradient defines the gradient to use (between 0 and 1)
  76179. * @param factor defines the emit rate to affect to the specified gradient
  76180. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76181. * @returns the current particle system
  76182. */
  76183. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76184. /**
  76185. * Remove a specific emit rate gradient
  76186. * @param gradient defines the gradient to remove
  76187. * @returns the current particle system
  76188. */
  76189. removeEmitRateGradient(gradient: number): IParticleSystem;
  76190. /**
  76191. * Gets the current list of emit rate gradients.
  76192. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  76193. * @returns the list of emit rate gradients
  76194. */
  76195. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  76196. /**
  76197. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  76198. * @param gradient defines the gradient to use (between 0 and 1)
  76199. * @param factor defines the start size to affect to the specified gradient
  76200. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76201. * @returns the current particle system
  76202. */
  76203. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76204. /**
  76205. * Remove a specific start size gradient
  76206. * @param gradient defines the gradient to remove
  76207. * @returns the current particle system
  76208. */
  76209. removeStartSizeGradient(gradient: number): IParticleSystem;
  76210. /**
  76211. * Gets the current list of start size gradients.
  76212. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  76213. * @returns the list of start size gradients
  76214. */
  76215. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  76216. /**
  76217. * Adds a new life time gradient
  76218. * @param gradient defines the gradient to use (between 0 and 1)
  76219. * @param factor defines the life time factor to affect to the specified gradient
  76220. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76221. * @returns the current particle system
  76222. */
  76223. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76224. /**
  76225. * Remove a specific life time gradient
  76226. * @param gradient defines the gradient to remove
  76227. * @returns the current particle system
  76228. */
  76229. removeLifeTimeGradient(gradient: number): IParticleSystem;
  76230. /**
  76231. * Gets the current list of life time gradients.
  76232. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  76233. * @returns the list of life time gradients
  76234. */
  76235. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  76236. /**
  76237. * Gets the current list of color gradients.
  76238. * You must use addColorGradient and removeColorGradient to udpate this list
  76239. * @returns the list of color gradients
  76240. */
  76241. getColorGradients(): Nullable<Array<ColorGradient>>;
  76242. /**
  76243. * Adds a new ramp gradient used to remap particle colors
  76244. * @param gradient defines the gradient to use (between 0 and 1)
  76245. * @param color defines the color to affect to the specified gradient
  76246. * @returns the current particle system
  76247. */
  76248. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  76249. /**
  76250. * Gets the current list of ramp gradients.
  76251. * You must use addRampGradient and removeRampGradient to udpate this list
  76252. * @returns the list of ramp gradients
  76253. */
  76254. getRampGradients(): Nullable<Array<Color3Gradient>>;
  76255. /** Gets or sets a boolean indicating that ramp gradients must be used
  76256. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  76257. */
  76258. useRampGradients: boolean;
  76259. /**
  76260. * Adds a new color remap gradient
  76261. * @param gradient defines the gradient to use (between 0 and 1)
  76262. * @param min defines the color remap minimal range
  76263. * @param max defines the color remap maximal range
  76264. * @returns the current particle system
  76265. */
  76266. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76267. /**
  76268. * Gets the current list of color remap gradients.
  76269. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  76270. * @returns the list of color remap gradients
  76271. */
  76272. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  76273. /**
  76274. * Adds a new alpha remap gradient
  76275. * @param gradient defines the gradient to use (between 0 and 1)
  76276. * @param min defines the alpha remap minimal range
  76277. * @param max defines the alpha remap maximal range
  76278. * @returns the current particle system
  76279. */
  76280. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76281. /**
  76282. * Gets the current list of alpha remap gradients.
  76283. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  76284. * @returns the list of alpha remap gradients
  76285. */
  76286. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  76287. /**
  76288. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  76289. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76290. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76291. * @returns the emitter
  76292. */
  76293. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  76294. /**
  76295. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  76296. * @param radius The radius of the hemisphere to emit from
  76297. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76298. * @returns the emitter
  76299. */
  76300. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  76301. /**
  76302. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  76303. * @param radius The radius of the sphere to emit from
  76304. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76305. * @returns the emitter
  76306. */
  76307. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  76308. /**
  76309. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  76310. * @param radius The radius of the sphere to emit from
  76311. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  76312. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  76313. * @returns the emitter
  76314. */
  76315. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  76316. /**
  76317. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  76318. * @param radius The radius of the emission cylinder
  76319. * @param height The height of the emission cylinder
  76320. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  76321. * @param directionRandomizer How much to randomize the particle direction [0-1]
  76322. * @returns the emitter
  76323. */
  76324. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  76325. /**
  76326. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  76327. * @param radius The radius of the cylinder to emit from
  76328. * @param height The height of the emission cylinder
  76329. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  76330. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  76331. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  76332. * @returns the emitter
  76333. */
  76334. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  76335. /**
  76336. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  76337. * @param radius The radius of the cone to emit from
  76338. * @param angle The base angle of the cone
  76339. * @returns the emitter
  76340. */
  76341. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  76342. /**
  76343. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  76344. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76345. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76346. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76347. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76348. * @returns the emitter
  76349. */
  76350. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  76351. /**
  76352. * Get hosting scene
  76353. * @returns the scene
  76354. */
  76355. getScene(): Scene;
  76356. }
  76357. }
  76358. declare module BABYLON {
  76359. /**
  76360. * Creates an instance based on a source mesh.
  76361. */
  76362. export class InstancedMesh extends AbstractMesh {
  76363. private _sourceMesh;
  76364. private _currentLOD;
  76365. /** @hidden */
  76366. _indexInSourceMeshInstanceArray: number;
  76367. constructor(name: string, source: Mesh);
  76368. /**
  76369. * Returns the string "InstancedMesh".
  76370. */
  76371. getClassName(): string;
  76372. /**
  76373. * If the source mesh receives shadows
  76374. */
  76375. readonly receiveShadows: boolean;
  76376. /**
  76377. * The material of the source mesh
  76378. */
  76379. readonly material: Nullable<Material>;
  76380. /**
  76381. * Visibility of the source mesh
  76382. */
  76383. readonly visibility: number;
  76384. /**
  76385. * Skeleton of the source mesh
  76386. */
  76387. readonly skeleton: Nullable<Skeleton>;
  76388. /**
  76389. * Rendering ground id of the source mesh
  76390. */
  76391. renderingGroupId: number;
  76392. /**
  76393. * Returns the total number of vertices (integer).
  76394. */
  76395. getTotalVertices(): number;
  76396. /**
  76397. * Returns a positive integer : the total number of indices in this mesh geometry.
  76398. * @returns the numner of indices or zero if the mesh has no geometry.
  76399. */
  76400. getTotalIndices(): number;
  76401. /**
  76402. * The source mesh of the instance
  76403. */
  76404. readonly sourceMesh: Mesh;
  76405. /**
  76406. * Is this node ready to be used/rendered
  76407. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  76408. * @return {boolean} is it ready
  76409. */
  76410. isReady(completeCheck?: boolean): boolean;
  76411. /**
  76412. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  76413. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  76414. * @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.
  76415. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  76416. */
  76417. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  76418. /**
  76419. * Sets the vertex data of the mesh geometry for the requested `kind`.
  76420. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  76421. * The `data` are either a numeric array either a Float32Array.
  76422. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  76423. * 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).
  76424. * Note that a new underlying VertexBuffer object is created each call.
  76425. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  76426. *
  76427. * Possible `kind` values :
  76428. * - VertexBuffer.PositionKind
  76429. * - VertexBuffer.UVKind
  76430. * - VertexBuffer.UV2Kind
  76431. * - VertexBuffer.UV3Kind
  76432. * - VertexBuffer.UV4Kind
  76433. * - VertexBuffer.UV5Kind
  76434. * - VertexBuffer.UV6Kind
  76435. * - VertexBuffer.ColorKind
  76436. * - VertexBuffer.MatricesIndicesKind
  76437. * - VertexBuffer.MatricesIndicesExtraKind
  76438. * - VertexBuffer.MatricesWeightsKind
  76439. * - VertexBuffer.MatricesWeightsExtraKind
  76440. *
  76441. * Returns the Mesh.
  76442. */
  76443. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  76444. /**
  76445. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  76446. * If the mesh has no geometry, it is simply returned as it is.
  76447. * The `data` are either a numeric array either a Float32Array.
  76448. * No new underlying VertexBuffer object is created.
  76449. * 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.
  76450. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  76451. *
  76452. * Possible `kind` values :
  76453. * - VertexBuffer.PositionKind
  76454. * - VertexBuffer.UVKind
  76455. * - VertexBuffer.UV2Kind
  76456. * - VertexBuffer.UV3Kind
  76457. * - VertexBuffer.UV4Kind
  76458. * - VertexBuffer.UV5Kind
  76459. * - VertexBuffer.UV6Kind
  76460. * - VertexBuffer.ColorKind
  76461. * - VertexBuffer.MatricesIndicesKind
  76462. * - VertexBuffer.MatricesIndicesExtraKind
  76463. * - VertexBuffer.MatricesWeightsKind
  76464. * - VertexBuffer.MatricesWeightsExtraKind
  76465. *
  76466. * Returns the Mesh.
  76467. */
  76468. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  76469. /**
  76470. * Sets the mesh indices.
  76471. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  76472. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  76473. * This method creates a new index buffer each call.
  76474. * Returns the Mesh.
  76475. */
  76476. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  76477. /**
  76478. * Boolean : True if the mesh owns the requested kind of data.
  76479. */
  76480. isVerticesDataPresent(kind: string): boolean;
  76481. /**
  76482. * Returns an array of indices (IndicesArray).
  76483. */
  76484. getIndices(): Nullable<IndicesArray>;
  76485. readonly _positions: Nullable<Vector3[]>;
  76486. /**
  76487. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  76488. * This means the mesh underlying bounding box and sphere are recomputed.
  76489. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  76490. * @returns the current mesh
  76491. */
  76492. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  76493. /** @hidden */
  76494. _preActivate(): InstancedMesh;
  76495. /** @hidden */
  76496. _activate(renderId: number): boolean;
  76497. getWorldMatrix(): Matrix;
  76498. /**
  76499. * Returns the current associated LOD AbstractMesh.
  76500. */
  76501. getLOD(camera: Camera): AbstractMesh;
  76502. /** @hidden */
  76503. _syncSubMeshes(): InstancedMesh;
  76504. /** @hidden */
  76505. _generatePointsArray(): boolean;
  76506. /**
  76507. * Creates a new InstancedMesh from the current mesh.
  76508. * - name (string) : the cloned mesh name
  76509. * - newParent (optional Node) : the optional Node to parent the clone to.
  76510. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  76511. *
  76512. * Returns the clone.
  76513. */
  76514. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  76515. /**
  76516. * Disposes the InstancedMesh.
  76517. * Returns nothing.
  76518. */
  76519. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76520. }
  76521. }
  76522. declare module BABYLON {
  76523. /**
  76524. * Defines the options associated with the creation of a shader material.
  76525. */
  76526. export interface IShaderMaterialOptions {
  76527. /**
  76528. * Does the material work in alpha blend mode
  76529. */
  76530. needAlphaBlending: boolean;
  76531. /**
  76532. * Does the material work in alpha test mode
  76533. */
  76534. needAlphaTesting: boolean;
  76535. /**
  76536. * The list of attribute names used in the shader
  76537. */
  76538. attributes: string[];
  76539. /**
  76540. * The list of unifrom names used in the shader
  76541. */
  76542. uniforms: string[];
  76543. /**
  76544. * The list of UBO names used in the shader
  76545. */
  76546. uniformBuffers: string[];
  76547. /**
  76548. * The list of sampler names used in the shader
  76549. */
  76550. samplers: string[];
  76551. /**
  76552. * The list of defines used in the shader
  76553. */
  76554. defines: string[];
  76555. }
  76556. /**
  76557. * 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.
  76558. *
  76559. * This returned material effects how the mesh will look based on the code in the shaders.
  76560. *
  76561. * @see http://doc.babylonjs.com/how_to/shader_material
  76562. */
  76563. export class ShaderMaterial extends Material {
  76564. private _shaderPath;
  76565. private _options;
  76566. private _textures;
  76567. private _textureArrays;
  76568. private _floats;
  76569. private _ints;
  76570. private _floatsArrays;
  76571. private _colors3;
  76572. private _colors3Arrays;
  76573. private _colors4;
  76574. private _vectors2;
  76575. private _vectors3;
  76576. private _vectors4;
  76577. private _matrices;
  76578. private _matrices3x3;
  76579. private _matrices2x2;
  76580. private _vectors2Arrays;
  76581. private _vectors3Arrays;
  76582. private _cachedWorldViewMatrix;
  76583. private _renderId;
  76584. /**
  76585. * Instantiate a new shader material.
  76586. * 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.
  76587. * This returned material effects how the mesh will look based on the code in the shaders.
  76588. * @see http://doc.babylonjs.com/how_to/shader_material
  76589. * @param name Define the name of the material in the scene
  76590. * @param scene Define the scene the material belongs to
  76591. * @param shaderPath Defines the route to the shader code in one of three ways:
  76592. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  76593. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  76594. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  76595. * @param options Define the options used to create the shader
  76596. */
  76597. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  76598. /**
  76599. * Gets the options used to compile the shader.
  76600. * They can be modified to trigger a new compilation
  76601. */
  76602. readonly options: IShaderMaterialOptions;
  76603. /**
  76604. * Gets the current class name of the material e.g. "ShaderMaterial"
  76605. * Mainly use in serialization.
  76606. * @returns the class name
  76607. */
  76608. getClassName(): string;
  76609. /**
  76610. * Specifies if the material will require alpha blending
  76611. * @returns a boolean specifying if alpha blending is needed
  76612. */
  76613. needAlphaBlending(): boolean;
  76614. /**
  76615. * Specifies if this material should be rendered in alpha test mode
  76616. * @returns a boolean specifying if an alpha test is needed.
  76617. */
  76618. needAlphaTesting(): boolean;
  76619. private _checkUniform;
  76620. /**
  76621. * Set a texture in the shader.
  76622. * @param name Define the name of the uniform samplers as defined in the shader
  76623. * @param texture Define the texture to bind to this sampler
  76624. * @return the material itself allowing "fluent" like uniform updates
  76625. */
  76626. setTexture(name: string, texture: Texture): ShaderMaterial;
  76627. /**
  76628. * Set a texture array in the shader.
  76629. * @param name Define the name of the uniform sampler array as defined in the shader
  76630. * @param textures Define the list of textures to bind to this sampler
  76631. * @return the material itself allowing "fluent" like uniform updates
  76632. */
  76633. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  76634. /**
  76635. * Set a float in the shader.
  76636. * @param name Define the name of the uniform as defined in the shader
  76637. * @param value Define the value to give to the uniform
  76638. * @return the material itself allowing "fluent" like uniform updates
  76639. */
  76640. setFloat(name: string, value: number): ShaderMaterial;
  76641. /**
  76642. * Set a int in the shader.
  76643. * @param name Define the name of the uniform as defined in the shader
  76644. * @param value Define the value to give to the uniform
  76645. * @return the material itself allowing "fluent" like uniform updates
  76646. */
  76647. setInt(name: string, value: number): ShaderMaterial;
  76648. /**
  76649. * Set an array of floats in the shader.
  76650. * @param name Define the name of the uniform as defined in the shader
  76651. * @param value Define the value to give to the uniform
  76652. * @return the material itself allowing "fluent" like uniform updates
  76653. */
  76654. setFloats(name: string, value: number[]): ShaderMaterial;
  76655. /**
  76656. * Set a vec3 in the shader from a Color3.
  76657. * @param name Define the name of the uniform as defined in the shader
  76658. * @param value Define the value to give to the uniform
  76659. * @return the material itself allowing "fluent" like uniform updates
  76660. */
  76661. setColor3(name: string, value: Color3): ShaderMaterial;
  76662. /**
  76663. * Set a vec3 array in the shader from a Color3 array.
  76664. * @param name Define the name of the uniform as defined in the shader
  76665. * @param value Define the value to give to the uniform
  76666. * @return the material itself allowing "fluent" like uniform updates
  76667. */
  76668. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  76669. /**
  76670. * Set a vec4 in the shader from a Color4.
  76671. * @param name Define the name of the uniform as defined in the shader
  76672. * @param value Define the value to give to the uniform
  76673. * @return the material itself allowing "fluent" like uniform updates
  76674. */
  76675. setColor4(name: string, value: Color4): ShaderMaterial;
  76676. /**
  76677. * Set a vec2 in the shader from a Vector2.
  76678. * @param name Define the name of the uniform as defined in the shader
  76679. * @param value Define the value to give to the uniform
  76680. * @return the material itself allowing "fluent" like uniform updates
  76681. */
  76682. setVector2(name: string, value: Vector2): ShaderMaterial;
  76683. /**
  76684. * Set a vec3 in the shader from a Vector3.
  76685. * @param name Define the name of the uniform as defined in the shader
  76686. * @param value Define the value to give to the uniform
  76687. * @return the material itself allowing "fluent" like uniform updates
  76688. */
  76689. setVector3(name: string, value: Vector3): ShaderMaterial;
  76690. /**
  76691. * Set a vec4 in the shader from a Vector4.
  76692. * @param name Define the name of the uniform as defined in the shader
  76693. * @param value Define the value to give to the uniform
  76694. * @return the material itself allowing "fluent" like uniform updates
  76695. */
  76696. setVector4(name: string, value: Vector4): ShaderMaterial;
  76697. /**
  76698. * Set a mat4 in the shader from a Matrix.
  76699. * @param name Define the name of the uniform as defined in the shader
  76700. * @param value Define the value to give to the uniform
  76701. * @return the material itself allowing "fluent" like uniform updates
  76702. */
  76703. setMatrix(name: string, value: Matrix): ShaderMaterial;
  76704. /**
  76705. * Set a mat3 in the shader from a Float32Array.
  76706. * @param name Define the name of the uniform as defined in the shader
  76707. * @param value Define the value to give to the uniform
  76708. * @return the material itself allowing "fluent" like uniform updates
  76709. */
  76710. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  76711. /**
  76712. * Set a mat2 in the shader from a Float32Array.
  76713. * @param name Define the name of the uniform as defined in the shader
  76714. * @param value Define the value to give to the uniform
  76715. * @return the material itself allowing "fluent" like uniform updates
  76716. */
  76717. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  76718. /**
  76719. * Set a vec2 array in the shader from a number array.
  76720. * @param name Define the name of the uniform as defined in the shader
  76721. * @param value Define the value to give to the uniform
  76722. * @return the material itself allowing "fluent" like uniform updates
  76723. */
  76724. setArray2(name: string, value: number[]): ShaderMaterial;
  76725. /**
  76726. * Set a vec3 array in the shader from a number array.
  76727. * @param name Define the name of the uniform as defined in the shader
  76728. * @param value Define the value to give to the uniform
  76729. * @return the material itself allowing "fluent" like uniform updates
  76730. */
  76731. setArray3(name: string, value: number[]): ShaderMaterial;
  76732. private _checkCache;
  76733. /**
  76734. * Specifies that the submesh is ready to be used
  76735. * @param mesh defines the mesh to check
  76736. * @param subMesh defines which submesh to check
  76737. * @param useInstances specifies that instances should be used
  76738. * @returns a boolean indicating that the submesh is ready or not
  76739. */
  76740. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  76741. /**
  76742. * Checks if the material is ready to render the requested mesh
  76743. * @param mesh Define the mesh to render
  76744. * @param useInstances Define whether or not the material is used with instances
  76745. * @returns true if ready, otherwise false
  76746. */
  76747. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  76748. /**
  76749. * Binds the world matrix to the material
  76750. * @param world defines the world transformation matrix
  76751. */
  76752. bindOnlyWorldMatrix(world: Matrix): void;
  76753. /**
  76754. * Binds the material to the mesh
  76755. * @param world defines the world transformation matrix
  76756. * @param mesh defines the mesh to bind the material to
  76757. */
  76758. bind(world: Matrix, mesh?: Mesh): void;
  76759. /**
  76760. * Gets the active textures from the material
  76761. * @returns an array of textures
  76762. */
  76763. getActiveTextures(): BaseTexture[];
  76764. /**
  76765. * Specifies if the material uses a texture
  76766. * @param texture defines the texture to check against the material
  76767. * @returns a boolean specifying if the material uses the texture
  76768. */
  76769. hasTexture(texture: BaseTexture): boolean;
  76770. /**
  76771. * Makes a duplicate of the material, and gives it a new name
  76772. * @param name defines the new name for the duplicated material
  76773. * @returns the cloned material
  76774. */
  76775. clone(name: string): ShaderMaterial;
  76776. /**
  76777. * Disposes the material
  76778. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  76779. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  76780. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  76781. */
  76782. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  76783. /**
  76784. * Serializes this material in a JSON representation
  76785. * @returns the serialized material object
  76786. */
  76787. serialize(): any;
  76788. /**
  76789. * Creates a shader material from parsed shader material data
  76790. * @param source defines the JSON represnetation of the material
  76791. * @param scene defines the hosting scene
  76792. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  76793. * @returns a new material
  76794. */
  76795. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  76796. }
  76797. }
  76798. declare module BABYLON {
  76799. /** @hidden */
  76800. export var colorPixelShader: {
  76801. name: string;
  76802. shader: string;
  76803. };
  76804. }
  76805. declare module BABYLON {
  76806. /** @hidden */
  76807. export var colorVertexShader: {
  76808. name: string;
  76809. shader: string;
  76810. };
  76811. }
  76812. declare module BABYLON {
  76813. /**
  76814. * Line mesh
  76815. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  76816. */
  76817. export class LinesMesh extends Mesh {
  76818. /**
  76819. * If vertex color should be applied to the mesh
  76820. */
  76821. useVertexColor?: boolean | undefined;
  76822. /**
  76823. * If vertex alpha should be applied to the mesh
  76824. */
  76825. useVertexAlpha?: boolean | undefined;
  76826. /**
  76827. * Color of the line (Default: White)
  76828. */
  76829. color: Color3;
  76830. /**
  76831. * Alpha of the line (Default: 1)
  76832. */
  76833. alpha: number;
  76834. /**
  76835. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  76836. * This margin is expressed in world space coordinates, so its value may vary.
  76837. * Default value is 0.1
  76838. */
  76839. intersectionThreshold: number;
  76840. private _colorShader;
  76841. /**
  76842. * Creates a new LinesMesh
  76843. * @param name defines the name
  76844. * @param scene defines the hosting scene
  76845. * @param parent defines the parent mesh if any
  76846. * @param source defines the optional source LinesMesh used to clone data from
  76847. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  76848. * When false, achieved by calling a clone(), also passing False.
  76849. * This will make creation of children, recursive.
  76850. * @param useVertexColor defines if this LinesMesh supports vertex color
  76851. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  76852. */
  76853. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  76854. /**
  76855. * If vertex color should be applied to the mesh
  76856. */
  76857. useVertexColor?: boolean | undefined,
  76858. /**
  76859. * If vertex alpha should be applied to the mesh
  76860. */
  76861. useVertexAlpha?: boolean | undefined);
  76862. private _addClipPlaneDefine;
  76863. private _removeClipPlaneDefine;
  76864. isReady(): boolean;
  76865. /**
  76866. * Returns the string "LineMesh"
  76867. */
  76868. getClassName(): string;
  76869. /**
  76870. * @hidden
  76871. */
  76872. /**
  76873. * @hidden
  76874. */
  76875. material: Material;
  76876. /**
  76877. * @hidden
  76878. */
  76879. readonly checkCollisions: boolean;
  76880. /** @hidden */
  76881. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  76882. /** @hidden */
  76883. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  76884. /**
  76885. * Disposes of the line mesh
  76886. * @param doNotRecurse If children should be disposed
  76887. */
  76888. dispose(doNotRecurse?: boolean): void;
  76889. /**
  76890. * Returns a new LineMesh object cloned from the current one.
  76891. */
  76892. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  76893. /**
  76894. * Creates a new InstancedLinesMesh object from the mesh model.
  76895. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76896. * @param name defines the name of the new instance
  76897. * @returns a new InstancedLinesMesh
  76898. */
  76899. createInstance(name: string): InstancedLinesMesh;
  76900. }
  76901. /**
  76902. * Creates an instance based on a source LinesMesh
  76903. */
  76904. export class InstancedLinesMesh extends InstancedMesh {
  76905. /**
  76906. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  76907. * This margin is expressed in world space coordinates, so its value may vary.
  76908. * Initilized with the intersectionThreshold value of the source LinesMesh
  76909. */
  76910. intersectionThreshold: number;
  76911. constructor(name: string, source: LinesMesh);
  76912. /**
  76913. * Returns the string "InstancedLinesMesh".
  76914. */
  76915. getClassName(): string;
  76916. }
  76917. }
  76918. declare module BABYLON {
  76919. /** @hidden */
  76920. export var linePixelShader: {
  76921. name: string;
  76922. shader: string;
  76923. };
  76924. }
  76925. declare module BABYLON {
  76926. /** @hidden */
  76927. export var lineVertexShader: {
  76928. name: string;
  76929. shader: string;
  76930. };
  76931. }
  76932. declare module BABYLON {
  76933. interface AbstractMesh {
  76934. /**
  76935. * Disables the mesh edge rendering mode
  76936. * @returns the currentAbstractMesh
  76937. */
  76938. disableEdgesRendering(): AbstractMesh;
  76939. /**
  76940. * Enables the edge rendering mode on the mesh.
  76941. * This mode makes the mesh edges visible
  76942. * @param epsilon defines the maximal distance between two angles to detect a face
  76943. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76944. * @returns the currentAbstractMesh
  76945. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76946. */
  76947. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  76948. /**
  76949. * Gets the edgesRenderer associated with the mesh
  76950. */
  76951. edgesRenderer: Nullable<EdgesRenderer>;
  76952. }
  76953. interface LinesMesh {
  76954. /**
  76955. * Enables the edge rendering mode on the mesh.
  76956. * This mode makes the mesh edges visible
  76957. * @param epsilon defines the maximal distance between two angles to detect a face
  76958. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76959. * @returns the currentAbstractMesh
  76960. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76961. */
  76962. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  76963. }
  76964. interface InstancedLinesMesh {
  76965. /**
  76966. * Enables the edge rendering mode on the mesh.
  76967. * This mode makes the mesh edges visible
  76968. * @param epsilon defines the maximal distance between two angles to detect a face
  76969. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76970. * @returns the current InstancedLinesMesh
  76971. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76972. */
  76973. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  76974. }
  76975. /**
  76976. * Defines the minimum contract an Edges renderer should follow.
  76977. */
  76978. export interface IEdgesRenderer extends IDisposable {
  76979. /**
  76980. * Gets or sets a boolean indicating if the edgesRenderer is active
  76981. */
  76982. isEnabled: boolean;
  76983. /**
  76984. * Renders the edges of the attached mesh,
  76985. */
  76986. render(): void;
  76987. /**
  76988. * Checks wether or not the edges renderer is ready to render.
  76989. * @return true if ready, otherwise false.
  76990. */
  76991. isReady(): boolean;
  76992. }
  76993. /**
  76994. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  76995. */
  76996. export class EdgesRenderer implements IEdgesRenderer {
  76997. /**
  76998. * Define the size of the edges with an orthographic camera
  76999. */
  77000. edgesWidthScalerForOrthographic: number;
  77001. /**
  77002. * Define the size of the edges with a perspective camera
  77003. */
  77004. edgesWidthScalerForPerspective: number;
  77005. protected _source: AbstractMesh;
  77006. protected _linesPositions: number[];
  77007. protected _linesNormals: number[];
  77008. protected _linesIndices: number[];
  77009. protected _epsilon: number;
  77010. protected _indicesCount: number;
  77011. protected _lineShader: ShaderMaterial;
  77012. protected _ib: DataBuffer;
  77013. protected _buffers: {
  77014. [key: string]: Nullable<VertexBuffer>;
  77015. };
  77016. protected _checkVerticesInsteadOfIndices: boolean;
  77017. private _meshRebuildObserver;
  77018. private _meshDisposeObserver;
  77019. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  77020. isEnabled: boolean;
  77021. /**
  77022. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  77023. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  77024. * @param source Mesh used to create edges
  77025. * @param epsilon sum of angles in adjacency to check for edge
  77026. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  77027. * @param generateEdgesLines - should generate Lines or only prepare resources.
  77028. */
  77029. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  77030. protected _prepareRessources(): void;
  77031. /** @hidden */
  77032. _rebuild(): void;
  77033. /**
  77034. * Releases the required resources for the edges renderer
  77035. */
  77036. dispose(): void;
  77037. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  77038. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  77039. /**
  77040. * Checks if the pair of p0 and p1 is en edge
  77041. * @param faceIndex
  77042. * @param edge
  77043. * @param faceNormals
  77044. * @param p0
  77045. * @param p1
  77046. * @private
  77047. */
  77048. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  77049. /**
  77050. * push line into the position, normal and index buffer
  77051. * @protected
  77052. */
  77053. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  77054. /**
  77055. * Generates lines edges from adjacencjes
  77056. * @private
  77057. */
  77058. _generateEdgesLines(): void;
  77059. /**
  77060. * Checks wether or not the edges renderer is ready to render.
  77061. * @return true if ready, otherwise false.
  77062. */
  77063. isReady(): boolean;
  77064. /**
  77065. * Renders the edges of the attached mesh,
  77066. */
  77067. render(): void;
  77068. }
  77069. /**
  77070. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  77071. */
  77072. export class LineEdgesRenderer extends EdgesRenderer {
  77073. /**
  77074. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  77075. * @param source LineMesh used to generate edges
  77076. * @param epsilon not important (specified angle for edge detection)
  77077. * @param checkVerticesInsteadOfIndices not important for LineMesh
  77078. */
  77079. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  77080. /**
  77081. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  77082. */
  77083. _generateEdgesLines(): void;
  77084. }
  77085. }
  77086. declare module BABYLON {
  77087. /**
  77088. * This represents the object necessary to create a rendering group.
  77089. * This is exclusively used and created by the rendering manager.
  77090. * To modify the behavior, you use the available helpers in your scene or meshes.
  77091. * @hidden
  77092. */
  77093. export class RenderingGroup {
  77094. index: number;
  77095. private _scene;
  77096. private _opaqueSubMeshes;
  77097. private _transparentSubMeshes;
  77098. private _alphaTestSubMeshes;
  77099. private _depthOnlySubMeshes;
  77100. private _particleSystems;
  77101. private _spriteManagers;
  77102. private _opaqueSortCompareFn;
  77103. private _alphaTestSortCompareFn;
  77104. private _transparentSortCompareFn;
  77105. private _renderOpaque;
  77106. private _renderAlphaTest;
  77107. private _renderTransparent;
  77108. /** @hidden */
  77109. _edgesRenderers: SmartArray<IEdgesRenderer>;
  77110. onBeforeTransparentRendering: () => void;
  77111. /**
  77112. * Set the opaque sort comparison function.
  77113. * If null the sub meshes will be render in the order they were created
  77114. */
  77115. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77116. /**
  77117. * Set the alpha test sort comparison function.
  77118. * If null the sub meshes will be render in the order they were created
  77119. */
  77120. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77121. /**
  77122. * Set the transparent sort comparison function.
  77123. * If null the sub meshes will be render in the order they were created
  77124. */
  77125. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77126. /**
  77127. * Creates a new rendering group.
  77128. * @param index The rendering group index
  77129. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  77130. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  77131. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  77132. */
  77133. 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>);
  77134. /**
  77135. * Render all the sub meshes contained in the group.
  77136. * @param customRenderFunction Used to override the default render behaviour of the group.
  77137. * @returns true if rendered some submeshes.
  77138. */
  77139. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  77140. /**
  77141. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  77142. * @param subMeshes The submeshes to render
  77143. */
  77144. private renderOpaqueSorted;
  77145. /**
  77146. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  77147. * @param subMeshes The submeshes to render
  77148. */
  77149. private renderAlphaTestSorted;
  77150. /**
  77151. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  77152. * @param subMeshes The submeshes to render
  77153. */
  77154. private renderTransparentSorted;
  77155. /**
  77156. * Renders the submeshes in a specified order.
  77157. * @param subMeshes The submeshes to sort before render
  77158. * @param sortCompareFn The comparison function use to sort
  77159. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  77160. * @param transparent Specifies to activate blending if true
  77161. */
  77162. private static renderSorted;
  77163. /**
  77164. * Renders the submeshes in the order they were dispatched (no sort applied).
  77165. * @param subMeshes The submeshes to render
  77166. */
  77167. private static renderUnsorted;
  77168. /**
  77169. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77170. * are rendered back to front if in the same alpha index.
  77171. *
  77172. * @param a The first submesh
  77173. * @param b The second submesh
  77174. * @returns The result of the comparison
  77175. */
  77176. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  77177. /**
  77178. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77179. * are rendered back to front.
  77180. *
  77181. * @param a The first submesh
  77182. * @param b The second submesh
  77183. * @returns The result of the comparison
  77184. */
  77185. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  77186. /**
  77187. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77188. * are rendered front to back (prevent overdraw).
  77189. *
  77190. * @param a The first submesh
  77191. * @param b The second submesh
  77192. * @returns The result of the comparison
  77193. */
  77194. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  77195. /**
  77196. * Resets the different lists of submeshes to prepare a new frame.
  77197. */
  77198. prepare(): void;
  77199. dispose(): void;
  77200. /**
  77201. * Inserts the submesh in its correct queue depending on its material.
  77202. * @param subMesh The submesh to dispatch
  77203. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  77204. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  77205. */
  77206. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  77207. dispatchSprites(spriteManager: ISpriteManager): void;
  77208. dispatchParticles(particleSystem: IParticleSystem): void;
  77209. private _renderParticles;
  77210. private _renderSprites;
  77211. }
  77212. }
  77213. declare module BABYLON {
  77214. /**
  77215. * Interface describing the different options available in the rendering manager
  77216. * regarding Auto Clear between groups.
  77217. */
  77218. export interface IRenderingManagerAutoClearSetup {
  77219. /**
  77220. * Defines whether or not autoclear is enable.
  77221. */
  77222. autoClear: boolean;
  77223. /**
  77224. * Defines whether or not to autoclear the depth buffer.
  77225. */
  77226. depth: boolean;
  77227. /**
  77228. * Defines whether or not to autoclear the stencil buffer.
  77229. */
  77230. stencil: boolean;
  77231. }
  77232. /**
  77233. * This class is used by the onRenderingGroupObservable
  77234. */
  77235. export class RenderingGroupInfo {
  77236. /**
  77237. * The Scene that being rendered
  77238. */
  77239. scene: Scene;
  77240. /**
  77241. * The camera currently used for the rendering pass
  77242. */
  77243. camera: Nullable<Camera>;
  77244. /**
  77245. * The ID of the renderingGroup being processed
  77246. */
  77247. renderingGroupId: number;
  77248. }
  77249. /**
  77250. * This is the manager responsible of all the rendering for meshes sprites and particles.
  77251. * It is enable to manage the different groups as well as the different necessary sort functions.
  77252. * This should not be used directly aside of the few static configurations
  77253. */
  77254. export class RenderingManager {
  77255. /**
  77256. * The max id used for rendering groups (not included)
  77257. */
  77258. static MAX_RENDERINGGROUPS: number;
  77259. /**
  77260. * The min id used for rendering groups (included)
  77261. */
  77262. static MIN_RENDERINGGROUPS: number;
  77263. /**
  77264. * Used to globally prevent autoclearing scenes.
  77265. */
  77266. static AUTOCLEAR: boolean;
  77267. /**
  77268. * @hidden
  77269. */
  77270. _useSceneAutoClearSetup: boolean;
  77271. private _scene;
  77272. private _renderingGroups;
  77273. private _depthStencilBufferAlreadyCleaned;
  77274. private _autoClearDepthStencil;
  77275. private _customOpaqueSortCompareFn;
  77276. private _customAlphaTestSortCompareFn;
  77277. private _customTransparentSortCompareFn;
  77278. private _renderingGroupInfo;
  77279. /**
  77280. * Instantiates a new rendering group for a particular scene
  77281. * @param scene Defines the scene the groups belongs to
  77282. */
  77283. constructor(scene: Scene);
  77284. private _clearDepthStencilBuffer;
  77285. /**
  77286. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  77287. * @hidden
  77288. */
  77289. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  77290. /**
  77291. * Resets the different information of the group to prepare a new frame
  77292. * @hidden
  77293. */
  77294. reset(): void;
  77295. /**
  77296. * Dispose and release the group and its associated resources.
  77297. * @hidden
  77298. */
  77299. dispose(): void;
  77300. /**
  77301. * Clear the info related to rendering groups preventing retention points during dispose.
  77302. */
  77303. freeRenderingGroups(): void;
  77304. private _prepareRenderingGroup;
  77305. /**
  77306. * Add a sprite manager to the rendering manager in order to render it this frame.
  77307. * @param spriteManager Define the sprite manager to render
  77308. */
  77309. dispatchSprites(spriteManager: ISpriteManager): void;
  77310. /**
  77311. * Add a particle system to the rendering manager in order to render it this frame.
  77312. * @param particleSystem Define the particle system to render
  77313. */
  77314. dispatchParticles(particleSystem: IParticleSystem): void;
  77315. /**
  77316. * Add a submesh to the manager in order to render it this frame
  77317. * @param subMesh The submesh to dispatch
  77318. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  77319. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  77320. */
  77321. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  77322. /**
  77323. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77324. * This allowed control for front to back rendering or reversly depending of the special needs.
  77325. *
  77326. * @param renderingGroupId The rendering group id corresponding to its index
  77327. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77328. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77329. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77330. */
  77331. 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;
  77332. /**
  77333. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77334. *
  77335. * @param renderingGroupId The rendering group id corresponding to its index
  77336. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77337. * @param depth Automatically clears depth between groups if true and autoClear is true.
  77338. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  77339. */
  77340. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  77341. /**
  77342. * Gets the current auto clear configuration for one rendering group of the rendering
  77343. * manager.
  77344. * @param index the rendering group index to get the information for
  77345. * @returns The auto clear setup for the requested rendering group
  77346. */
  77347. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  77348. }
  77349. }
  77350. declare module BABYLON {
  77351. /**
  77352. * This Helps creating a texture that will be created from a camera in your scene.
  77353. * It is basically a dynamic texture that could be used to create special effects for instance.
  77354. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  77355. */
  77356. export class RenderTargetTexture extends Texture {
  77357. isCube: boolean;
  77358. /**
  77359. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  77360. */
  77361. static readonly REFRESHRATE_RENDER_ONCE: number;
  77362. /**
  77363. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  77364. */
  77365. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  77366. /**
  77367. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  77368. * the central point of your effect and can save a lot of performances.
  77369. */
  77370. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  77371. /**
  77372. * Use this predicate to dynamically define the list of mesh you want to render.
  77373. * If set, the renderList property will be overwritten.
  77374. */
  77375. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  77376. private _renderList;
  77377. /**
  77378. * Use this list to define the list of mesh you want to render.
  77379. */
  77380. renderList: Nullable<Array<AbstractMesh>>;
  77381. private _hookArray;
  77382. /**
  77383. * Define if particles should be rendered in your texture.
  77384. */
  77385. renderParticles: boolean;
  77386. /**
  77387. * Define if sprites should be rendered in your texture.
  77388. */
  77389. renderSprites: boolean;
  77390. /**
  77391. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  77392. */
  77393. coordinatesMode: number;
  77394. /**
  77395. * Define the camera used to render the texture.
  77396. */
  77397. activeCamera: Nullable<Camera>;
  77398. /**
  77399. * Override the render function of the texture with your own one.
  77400. */
  77401. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  77402. /**
  77403. * Define if camera post processes should be use while rendering the texture.
  77404. */
  77405. useCameraPostProcesses: boolean;
  77406. /**
  77407. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  77408. */
  77409. ignoreCameraViewport: boolean;
  77410. private _postProcessManager;
  77411. private _postProcesses;
  77412. private _resizeObserver;
  77413. /**
  77414. * An event triggered when the texture is unbind.
  77415. */
  77416. onBeforeBindObservable: Observable<RenderTargetTexture>;
  77417. /**
  77418. * An event triggered when the texture is unbind.
  77419. */
  77420. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  77421. private _onAfterUnbindObserver;
  77422. /**
  77423. * Set a after unbind callback in the texture.
  77424. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  77425. */
  77426. onAfterUnbind: () => void;
  77427. /**
  77428. * An event triggered before rendering the texture
  77429. */
  77430. onBeforeRenderObservable: Observable<number>;
  77431. private _onBeforeRenderObserver;
  77432. /**
  77433. * Set a before render callback in the texture.
  77434. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  77435. */
  77436. onBeforeRender: (faceIndex: number) => void;
  77437. /**
  77438. * An event triggered after rendering the texture
  77439. */
  77440. onAfterRenderObservable: Observable<number>;
  77441. private _onAfterRenderObserver;
  77442. /**
  77443. * Set a after render callback in the texture.
  77444. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  77445. */
  77446. onAfterRender: (faceIndex: number) => void;
  77447. /**
  77448. * An event triggered after the texture clear
  77449. */
  77450. onClearObservable: Observable<Engine>;
  77451. private _onClearObserver;
  77452. /**
  77453. * Set a clear callback in the texture.
  77454. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  77455. */
  77456. onClear: (Engine: Engine) => void;
  77457. /**
  77458. * Define the clear color of the Render Target if it should be different from the scene.
  77459. */
  77460. clearColor: Color4;
  77461. protected _size: number | {
  77462. width: number;
  77463. height: number;
  77464. };
  77465. protected _initialSizeParameter: number | {
  77466. width: number;
  77467. height: number;
  77468. } | {
  77469. ratio: number;
  77470. };
  77471. protected _sizeRatio: Nullable<number>;
  77472. /** @hidden */
  77473. _generateMipMaps: boolean;
  77474. protected _renderingManager: RenderingManager;
  77475. /** @hidden */
  77476. _waitingRenderList: string[];
  77477. protected _doNotChangeAspectRatio: boolean;
  77478. protected _currentRefreshId: number;
  77479. protected _refreshRate: number;
  77480. protected _textureMatrix: Matrix;
  77481. protected _samples: number;
  77482. protected _renderTargetOptions: RenderTargetCreationOptions;
  77483. /**
  77484. * Gets render target creation options that were used.
  77485. */
  77486. readonly renderTargetOptions: RenderTargetCreationOptions;
  77487. protected _engine: Engine;
  77488. protected _onRatioRescale(): void;
  77489. /**
  77490. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  77491. * It must define where the camera used to render the texture is set
  77492. */
  77493. boundingBoxPosition: Vector3;
  77494. private _boundingBoxSize;
  77495. /**
  77496. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  77497. * When defined, the cubemap will switch to local mode
  77498. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  77499. * @example https://www.babylonjs-playground.com/#RNASML
  77500. */
  77501. boundingBoxSize: Vector3;
  77502. /**
  77503. * In case the RTT has been created with a depth texture, get the associated
  77504. * depth texture.
  77505. * Otherwise, return null.
  77506. */
  77507. depthStencilTexture: Nullable<InternalTexture>;
  77508. /**
  77509. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  77510. * or used a shadow, depth texture...
  77511. * @param name The friendly name of the texture
  77512. * @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)
  77513. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  77514. * @param generateMipMaps True if mip maps need to be generated after render.
  77515. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  77516. * @param type The type of the buffer in the RTT (int, half float, float...)
  77517. * @param isCube True if a cube texture needs to be created
  77518. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  77519. * @param generateDepthBuffer True to generate a depth buffer
  77520. * @param generateStencilBuffer True to generate a stencil buffer
  77521. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  77522. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  77523. * @param delayAllocation if the texture allocation should be delayed (default: false)
  77524. */
  77525. constructor(name: string, size: number | {
  77526. width: number;
  77527. height: number;
  77528. } | {
  77529. ratio: number;
  77530. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  77531. /**
  77532. * Creates a depth stencil texture.
  77533. * This is only available in WebGL 2 or with the depth texture extension available.
  77534. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  77535. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  77536. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  77537. */
  77538. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  77539. private _processSizeParameter;
  77540. /**
  77541. * Define the number of samples to use in case of MSAA.
  77542. * It defaults to one meaning no MSAA has been enabled.
  77543. */
  77544. samples: number;
  77545. /**
  77546. * Resets the refresh counter of the texture and start bak from scratch.
  77547. * Could be useful to regenerate the texture if it is setup to render only once.
  77548. */
  77549. resetRefreshCounter(): void;
  77550. /**
  77551. * Define the refresh rate of the texture or the rendering frequency.
  77552. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  77553. */
  77554. refreshRate: number;
  77555. /**
  77556. * Adds a post process to the render target rendering passes.
  77557. * @param postProcess define the post process to add
  77558. */
  77559. addPostProcess(postProcess: PostProcess): void;
  77560. /**
  77561. * Clear all the post processes attached to the render target
  77562. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  77563. */
  77564. clearPostProcesses(dispose?: boolean): void;
  77565. /**
  77566. * Remove one of the post process from the list of attached post processes to the texture
  77567. * @param postProcess define the post process to remove from the list
  77568. */
  77569. removePostProcess(postProcess: PostProcess): void;
  77570. /** @hidden */
  77571. _shouldRender(): boolean;
  77572. /**
  77573. * Gets the actual render size of the texture.
  77574. * @returns the width of the render size
  77575. */
  77576. getRenderSize(): number;
  77577. /**
  77578. * Gets the actual render width of the texture.
  77579. * @returns the width of the render size
  77580. */
  77581. getRenderWidth(): number;
  77582. /**
  77583. * Gets the actual render height of the texture.
  77584. * @returns the height of the render size
  77585. */
  77586. getRenderHeight(): number;
  77587. /**
  77588. * Get if the texture can be rescaled or not.
  77589. */
  77590. readonly canRescale: boolean;
  77591. /**
  77592. * Resize the texture using a ratio.
  77593. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  77594. */
  77595. scale(ratio: number): void;
  77596. /**
  77597. * Get the texture reflection matrix used to rotate/transform the reflection.
  77598. * @returns the reflection matrix
  77599. */
  77600. getReflectionTextureMatrix(): Matrix;
  77601. /**
  77602. * Resize the texture to a new desired size.
  77603. * Be carrefull as it will recreate all the data in the new texture.
  77604. * @param size Define the new size. It can be:
  77605. * - a number for squared texture,
  77606. * - an object containing { width: number, height: number }
  77607. * - or an object containing a ratio { ratio: number }
  77608. */
  77609. resize(size: number | {
  77610. width: number;
  77611. height: number;
  77612. } | {
  77613. ratio: number;
  77614. }): void;
  77615. /**
  77616. * Renders all the objects from the render list into the texture.
  77617. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  77618. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  77619. */
  77620. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  77621. private _bestReflectionRenderTargetDimension;
  77622. /**
  77623. * @hidden
  77624. * @param faceIndex face index to bind to if this is a cubetexture
  77625. */
  77626. _bindFrameBuffer(faceIndex?: number): void;
  77627. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  77628. private renderToTarget;
  77629. /**
  77630. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77631. * This allowed control for front to back rendering or reversly depending of the special needs.
  77632. *
  77633. * @param renderingGroupId The rendering group id corresponding to its index
  77634. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77635. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77636. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77637. */
  77638. 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;
  77639. /**
  77640. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77641. *
  77642. * @param renderingGroupId The rendering group id corresponding to its index
  77643. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77644. */
  77645. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  77646. /**
  77647. * Clones the texture.
  77648. * @returns the cloned texture
  77649. */
  77650. clone(): RenderTargetTexture;
  77651. /**
  77652. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77653. * @returns The JSON representation of the texture
  77654. */
  77655. serialize(): any;
  77656. /**
  77657. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  77658. */
  77659. disposeFramebufferObjects(): void;
  77660. /**
  77661. * Dispose the texture and release its associated resources.
  77662. */
  77663. dispose(): void;
  77664. /** @hidden */
  77665. _rebuild(): void;
  77666. /**
  77667. * Clear the info related to rendering groups preventing retention point in material dispose.
  77668. */
  77669. freeRenderingGroups(): void;
  77670. /**
  77671. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  77672. * @returns the view count
  77673. */
  77674. getViewCount(): number;
  77675. }
  77676. }
  77677. declare module BABYLON {
  77678. /**
  77679. * Mirror texture can be used to simulate the view from a mirror in a scene.
  77680. * It will dynamically be rendered every frame to adapt to the camera point of view.
  77681. * You can then easily use it as a reflectionTexture on a flat surface.
  77682. * In case the surface is not a plane, please consider relying on reflection probes.
  77683. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77684. */
  77685. export class MirrorTexture extends RenderTargetTexture {
  77686. private scene;
  77687. /**
  77688. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  77689. * 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.
  77690. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77691. */
  77692. mirrorPlane: Plane;
  77693. /**
  77694. * Define the blur ratio used to blur the reflection if needed.
  77695. */
  77696. blurRatio: number;
  77697. /**
  77698. * Define the adaptive blur kernel used to blur the reflection if needed.
  77699. * This will autocompute the closest best match for the `blurKernel`
  77700. */
  77701. adaptiveBlurKernel: number;
  77702. /**
  77703. * Define the blur kernel used to blur the reflection if needed.
  77704. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77705. */
  77706. blurKernel: number;
  77707. /**
  77708. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  77709. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77710. */
  77711. blurKernelX: number;
  77712. /**
  77713. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  77714. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77715. */
  77716. blurKernelY: number;
  77717. private _autoComputeBlurKernel;
  77718. protected _onRatioRescale(): void;
  77719. private _updateGammaSpace;
  77720. private _imageProcessingConfigChangeObserver;
  77721. private _transformMatrix;
  77722. private _mirrorMatrix;
  77723. private _savedViewMatrix;
  77724. private _blurX;
  77725. private _blurY;
  77726. private _adaptiveBlurKernel;
  77727. private _blurKernelX;
  77728. private _blurKernelY;
  77729. private _blurRatio;
  77730. /**
  77731. * Instantiates a Mirror Texture.
  77732. * Mirror texture can be used to simulate the view from a mirror in a scene.
  77733. * It will dynamically be rendered every frame to adapt to the camera point of view.
  77734. * You can then easily use it as a reflectionTexture on a flat surface.
  77735. * In case the surface is not a plane, please consider relying on reflection probes.
  77736. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77737. * @param name
  77738. * @param size
  77739. * @param scene
  77740. * @param generateMipMaps
  77741. * @param type
  77742. * @param samplingMode
  77743. * @param generateDepthBuffer
  77744. */
  77745. constructor(name: string, size: number | {
  77746. width: number;
  77747. height: number;
  77748. } | {
  77749. ratio: number;
  77750. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  77751. private _preparePostProcesses;
  77752. /**
  77753. * Clone the mirror texture.
  77754. * @returns the cloned texture
  77755. */
  77756. clone(): MirrorTexture;
  77757. /**
  77758. * Serialize the texture to a JSON representation you could use in Parse later on
  77759. * @returns the serialized JSON representation
  77760. */
  77761. serialize(): any;
  77762. /**
  77763. * Dispose the texture and release its associated resources.
  77764. */
  77765. dispose(): void;
  77766. }
  77767. }
  77768. declare module BABYLON {
  77769. /**
  77770. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  77771. * @see http://doc.babylonjs.com/babylon101/materials#texture
  77772. */
  77773. export class Texture extends BaseTexture {
  77774. /** @hidden */
  77775. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  77776. /** @hidden */
  77777. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  77778. /** @hidden */
  77779. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  77780. /** nearest is mag = nearest and min = nearest and mip = linear */
  77781. static readonly NEAREST_SAMPLINGMODE: number;
  77782. /** nearest is mag = nearest and min = nearest and mip = linear */
  77783. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  77784. /** Bilinear is mag = linear and min = linear and mip = nearest */
  77785. static readonly BILINEAR_SAMPLINGMODE: number;
  77786. /** Bilinear is mag = linear and min = linear and mip = nearest */
  77787. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  77788. /** Trilinear is mag = linear and min = linear and mip = linear */
  77789. static readonly TRILINEAR_SAMPLINGMODE: number;
  77790. /** Trilinear is mag = linear and min = linear and mip = linear */
  77791. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  77792. /** mag = nearest and min = nearest and mip = nearest */
  77793. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  77794. /** mag = nearest and min = linear and mip = nearest */
  77795. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  77796. /** mag = nearest and min = linear and mip = linear */
  77797. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  77798. /** mag = nearest and min = linear and mip = none */
  77799. static readonly NEAREST_LINEAR: number;
  77800. /** mag = nearest and min = nearest and mip = none */
  77801. static readonly NEAREST_NEAREST: number;
  77802. /** mag = linear and min = nearest and mip = nearest */
  77803. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  77804. /** mag = linear and min = nearest and mip = linear */
  77805. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  77806. /** mag = linear and min = linear and mip = none */
  77807. static readonly LINEAR_LINEAR: number;
  77808. /** mag = linear and min = nearest and mip = none */
  77809. static readonly LINEAR_NEAREST: number;
  77810. /** Explicit coordinates mode */
  77811. static readonly EXPLICIT_MODE: number;
  77812. /** Spherical coordinates mode */
  77813. static readonly SPHERICAL_MODE: number;
  77814. /** Planar coordinates mode */
  77815. static readonly PLANAR_MODE: number;
  77816. /** Cubic coordinates mode */
  77817. static readonly CUBIC_MODE: number;
  77818. /** Projection coordinates mode */
  77819. static readonly PROJECTION_MODE: number;
  77820. /** Inverse Cubic coordinates mode */
  77821. static readonly SKYBOX_MODE: number;
  77822. /** Inverse Cubic coordinates mode */
  77823. static readonly INVCUBIC_MODE: number;
  77824. /** Equirectangular coordinates mode */
  77825. static readonly EQUIRECTANGULAR_MODE: number;
  77826. /** Equirectangular Fixed coordinates mode */
  77827. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  77828. /** Equirectangular Fixed Mirrored coordinates mode */
  77829. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  77830. /** Texture is not repeating outside of 0..1 UVs */
  77831. static readonly CLAMP_ADDRESSMODE: number;
  77832. /** Texture is repeating outside of 0..1 UVs */
  77833. static readonly WRAP_ADDRESSMODE: number;
  77834. /** Texture is repeating and mirrored */
  77835. static readonly MIRROR_ADDRESSMODE: number;
  77836. /**
  77837. * 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
  77838. */
  77839. static UseSerializedUrlIfAny: boolean;
  77840. /**
  77841. * Define the url of the texture.
  77842. */
  77843. url: Nullable<string>;
  77844. /**
  77845. * Define an offset on the texture to offset the u coordinates of the UVs
  77846. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  77847. */
  77848. uOffset: number;
  77849. /**
  77850. * Define an offset on the texture to offset the v coordinates of the UVs
  77851. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  77852. */
  77853. vOffset: number;
  77854. /**
  77855. * Define an offset on the texture to scale the u coordinates of the UVs
  77856. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  77857. */
  77858. uScale: number;
  77859. /**
  77860. * Define an offset on the texture to scale the v coordinates of the UVs
  77861. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  77862. */
  77863. vScale: number;
  77864. /**
  77865. * Define an offset on the texture to rotate around the u coordinates of the UVs
  77866. * @see http://doc.babylonjs.com/how_to/more_materials
  77867. */
  77868. uAng: number;
  77869. /**
  77870. * Define an offset on the texture to rotate around the v coordinates of the UVs
  77871. * @see http://doc.babylonjs.com/how_to/more_materials
  77872. */
  77873. vAng: number;
  77874. /**
  77875. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  77876. * @see http://doc.babylonjs.com/how_to/more_materials
  77877. */
  77878. wAng: number;
  77879. /**
  77880. * Defines the center of rotation (U)
  77881. */
  77882. uRotationCenter: number;
  77883. /**
  77884. * Defines the center of rotation (V)
  77885. */
  77886. vRotationCenter: number;
  77887. /**
  77888. * Defines the center of rotation (W)
  77889. */
  77890. wRotationCenter: number;
  77891. /**
  77892. * Are mip maps generated for this texture or not.
  77893. */
  77894. readonly noMipmap: boolean;
  77895. /**
  77896. * List of inspectable custom properties (used by the Inspector)
  77897. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77898. */
  77899. inspectableCustomProperties: Nullable<IInspectable[]>;
  77900. private _noMipmap;
  77901. /** @hidden */
  77902. _invertY: boolean;
  77903. private _rowGenerationMatrix;
  77904. private _cachedTextureMatrix;
  77905. private _projectionModeMatrix;
  77906. private _t0;
  77907. private _t1;
  77908. private _t2;
  77909. private _cachedUOffset;
  77910. private _cachedVOffset;
  77911. private _cachedUScale;
  77912. private _cachedVScale;
  77913. private _cachedUAng;
  77914. private _cachedVAng;
  77915. private _cachedWAng;
  77916. private _cachedProjectionMatrixId;
  77917. private _cachedCoordinatesMode;
  77918. /** @hidden */
  77919. protected _initialSamplingMode: number;
  77920. /** @hidden */
  77921. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  77922. private _deleteBuffer;
  77923. protected _format: Nullable<number>;
  77924. private _delayedOnLoad;
  77925. private _delayedOnError;
  77926. /**
  77927. * Observable triggered once the texture has been loaded.
  77928. */
  77929. onLoadObservable: Observable<Texture>;
  77930. protected _isBlocking: boolean;
  77931. /**
  77932. * Is the texture preventing material to render while loading.
  77933. * If false, a default texture will be used instead of the loading one during the preparation step.
  77934. */
  77935. isBlocking: boolean;
  77936. /**
  77937. * Get the current sampling mode associated with the texture.
  77938. */
  77939. readonly samplingMode: number;
  77940. /**
  77941. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  77942. */
  77943. readonly invertY: boolean;
  77944. /**
  77945. * Instantiates a new texture.
  77946. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  77947. * @see http://doc.babylonjs.com/babylon101/materials#texture
  77948. * @param url define the url of the picture to load as a texture
  77949. * @param scene define the scene the texture will belong to
  77950. * @param noMipmap define if the texture will require mip maps or not
  77951. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77952. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77953. * @param onLoad define a callback triggered when the texture has been loaded
  77954. * @param onError define a callback triggered when an error occurred during the loading session
  77955. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  77956. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  77957. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77958. */
  77959. constructor(url: Nullable<string>, scene: Nullable<Scene>, 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);
  77960. /**
  77961. * Update the url (and optional buffer) of this texture if url was null during construction.
  77962. * @param url the url of the texture
  77963. * @param buffer the buffer of the texture (defaults to null)
  77964. * @param onLoad callback called when the texture is loaded (defaults to null)
  77965. */
  77966. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  77967. /**
  77968. * Finish the loading sequence of a texture flagged as delayed load.
  77969. * @hidden
  77970. */
  77971. delayLoad(): void;
  77972. private _prepareRowForTextureGeneration;
  77973. /**
  77974. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  77975. * @returns the transform matrix of the texture.
  77976. */
  77977. getTextureMatrix(): Matrix;
  77978. /**
  77979. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  77980. * @returns The reflection texture transform
  77981. */
  77982. getReflectionTextureMatrix(): Matrix;
  77983. /**
  77984. * Clones the texture.
  77985. * @returns the cloned texture
  77986. */
  77987. clone(): Texture;
  77988. /**
  77989. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77990. * @returns The JSON representation of the texture
  77991. */
  77992. serialize(): any;
  77993. /**
  77994. * Get the current class name of the texture useful for serialization or dynamic coding.
  77995. * @returns "Texture"
  77996. */
  77997. getClassName(): string;
  77998. /**
  77999. * Dispose the texture and release its associated resources.
  78000. */
  78001. dispose(): void;
  78002. /**
  78003. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  78004. * @param parsedTexture Define the JSON representation of the texture
  78005. * @param scene Define the scene the parsed texture should be instantiated in
  78006. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  78007. * @returns The parsed texture if successful
  78008. */
  78009. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  78010. /**
  78011. * Creates a texture from its base 64 representation.
  78012. * @param data Define the base64 payload without the data: prefix
  78013. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  78014. * @param scene Define the scene the texture should belong to
  78015. * @param noMipmap Forces the texture to not create mip map information if true
  78016. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78017. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78018. * @param onLoad define a callback triggered when the texture has been loaded
  78019. * @param onError define a callback triggered when an error occurred during the loading session
  78020. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78021. * @returns the created texture
  78022. */
  78023. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  78024. /**
  78025. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  78026. * @param data Define the base64 payload without the data: prefix
  78027. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  78028. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  78029. * @param scene Define the scene the texture should belong to
  78030. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  78031. * @param noMipmap Forces the texture to not create mip map information if true
  78032. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78033. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78034. * @param onLoad define a callback triggered when the texture has been loaded
  78035. * @param onError define a callback triggered when an error occurred during the loading session
  78036. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78037. * @returns the created texture
  78038. */
  78039. 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;
  78040. }
  78041. }
  78042. declare module BABYLON {
  78043. interface Engine {
  78044. /**
  78045. * Creates a raw texture
  78046. * @param data defines the data to store in the texture
  78047. * @param width defines the width of the texture
  78048. * @param height defines the height of the texture
  78049. * @param format defines the format of the data
  78050. * @param generateMipMaps defines if the engine should generate the mip levels
  78051. * @param invertY defines if data must be stored with Y axis inverted
  78052. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78053. * @param compression defines the compression used (null by default)
  78054. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78055. * @returns the raw texture inside an InternalTexture
  78056. */
  78057. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  78058. /**
  78059. * Update a raw texture
  78060. * @param texture defines the texture to update
  78061. * @param data defines the data to store in the texture
  78062. * @param format defines the format of the data
  78063. * @param invertY defines if data must be stored with Y axis inverted
  78064. */
  78065. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78066. /**
  78067. * Update a raw texture
  78068. * @param texture defines the texture to update
  78069. * @param data defines the data to store in the texture
  78070. * @param format defines the format of the data
  78071. * @param invertY defines if data must be stored with Y axis inverted
  78072. * @param compression defines the compression used (null by default)
  78073. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78074. */
  78075. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  78076. /**
  78077. * Creates a new raw cube texture
  78078. * @param data defines the array of data to use to create each face
  78079. * @param size defines the size of the textures
  78080. * @param format defines the format of the data
  78081. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78082. * @param generateMipMaps defines if the engine should generate the mip levels
  78083. * @param invertY defines if data must be stored with Y axis inverted
  78084. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78085. * @param compression defines the compression used (null by default)
  78086. * @returns the cube texture as an InternalTexture
  78087. */
  78088. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  78089. /**
  78090. * Update a raw cube texture
  78091. * @param texture defines the texture to udpdate
  78092. * @param data defines the data to store
  78093. * @param format defines the data format
  78094. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78095. * @param invertY defines if data must be stored with Y axis inverted
  78096. */
  78097. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  78098. /**
  78099. * Update a raw cube texture
  78100. * @param texture defines the texture to udpdate
  78101. * @param data defines the data to store
  78102. * @param format defines the data format
  78103. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78104. * @param invertY defines if data must be stored with Y axis inverted
  78105. * @param compression defines the compression used (null by default)
  78106. */
  78107. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  78108. /**
  78109. * Update a raw cube texture
  78110. * @param texture defines the texture to udpdate
  78111. * @param data defines the data to store
  78112. * @param format defines the data format
  78113. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78114. * @param invertY defines if data must be stored with Y axis inverted
  78115. * @param compression defines the compression used (null by default)
  78116. * @param level defines which level of the texture to update
  78117. */
  78118. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  78119. /**
  78120. * Creates a new raw cube texture from a specified url
  78121. * @param url defines the url where the data is located
  78122. * @param scene defines the current scene
  78123. * @param size defines the size of the textures
  78124. * @param format defines the format of the data
  78125. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78126. * @param noMipmap defines if the engine should avoid generating the mip levels
  78127. * @param callback defines a callback used to extract texture data from loaded data
  78128. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78129. * @param onLoad defines a callback called when texture is loaded
  78130. * @param onError defines a callback called if there is an error
  78131. * @returns the cube texture as an InternalTexture
  78132. */
  78133. 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;
  78134. /**
  78135. * Creates a new raw cube texture from a specified url
  78136. * @param url defines the url where the data is located
  78137. * @param scene defines the current scene
  78138. * @param size defines the size of the textures
  78139. * @param format defines the format of the data
  78140. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78141. * @param noMipmap defines if the engine should avoid generating the mip levels
  78142. * @param callback defines a callback used to extract texture data from loaded data
  78143. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78144. * @param onLoad defines a callback called when texture is loaded
  78145. * @param onError defines a callback called if there is an error
  78146. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78147. * @param invertY defines if data must be stored with Y axis inverted
  78148. * @returns the cube texture as an InternalTexture
  78149. */
  78150. 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;
  78151. /**
  78152. * Creates a new raw 3D texture
  78153. * @param data defines the data used to create the texture
  78154. * @param width defines the width of the texture
  78155. * @param height defines the height of the texture
  78156. * @param depth defines the depth of the texture
  78157. * @param format defines the format of the texture
  78158. * @param generateMipMaps defines if the engine must generate mip levels
  78159. * @param invertY defines if data must be stored with Y axis inverted
  78160. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78161. * @param compression defines the compressed used (can be null)
  78162. * @param textureType defines the compressed used (can be null)
  78163. * @returns a new raw 3D texture (stored in an InternalTexture)
  78164. */
  78165. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  78166. /**
  78167. * Update a raw 3D texture
  78168. * @param texture defines the texture to update
  78169. * @param data defines the data to store
  78170. * @param format defines the data format
  78171. * @param invertY defines if data must be stored with Y axis inverted
  78172. */
  78173. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78174. /**
  78175. * Update a raw 3D texture
  78176. * @param texture defines the texture to update
  78177. * @param data defines the data to store
  78178. * @param format defines the data format
  78179. * @param invertY defines if data must be stored with Y axis inverted
  78180. * @param compression defines the used compression (can be null)
  78181. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  78182. */
  78183. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  78184. }
  78185. }
  78186. declare module BABYLON {
  78187. /**
  78188. * Raw texture can help creating a texture directly from an array of data.
  78189. * This can be super useful if you either get the data from an uncompressed source or
  78190. * if you wish to create your texture pixel by pixel.
  78191. */
  78192. export class RawTexture extends Texture {
  78193. /**
  78194. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78195. */
  78196. format: number;
  78197. private _engine;
  78198. /**
  78199. * Instantiates a new RawTexture.
  78200. * Raw texture can help creating a texture directly from an array of data.
  78201. * This can be super useful if you either get the data from an uncompressed source or
  78202. * if you wish to create your texture pixel by pixel.
  78203. * @param data define the array of data to use to create the texture
  78204. * @param width define the width of the texture
  78205. * @param height define the height of the texture
  78206. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78207. * @param scene define the scene the texture belongs to
  78208. * @param generateMipMaps define whether mip maps should be generated or not
  78209. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78210. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78211. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78212. */
  78213. constructor(data: ArrayBufferView, width: number, height: number,
  78214. /**
  78215. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78216. */
  78217. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  78218. /**
  78219. * Updates the texture underlying data.
  78220. * @param data Define the new data of the texture
  78221. */
  78222. update(data: ArrayBufferView): void;
  78223. /**
  78224. * Creates a luminance texture from some data.
  78225. * @param data Define the texture data
  78226. * @param width Define the width of the texture
  78227. * @param height Define the height of the texture
  78228. * @param scene Define the scene the texture belongs to
  78229. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78230. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78231. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78232. * @returns the luminance texture
  78233. */
  78234. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78235. /**
  78236. * Creates a luminance alpha texture from some data.
  78237. * @param data Define the texture data
  78238. * @param width Define the width of the texture
  78239. * @param height Define the height of the texture
  78240. * @param scene Define the scene the texture belongs to
  78241. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78242. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78243. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78244. * @returns the luminance alpha texture
  78245. */
  78246. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78247. /**
  78248. * Creates an alpha texture from some data.
  78249. * @param data Define the texture data
  78250. * @param width Define the width of the texture
  78251. * @param height Define the height of the texture
  78252. * @param scene Define the scene the texture belongs to
  78253. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78254. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78255. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78256. * @returns the alpha texture
  78257. */
  78258. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78259. /**
  78260. * Creates a RGB texture from some data.
  78261. * @param data Define the texture data
  78262. * @param width Define the width of the texture
  78263. * @param height Define the height of the texture
  78264. * @param scene Define the scene the texture belongs to
  78265. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78266. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78267. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78268. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78269. * @returns the RGB alpha texture
  78270. */
  78271. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78272. /**
  78273. * Creates a RGBA texture from some data.
  78274. * @param data Define the texture data
  78275. * @param width Define the width of the texture
  78276. * @param height Define the height of the texture
  78277. * @param scene Define the scene the texture belongs to
  78278. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78279. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78280. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78281. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78282. * @returns the RGBA texture
  78283. */
  78284. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78285. /**
  78286. * Creates a R texture from some data.
  78287. * @param data Define the texture data
  78288. * @param width Define the width of the texture
  78289. * @param height Define the height of the texture
  78290. * @param scene Define the scene the texture belongs to
  78291. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78292. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78293. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78294. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78295. * @returns the R texture
  78296. */
  78297. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78298. }
  78299. }
  78300. declare module BABYLON {
  78301. /**
  78302. * Defines a runtime animation
  78303. */
  78304. export class RuntimeAnimation {
  78305. private _events;
  78306. /**
  78307. * The current frame of the runtime animation
  78308. */
  78309. private _currentFrame;
  78310. /**
  78311. * The animation used by the runtime animation
  78312. */
  78313. private _animation;
  78314. /**
  78315. * The target of the runtime animation
  78316. */
  78317. private _target;
  78318. /**
  78319. * The initiating animatable
  78320. */
  78321. private _host;
  78322. /**
  78323. * The original value of the runtime animation
  78324. */
  78325. private _originalValue;
  78326. /**
  78327. * The original blend value of the runtime animation
  78328. */
  78329. private _originalBlendValue;
  78330. /**
  78331. * The offsets cache of the runtime animation
  78332. */
  78333. private _offsetsCache;
  78334. /**
  78335. * The high limits cache of the runtime animation
  78336. */
  78337. private _highLimitsCache;
  78338. /**
  78339. * Specifies if the runtime animation has been stopped
  78340. */
  78341. private _stopped;
  78342. /**
  78343. * The blending factor of the runtime animation
  78344. */
  78345. private _blendingFactor;
  78346. /**
  78347. * The BabylonJS scene
  78348. */
  78349. private _scene;
  78350. /**
  78351. * The current value of the runtime animation
  78352. */
  78353. private _currentValue;
  78354. /** @hidden */
  78355. _animationState: _IAnimationState;
  78356. /**
  78357. * The active target of the runtime animation
  78358. */
  78359. private _activeTargets;
  78360. private _currentActiveTarget;
  78361. private _directTarget;
  78362. /**
  78363. * The target path of the runtime animation
  78364. */
  78365. private _targetPath;
  78366. /**
  78367. * The weight of the runtime animation
  78368. */
  78369. private _weight;
  78370. /**
  78371. * The ratio offset of the runtime animation
  78372. */
  78373. private _ratioOffset;
  78374. /**
  78375. * The previous delay of the runtime animation
  78376. */
  78377. private _previousDelay;
  78378. /**
  78379. * The previous ratio of the runtime animation
  78380. */
  78381. private _previousRatio;
  78382. private _enableBlending;
  78383. private _keys;
  78384. private _minFrame;
  78385. private _maxFrame;
  78386. private _minValue;
  78387. private _maxValue;
  78388. private _targetIsArray;
  78389. /**
  78390. * Gets the current frame of the runtime animation
  78391. */
  78392. readonly currentFrame: number;
  78393. /**
  78394. * Gets the weight of the runtime animation
  78395. */
  78396. readonly weight: number;
  78397. /**
  78398. * Gets the current value of the runtime animation
  78399. */
  78400. readonly currentValue: any;
  78401. /**
  78402. * Gets the target path of the runtime animation
  78403. */
  78404. readonly targetPath: string;
  78405. /**
  78406. * Gets the actual target of the runtime animation
  78407. */
  78408. readonly target: any;
  78409. /** @hidden */
  78410. _onLoop: () => void;
  78411. /**
  78412. * Create a new RuntimeAnimation object
  78413. * @param target defines the target of the animation
  78414. * @param animation defines the source animation object
  78415. * @param scene defines the hosting scene
  78416. * @param host defines the initiating Animatable
  78417. */
  78418. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  78419. private _preparePath;
  78420. /**
  78421. * Gets the animation from the runtime animation
  78422. */
  78423. readonly animation: Animation;
  78424. /**
  78425. * Resets the runtime animation to the beginning
  78426. * @param restoreOriginal defines whether to restore the target property to the original value
  78427. */
  78428. reset(restoreOriginal?: boolean): void;
  78429. /**
  78430. * Specifies if the runtime animation is stopped
  78431. * @returns Boolean specifying if the runtime animation is stopped
  78432. */
  78433. isStopped(): boolean;
  78434. /**
  78435. * Disposes of the runtime animation
  78436. */
  78437. dispose(): void;
  78438. /**
  78439. * Apply the interpolated value to the target
  78440. * @param currentValue defines the value computed by the animation
  78441. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  78442. */
  78443. setValue(currentValue: any, weight: number): void;
  78444. private _getOriginalValues;
  78445. private _setValue;
  78446. /**
  78447. * Gets the loop pmode of the runtime animation
  78448. * @returns Loop Mode
  78449. */
  78450. private _getCorrectLoopMode;
  78451. /**
  78452. * Move the current animation to a given frame
  78453. * @param frame defines the frame to move to
  78454. */
  78455. goToFrame(frame: number): void;
  78456. /**
  78457. * @hidden Internal use only
  78458. */
  78459. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  78460. /**
  78461. * Execute the current animation
  78462. * @param delay defines the delay to add to the current frame
  78463. * @param from defines the lower bound of the animation range
  78464. * @param to defines the upper bound of the animation range
  78465. * @param loop defines if the current animation must loop
  78466. * @param speedRatio defines the current speed ratio
  78467. * @param weight defines the weight of the animation (default is -1 so no weight)
  78468. * @param onLoop optional callback called when animation loops
  78469. * @returns a boolean indicating if the animation is running
  78470. */
  78471. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  78472. }
  78473. }
  78474. declare module BABYLON {
  78475. /**
  78476. * Class used to store an actual running animation
  78477. */
  78478. export class Animatable {
  78479. /** defines the target object */
  78480. target: any;
  78481. /** defines the starting frame number (default is 0) */
  78482. fromFrame: number;
  78483. /** defines the ending frame number (default is 100) */
  78484. toFrame: number;
  78485. /** defines if the animation must loop (default is false) */
  78486. loopAnimation: boolean;
  78487. /** defines a callback to call when animation ends if it is not looping */
  78488. onAnimationEnd?: (() => void) | null | undefined;
  78489. /** defines a callback to call when animation loops */
  78490. onAnimationLoop?: (() => void) | null | undefined;
  78491. private _localDelayOffset;
  78492. private _pausedDelay;
  78493. private _runtimeAnimations;
  78494. private _paused;
  78495. private _scene;
  78496. private _speedRatio;
  78497. private _weight;
  78498. private _syncRoot;
  78499. /**
  78500. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  78501. * This will only apply for non looping animation (default is true)
  78502. */
  78503. disposeOnEnd: boolean;
  78504. /**
  78505. * Gets a boolean indicating if the animation has started
  78506. */
  78507. animationStarted: boolean;
  78508. /**
  78509. * Observer raised when the animation ends
  78510. */
  78511. onAnimationEndObservable: Observable<Animatable>;
  78512. /**
  78513. * Observer raised when the animation loops
  78514. */
  78515. onAnimationLoopObservable: Observable<Animatable>;
  78516. /**
  78517. * Gets the root Animatable used to synchronize and normalize animations
  78518. */
  78519. readonly syncRoot: Nullable<Animatable>;
  78520. /**
  78521. * Gets the current frame of the first RuntimeAnimation
  78522. * Used to synchronize Animatables
  78523. */
  78524. readonly masterFrame: number;
  78525. /**
  78526. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  78527. */
  78528. weight: number;
  78529. /**
  78530. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  78531. */
  78532. speedRatio: number;
  78533. /**
  78534. * Creates a new Animatable
  78535. * @param scene defines the hosting scene
  78536. * @param target defines the target object
  78537. * @param fromFrame defines the starting frame number (default is 0)
  78538. * @param toFrame defines the ending frame number (default is 100)
  78539. * @param loopAnimation defines if the animation must loop (default is false)
  78540. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  78541. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  78542. * @param animations defines a group of animation to add to the new Animatable
  78543. * @param onAnimationLoop defines a callback to call when animation loops
  78544. */
  78545. constructor(scene: Scene,
  78546. /** defines the target object */
  78547. target: any,
  78548. /** defines the starting frame number (default is 0) */
  78549. fromFrame?: number,
  78550. /** defines the ending frame number (default is 100) */
  78551. toFrame?: number,
  78552. /** defines if the animation must loop (default is false) */
  78553. loopAnimation?: boolean, speedRatio?: number,
  78554. /** defines a callback to call when animation ends if it is not looping */
  78555. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  78556. /** defines a callback to call when animation loops */
  78557. onAnimationLoop?: (() => void) | null | undefined);
  78558. /**
  78559. * Synchronize and normalize current Animatable with a source Animatable
  78560. * This is useful when using animation weights and when animations are not of the same length
  78561. * @param root defines the root Animatable to synchronize with
  78562. * @returns the current Animatable
  78563. */
  78564. syncWith(root: Animatable): Animatable;
  78565. /**
  78566. * Gets the list of runtime animations
  78567. * @returns an array of RuntimeAnimation
  78568. */
  78569. getAnimations(): RuntimeAnimation[];
  78570. /**
  78571. * Adds more animations to the current animatable
  78572. * @param target defines the target of the animations
  78573. * @param animations defines the new animations to add
  78574. */
  78575. appendAnimations(target: any, animations: Animation[]): void;
  78576. /**
  78577. * Gets the source animation for a specific property
  78578. * @param property defines the propertyu to look for
  78579. * @returns null or the source animation for the given property
  78580. */
  78581. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  78582. /**
  78583. * Gets the runtime animation for a specific property
  78584. * @param property defines the propertyu to look for
  78585. * @returns null or the runtime animation for the given property
  78586. */
  78587. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  78588. /**
  78589. * Resets the animatable to its original state
  78590. */
  78591. reset(): void;
  78592. /**
  78593. * Allows the animatable to blend with current running animations
  78594. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78595. * @param blendingSpeed defines the blending speed to use
  78596. */
  78597. enableBlending(blendingSpeed: number): void;
  78598. /**
  78599. * Disable animation blending
  78600. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78601. */
  78602. disableBlending(): void;
  78603. /**
  78604. * Jump directly to a given frame
  78605. * @param frame defines the frame to jump to
  78606. */
  78607. goToFrame(frame: number): void;
  78608. /**
  78609. * Pause the animation
  78610. */
  78611. pause(): void;
  78612. /**
  78613. * Restart the animation
  78614. */
  78615. restart(): void;
  78616. private _raiseOnAnimationEnd;
  78617. /**
  78618. * Stop and delete the current animation
  78619. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  78620. * @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)
  78621. */
  78622. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  78623. /**
  78624. * Wait asynchronously for the animation to end
  78625. * @returns a promise which will be fullfilled when the animation ends
  78626. */
  78627. waitAsync(): Promise<Animatable>;
  78628. /** @hidden */
  78629. _animate(delay: number): boolean;
  78630. }
  78631. interface Scene {
  78632. /** @hidden */
  78633. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78634. /** @hidden */
  78635. _processLateAnimationBindingsForMatrices(holder: {
  78636. totalWeight: number;
  78637. animations: RuntimeAnimation[];
  78638. originalValue: Matrix;
  78639. }): any;
  78640. /** @hidden */
  78641. _processLateAnimationBindingsForQuaternions(holder: {
  78642. totalWeight: number;
  78643. animations: RuntimeAnimation[];
  78644. originalValue: Quaternion;
  78645. }, refQuaternion: Quaternion): Quaternion;
  78646. /** @hidden */
  78647. _processLateAnimationBindings(): void;
  78648. /**
  78649. * Will start the animation sequence of a given target
  78650. * @param target defines the target
  78651. * @param from defines from which frame should animation start
  78652. * @param to defines until which frame should animation run.
  78653. * @param weight defines the weight to apply to the animation (1.0 by default)
  78654. * @param loop defines if the animation loops
  78655. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78656. * @param onAnimationEnd defines the function to be executed when the animation ends
  78657. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78658. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78659. * @param onAnimationLoop defines the callback to call when an animation loops
  78660. * @returns the animatable object created for this animation
  78661. */
  78662. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78663. /**
  78664. * Will start the animation sequence of a given target
  78665. * @param target defines the target
  78666. * @param from defines from which frame should animation start
  78667. * @param to defines until which frame should animation run.
  78668. * @param loop defines if the animation loops
  78669. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78670. * @param onAnimationEnd defines the function to be executed when the animation ends
  78671. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78672. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78673. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78674. * @param onAnimationLoop defines the callback to call when an animation loops
  78675. * @returns the animatable object created for this animation
  78676. */
  78677. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78678. /**
  78679. * Will start the animation sequence of a given target and its hierarchy
  78680. * @param target defines the target
  78681. * @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.
  78682. * @param from defines from which frame should animation start
  78683. * @param to defines until which frame should animation run.
  78684. * @param loop defines if the animation loops
  78685. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78686. * @param onAnimationEnd defines the function to be executed when the animation ends
  78687. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78688. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78689. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78690. * @param onAnimationLoop defines the callback to call when an animation loops
  78691. * @returns the list of created animatables
  78692. */
  78693. 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[];
  78694. /**
  78695. * Begin a new animation on a given node
  78696. * @param target defines the target where the animation will take place
  78697. * @param animations defines the list of animations to start
  78698. * @param from defines the initial value
  78699. * @param to defines the final value
  78700. * @param loop defines if you want animation to loop (off by default)
  78701. * @param speedRatio defines the speed ratio to apply to all animations
  78702. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78703. * @param onAnimationLoop defines the callback to call when an animation loops
  78704. * @returns the list of created animatables
  78705. */
  78706. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  78707. /**
  78708. * Begin a new animation on a given node and its hierarchy
  78709. * @param target defines the root node where the animation will take place
  78710. * @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.
  78711. * @param animations defines the list of animations to start
  78712. * @param from defines the initial value
  78713. * @param to defines the final value
  78714. * @param loop defines if you want animation to loop (off by default)
  78715. * @param speedRatio defines the speed ratio to apply to all animations
  78716. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78717. * @param onAnimationLoop defines the callback to call when an animation loops
  78718. * @returns the list of animatables created for all nodes
  78719. */
  78720. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  78721. /**
  78722. * Gets the animatable associated with a specific target
  78723. * @param target defines the target of the animatable
  78724. * @returns the required animatable if found
  78725. */
  78726. getAnimatableByTarget(target: any): Nullable<Animatable>;
  78727. /**
  78728. * Gets all animatables associated with a given target
  78729. * @param target defines the target to look animatables for
  78730. * @returns an array of Animatables
  78731. */
  78732. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  78733. /**
  78734. * Will stop the animation of the given target
  78735. * @param target - the target
  78736. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  78737. * @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)
  78738. */
  78739. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  78740. /**
  78741. * Stops and removes all animations that have been applied to the scene
  78742. */
  78743. stopAllAnimations(): void;
  78744. }
  78745. interface Bone {
  78746. /**
  78747. * Copy an animation range from another bone
  78748. * @param source defines the source bone
  78749. * @param rangeName defines the range name to copy
  78750. * @param frameOffset defines the frame offset
  78751. * @param rescaleAsRequired defines if rescaling must be applied if required
  78752. * @param skelDimensionsRatio defines the scaling ratio
  78753. * @returns true if operation was successful
  78754. */
  78755. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  78756. }
  78757. }
  78758. declare module BABYLON {
  78759. /**
  78760. * Class used to handle skinning animations
  78761. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78762. */
  78763. export class Skeleton implements IAnimatable {
  78764. /** defines the skeleton name */
  78765. name: string;
  78766. /** defines the skeleton Id */
  78767. id: string;
  78768. /**
  78769. * Defines the list of child bones
  78770. */
  78771. bones: Bone[];
  78772. /**
  78773. * Defines an estimate of the dimension of the skeleton at rest
  78774. */
  78775. dimensionsAtRest: Vector3;
  78776. /**
  78777. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  78778. */
  78779. needInitialSkinMatrix: boolean;
  78780. /**
  78781. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  78782. */
  78783. overrideMesh: Nullable<AbstractMesh>;
  78784. /**
  78785. * Gets the list of animations attached to this skeleton
  78786. */
  78787. animations: Array<Animation>;
  78788. private _scene;
  78789. private _isDirty;
  78790. private _transformMatrices;
  78791. private _transformMatrixTexture;
  78792. private _meshesWithPoseMatrix;
  78793. private _animatables;
  78794. private _identity;
  78795. private _synchronizedWithMesh;
  78796. private _ranges;
  78797. private _lastAbsoluteTransformsUpdateId;
  78798. private _canUseTextureForBones;
  78799. private _uniqueId;
  78800. /** @hidden */
  78801. _numBonesWithLinkedTransformNode: number;
  78802. /**
  78803. * Specifies if the skeleton should be serialized
  78804. */
  78805. doNotSerialize: boolean;
  78806. private _useTextureToStoreBoneMatrices;
  78807. /**
  78808. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  78809. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  78810. */
  78811. useTextureToStoreBoneMatrices: boolean;
  78812. private _animationPropertiesOverride;
  78813. /**
  78814. * Gets or sets the animation properties override
  78815. */
  78816. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78817. /**
  78818. * List of inspectable custom properties (used by the Inspector)
  78819. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78820. */
  78821. inspectableCustomProperties: IInspectable[];
  78822. /**
  78823. * An observable triggered before computing the skeleton's matrices
  78824. */
  78825. onBeforeComputeObservable: Observable<Skeleton>;
  78826. /**
  78827. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  78828. */
  78829. readonly isUsingTextureForMatrices: boolean;
  78830. /**
  78831. * Gets the unique ID of this skeleton
  78832. */
  78833. readonly uniqueId: number;
  78834. /**
  78835. * Creates a new skeleton
  78836. * @param name defines the skeleton name
  78837. * @param id defines the skeleton Id
  78838. * @param scene defines the hosting scene
  78839. */
  78840. constructor(
  78841. /** defines the skeleton name */
  78842. name: string,
  78843. /** defines the skeleton Id */
  78844. id: string, scene: Scene);
  78845. /**
  78846. * Gets the current object class name.
  78847. * @return the class name
  78848. */
  78849. getClassName(): string;
  78850. /**
  78851. * Returns an array containing the root bones
  78852. * @returns an array containing the root bones
  78853. */
  78854. getChildren(): Array<Bone>;
  78855. /**
  78856. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  78857. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78858. * @returns a Float32Array containing matrices data
  78859. */
  78860. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  78861. /**
  78862. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  78863. * @returns a raw texture containing the data
  78864. */
  78865. getTransformMatrixTexture(): Nullable<RawTexture>;
  78866. /**
  78867. * Gets the current hosting scene
  78868. * @returns a scene object
  78869. */
  78870. getScene(): Scene;
  78871. /**
  78872. * Gets a string representing the current skeleton data
  78873. * @param fullDetails defines a boolean indicating if we want a verbose version
  78874. * @returns a string representing the current skeleton data
  78875. */
  78876. toString(fullDetails?: boolean): string;
  78877. /**
  78878. * Get bone's index searching by name
  78879. * @param name defines bone's name to search for
  78880. * @return the indice of the bone. Returns -1 if not found
  78881. */
  78882. getBoneIndexByName(name: string): number;
  78883. /**
  78884. * Creater a new animation range
  78885. * @param name defines the name of the range
  78886. * @param from defines the start key
  78887. * @param to defines the end key
  78888. */
  78889. createAnimationRange(name: string, from: number, to: number): void;
  78890. /**
  78891. * Delete a specific animation range
  78892. * @param name defines the name of the range
  78893. * @param deleteFrames defines if frames must be removed as well
  78894. */
  78895. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  78896. /**
  78897. * Gets a specific animation range
  78898. * @param name defines the name of the range to look for
  78899. * @returns the requested animation range or null if not found
  78900. */
  78901. getAnimationRange(name: string): Nullable<AnimationRange>;
  78902. /**
  78903. * Gets the list of all animation ranges defined on this skeleton
  78904. * @returns an array
  78905. */
  78906. getAnimationRanges(): Nullable<AnimationRange>[];
  78907. /**
  78908. * Copy animation range from a source skeleton.
  78909. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  78910. * @param source defines the source skeleton
  78911. * @param name defines the name of the range to copy
  78912. * @param rescaleAsRequired defines if rescaling must be applied if required
  78913. * @returns true if operation was successful
  78914. */
  78915. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  78916. /**
  78917. * Forces the skeleton to go to rest pose
  78918. */
  78919. returnToRest(): void;
  78920. private _getHighestAnimationFrame;
  78921. /**
  78922. * Begin a specific animation range
  78923. * @param name defines the name of the range to start
  78924. * @param loop defines if looping must be turned on (false by default)
  78925. * @param speedRatio defines the speed ratio to apply (1 by default)
  78926. * @param onAnimationEnd defines a callback which will be called when animation will end
  78927. * @returns a new animatable
  78928. */
  78929. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  78930. /** @hidden */
  78931. _markAsDirty(): void;
  78932. /** @hidden */
  78933. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78934. /** @hidden */
  78935. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78936. private _computeTransformMatrices;
  78937. /**
  78938. * Build all resources required to render a skeleton
  78939. */
  78940. prepare(): void;
  78941. /**
  78942. * Gets the list of animatables currently running for this skeleton
  78943. * @returns an array of animatables
  78944. */
  78945. getAnimatables(): IAnimatable[];
  78946. /**
  78947. * Clone the current skeleton
  78948. * @param name defines the name of the new skeleton
  78949. * @param id defines the id of the new skeleton
  78950. * @returns the new skeleton
  78951. */
  78952. clone(name: string, id: string): Skeleton;
  78953. /**
  78954. * Enable animation blending for this skeleton
  78955. * @param blendingSpeed defines the blending speed to apply
  78956. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78957. */
  78958. enableBlending(blendingSpeed?: number): void;
  78959. /**
  78960. * Releases all resources associated with the current skeleton
  78961. */
  78962. dispose(): void;
  78963. /**
  78964. * Serialize the skeleton in a JSON object
  78965. * @returns a JSON object
  78966. */
  78967. serialize(): any;
  78968. /**
  78969. * Creates a new skeleton from serialized data
  78970. * @param parsedSkeleton defines the serialized data
  78971. * @param scene defines the hosting scene
  78972. * @returns a new skeleton
  78973. */
  78974. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  78975. /**
  78976. * Compute all node absolute transforms
  78977. * @param forceUpdate defines if computation must be done even if cache is up to date
  78978. */
  78979. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  78980. /**
  78981. * Gets the root pose matrix
  78982. * @returns a matrix
  78983. */
  78984. getPoseMatrix(): Nullable<Matrix>;
  78985. /**
  78986. * Sorts bones per internal index
  78987. */
  78988. sortBones(): void;
  78989. private _sortBones;
  78990. }
  78991. }
  78992. declare module BABYLON {
  78993. /**
  78994. * Defines a target to use with MorphTargetManager
  78995. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78996. */
  78997. export class MorphTarget implements IAnimatable {
  78998. /** defines the name of the target */
  78999. name: string;
  79000. /**
  79001. * Gets or sets the list of animations
  79002. */
  79003. animations: Animation[];
  79004. private _scene;
  79005. private _positions;
  79006. private _normals;
  79007. private _tangents;
  79008. private _influence;
  79009. /**
  79010. * Observable raised when the influence changes
  79011. */
  79012. onInfluenceChanged: Observable<boolean>;
  79013. /** @hidden */
  79014. _onDataLayoutChanged: Observable<void>;
  79015. /**
  79016. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  79017. */
  79018. influence: number;
  79019. /**
  79020. * Gets or sets the id of the morph Target
  79021. */
  79022. id: string;
  79023. private _animationPropertiesOverride;
  79024. /**
  79025. * Gets or sets the animation properties override
  79026. */
  79027. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79028. /**
  79029. * Creates a new MorphTarget
  79030. * @param name defines the name of the target
  79031. * @param influence defines the influence to use
  79032. * @param scene defines the scene the morphtarget belongs to
  79033. */
  79034. constructor(
  79035. /** defines the name of the target */
  79036. name: string, influence?: number, scene?: Nullable<Scene>);
  79037. /**
  79038. * Gets a boolean defining if the target contains position data
  79039. */
  79040. readonly hasPositions: boolean;
  79041. /**
  79042. * Gets a boolean defining if the target contains normal data
  79043. */
  79044. readonly hasNormals: boolean;
  79045. /**
  79046. * Gets a boolean defining if the target contains tangent data
  79047. */
  79048. readonly hasTangents: boolean;
  79049. /**
  79050. * Affects position data to this target
  79051. * @param data defines the position data to use
  79052. */
  79053. setPositions(data: Nullable<FloatArray>): void;
  79054. /**
  79055. * Gets the position data stored in this target
  79056. * @returns a FloatArray containing the position data (or null if not present)
  79057. */
  79058. getPositions(): Nullable<FloatArray>;
  79059. /**
  79060. * Affects normal data to this target
  79061. * @param data defines the normal data to use
  79062. */
  79063. setNormals(data: Nullable<FloatArray>): void;
  79064. /**
  79065. * Gets the normal data stored in this target
  79066. * @returns a FloatArray containing the normal data (or null if not present)
  79067. */
  79068. getNormals(): Nullable<FloatArray>;
  79069. /**
  79070. * Affects tangent data to this target
  79071. * @param data defines the tangent data to use
  79072. */
  79073. setTangents(data: Nullable<FloatArray>): void;
  79074. /**
  79075. * Gets the tangent data stored in this target
  79076. * @returns a FloatArray containing the tangent data (or null if not present)
  79077. */
  79078. getTangents(): Nullable<FloatArray>;
  79079. /**
  79080. * Serializes the current target into a Serialization object
  79081. * @returns the serialized object
  79082. */
  79083. serialize(): any;
  79084. /**
  79085. * Returns the string "MorphTarget"
  79086. * @returns "MorphTarget"
  79087. */
  79088. getClassName(): string;
  79089. /**
  79090. * Creates a new target from serialized data
  79091. * @param serializationObject defines the serialized data to use
  79092. * @returns a new MorphTarget
  79093. */
  79094. static Parse(serializationObject: any): MorphTarget;
  79095. /**
  79096. * Creates a MorphTarget from mesh data
  79097. * @param mesh defines the source mesh
  79098. * @param name defines the name to use for the new target
  79099. * @param influence defines the influence to attach to the target
  79100. * @returns a new MorphTarget
  79101. */
  79102. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  79103. }
  79104. }
  79105. declare module BABYLON {
  79106. /**
  79107. * This class is used to deform meshes using morphing between different targets
  79108. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79109. */
  79110. export class MorphTargetManager {
  79111. private _targets;
  79112. private _targetInfluenceChangedObservers;
  79113. private _targetDataLayoutChangedObservers;
  79114. private _activeTargets;
  79115. private _scene;
  79116. private _influences;
  79117. private _supportsNormals;
  79118. private _supportsTangents;
  79119. private _vertexCount;
  79120. private _uniqueId;
  79121. private _tempInfluences;
  79122. /**
  79123. * Creates a new MorphTargetManager
  79124. * @param scene defines the current scene
  79125. */
  79126. constructor(scene?: Nullable<Scene>);
  79127. /**
  79128. * Gets the unique ID of this manager
  79129. */
  79130. readonly uniqueId: number;
  79131. /**
  79132. * Gets the number of vertices handled by this manager
  79133. */
  79134. readonly vertexCount: number;
  79135. /**
  79136. * Gets a boolean indicating if this manager supports morphing of normals
  79137. */
  79138. readonly supportsNormals: boolean;
  79139. /**
  79140. * Gets a boolean indicating if this manager supports morphing of tangents
  79141. */
  79142. readonly supportsTangents: boolean;
  79143. /**
  79144. * Gets the number of targets stored in this manager
  79145. */
  79146. readonly numTargets: number;
  79147. /**
  79148. * Gets the number of influencers (ie. the number of targets with influences > 0)
  79149. */
  79150. readonly numInfluencers: number;
  79151. /**
  79152. * Gets the list of influences (one per target)
  79153. */
  79154. readonly influences: Float32Array;
  79155. /**
  79156. * Gets the active target at specified index. An active target is a target with an influence > 0
  79157. * @param index defines the index to check
  79158. * @returns the requested target
  79159. */
  79160. getActiveTarget(index: number): MorphTarget;
  79161. /**
  79162. * Gets the target at specified index
  79163. * @param index defines the index to check
  79164. * @returns the requested target
  79165. */
  79166. getTarget(index: number): MorphTarget;
  79167. /**
  79168. * Add a new target to this manager
  79169. * @param target defines the target to add
  79170. */
  79171. addTarget(target: MorphTarget): void;
  79172. /**
  79173. * Removes a target from the manager
  79174. * @param target defines the target to remove
  79175. */
  79176. removeTarget(target: MorphTarget): void;
  79177. /**
  79178. * Serializes the current manager into a Serialization object
  79179. * @returns the serialized object
  79180. */
  79181. serialize(): any;
  79182. private _syncActiveTargets;
  79183. /**
  79184. * Syncrhonize the targets with all the meshes using this morph target manager
  79185. */
  79186. synchronize(): void;
  79187. /**
  79188. * Creates a new MorphTargetManager from serialized data
  79189. * @param serializationObject defines the serialized data
  79190. * @param scene defines the hosting scene
  79191. * @returns the new MorphTargetManager
  79192. */
  79193. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  79194. }
  79195. }
  79196. declare module BABYLON {
  79197. /**
  79198. * Class used to represent a specific level of detail of a mesh
  79199. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79200. */
  79201. export class MeshLODLevel {
  79202. /** Defines the distance where this level should star being displayed */
  79203. distance: number;
  79204. /** Defines the mesh to use to render this level */
  79205. mesh: Nullable<Mesh>;
  79206. /**
  79207. * Creates a new LOD level
  79208. * @param distance defines the distance where this level should star being displayed
  79209. * @param mesh defines the mesh to use to render this level
  79210. */
  79211. constructor(
  79212. /** Defines the distance where this level should star being displayed */
  79213. distance: number,
  79214. /** Defines the mesh to use to render this level */
  79215. mesh: Nullable<Mesh>);
  79216. }
  79217. }
  79218. declare module BABYLON {
  79219. /**
  79220. * Mesh representing the gorund
  79221. */
  79222. export class GroundMesh extends Mesh {
  79223. /** If octree should be generated */
  79224. generateOctree: boolean;
  79225. private _heightQuads;
  79226. /** @hidden */
  79227. _subdivisionsX: number;
  79228. /** @hidden */
  79229. _subdivisionsY: number;
  79230. /** @hidden */
  79231. _width: number;
  79232. /** @hidden */
  79233. _height: number;
  79234. /** @hidden */
  79235. _minX: number;
  79236. /** @hidden */
  79237. _maxX: number;
  79238. /** @hidden */
  79239. _minZ: number;
  79240. /** @hidden */
  79241. _maxZ: number;
  79242. constructor(name: string, scene: Scene);
  79243. /**
  79244. * "GroundMesh"
  79245. * @returns "GroundMesh"
  79246. */
  79247. getClassName(): string;
  79248. /**
  79249. * The minimum of x and y subdivisions
  79250. */
  79251. readonly subdivisions: number;
  79252. /**
  79253. * X subdivisions
  79254. */
  79255. readonly subdivisionsX: number;
  79256. /**
  79257. * Y subdivisions
  79258. */
  79259. readonly subdivisionsY: number;
  79260. /**
  79261. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  79262. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  79263. * @param chunksCount the number of subdivisions for x and y
  79264. * @param octreeBlocksSize (Default: 32)
  79265. */
  79266. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  79267. /**
  79268. * Returns a height (y) value in the Worl system :
  79269. * the ground altitude at the coordinates (x, z) expressed in the World system.
  79270. * @param x x coordinate
  79271. * @param z z coordinate
  79272. * @returns the ground y position if (x, z) are outside the ground surface.
  79273. */
  79274. getHeightAtCoordinates(x: number, z: number): number;
  79275. /**
  79276. * Returns a normalized vector (Vector3) orthogonal to the ground
  79277. * at the ground coordinates (x, z) expressed in the World system.
  79278. * @param x x coordinate
  79279. * @param z z coordinate
  79280. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  79281. */
  79282. getNormalAtCoordinates(x: number, z: number): Vector3;
  79283. /**
  79284. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  79285. * at the ground coordinates (x, z) expressed in the World system.
  79286. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  79287. * @param x x coordinate
  79288. * @param z z coordinate
  79289. * @param ref vector to store the result
  79290. * @returns the GroundMesh.
  79291. */
  79292. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  79293. /**
  79294. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  79295. * if the ground has been updated.
  79296. * This can be used in the render loop.
  79297. * @returns the GroundMesh.
  79298. */
  79299. updateCoordinateHeights(): GroundMesh;
  79300. private _getFacetAt;
  79301. private _initHeightQuads;
  79302. private _computeHeightQuads;
  79303. /**
  79304. * Serializes this ground mesh
  79305. * @param serializationObject object to write serialization to
  79306. */
  79307. serialize(serializationObject: any): void;
  79308. /**
  79309. * Parses a serialized ground mesh
  79310. * @param parsedMesh the serialized mesh
  79311. * @param scene the scene to create the ground mesh in
  79312. * @returns the created ground mesh
  79313. */
  79314. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  79315. }
  79316. }
  79317. declare module BABYLON {
  79318. /**
  79319. * Interface for Physics-Joint data
  79320. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79321. */
  79322. export interface PhysicsJointData {
  79323. /**
  79324. * The main pivot of the joint
  79325. */
  79326. mainPivot?: Vector3;
  79327. /**
  79328. * The connected pivot of the joint
  79329. */
  79330. connectedPivot?: Vector3;
  79331. /**
  79332. * The main axis of the joint
  79333. */
  79334. mainAxis?: Vector3;
  79335. /**
  79336. * The connected axis of the joint
  79337. */
  79338. connectedAxis?: Vector3;
  79339. /**
  79340. * The collision of the joint
  79341. */
  79342. collision?: boolean;
  79343. /**
  79344. * Native Oimo/Cannon/Energy data
  79345. */
  79346. nativeParams?: any;
  79347. }
  79348. /**
  79349. * This is a holder class for the physics joint created by the physics plugin
  79350. * It holds a set of functions to control the underlying joint
  79351. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79352. */
  79353. export class PhysicsJoint {
  79354. /**
  79355. * The type of the physics joint
  79356. */
  79357. type: number;
  79358. /**
  79359. * The data for the physics joint
  79360. */
  79361. jointData: PhysicsJointData;
  79362. private _physicsJoint;
  79363. protected _physicsPlugin: IPhysicsEnginePlugin;
  79364. /**
  79365. * Initializes the physics joint
  79366. * @param type The type of the physics joint
  79367. * @param jointData The data for the physics joint
  79368. */
  79369. constructor(
  79370. /**
  79371. * The type of the physics joint
  79372. */
  79373. type: number,
  79374. /**
  79375. * The data for the physics joint
  79376. */
  79377. jointData: PhysicsJointData);
  79378. /**
  79379. * Gets the physics joint
  79380. */
  79381. /**
  79382. * Sets the physics joint
  79383. */
  79384. physicsJoint: any;
  79385. /**
  79386. * Sets the physics plugin
  79387. */
  79388. physicsPlugin: IPhysicsEnginePlugin;
  79389. /**
  79390. * Execute a function that is physics-plugin specific.
  79391. * @param {Function} func the function that will be executed.
  79392. * It accepts two parameters: the physics world and the physics joint
  79393. */
  79394. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  79395. /**
  79396. * Distance-Joint type
  79397. */
  79398. static DistanceJoint: number;
  79399. /**
  79400. * Hinge-Joint type
  79401. */
  79402. static HingeJoint: number;
  79403. /**
  79404. * Ball-and-Socket joint type
  79405. */
  79406. static BallAndSocketJoint: number;
  79407. /**
  79408. * Wheel-Joint type
  79409. */
  79410. static WheelJoint: number;
  79411. /**
  79412. * Slider-Joint type
  79413. */
  79414. static SliderJoint: number;
  79415. /**
  79416. * Prismatic-Joint type
  79417. */
  79418. static PrismaticJoint: number;
  79419. /**
  79420. * Universal-Joint type
  79421. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  79422. */
  79423. static UniversalJoint: number;
  79424. /**
  79425. * Hinge-Joint 2 type
  79426. */
  79427. static Hinge2Joint: number;
  79428. /**
  79429. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  79430. */
  79431. static PointToPointJoint: number;
  79432. /**
  79433. * Spring-Joint type
  79434. */
  79435. static SpringJoint: number;
  79436. /**
  79437. * Lock-Joint type
  79438. */
  79439. static LockJoint: number;
  79440. }
  79441. /**
  79442. * A class representing a physics distance joint
  79443. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79444. */
  79445. export class DistanceJoint extends PhysicsJoint {
  79446. /**
  79447. *
  79448. * @param jointData The data for the Distance-Joint
  79449. */
  79450. constructor(jointData: DistanceJointData);
  79451. /**
  79452. * Update the predefined distance.
  79453. * @param maxDistance The maximum preferred distance
  79454. * @param minDistance The minimum preferred distance
  79455. */
  79456. updateDistance(maxDistance: number, minDistance?: number): void;
  79457. }
  79458. /**
  79459. * Represents a Motor-Enabled Joint
  79460. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79461. */
  79462. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  79463. /**
  79464. * Initializes the Motor-Enabled Joint
  79465. * @param type The type of the joint
  79466. * @param jointData The physica joint data for the joint
  79467. */
  79468. constructor(type: number, jointData: PhysicsJointData);
  79469. /**
  79470. * Set the motor values.
  79471. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79472. * @param force the force to apply
  79473. * @param maxForce max force for this motor.
  79474. */
  79475. setMotor(force?: number, maxForce?: number): void;
  79476. /**
  79477. * Set the motor's limits.
  79478. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79479. * @param upperLimit The upper limit of the motor
  79480. * @param lowerLimit The lower limit of the motor
  79481. */
  79482. setLimit(upperLimit: number, lowerLimit?: number): void;
  79483. }
  79484. /**
  79485. * This class represents a single physics Hinge-Joint
  79486. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79487. */
  79488. export class HingeJoint extends MotorEnabledJoint {
  79489. /**
  79490. * Initializes the Hinge-Joint
  79491. * @param jointData The joint data for the Hinge-Joint
  79492. */
  79493. constructor(jointData: PhysicsJointData);
  79494. /**
  79495. * Set the motor values.
  79496. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79497. * @param {number} force the force to apply
  79498. * @param {number} maxForce max force for this motor.
  79499. */
  79500. setMotor(force?: number, maxForce?: number): void;
  79501. /**
  79502. * Set the motor's limits.
  79503. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79504. * @param upperLimit The upper limit of the motor
  79505. * @param lowerLimit The lower limit of the motor
  79506. */
  79507. setLimit(upperLimit: number, lowerLimit?: number): void;
  79508. }
  79509. /**
  79510. * This class represents a dual hinge physics joint (same as wheel joint)
  79511. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79512. */
  79513. export class Hinge2Joint extends MotorEnabledJoint {
  79514. /**
  79515. * Initializes the Hinge2-Joint
  79516. * @param jointData The joint data for the Hinge2-Joint
  79517. */
  79518. constructor(jointData: PhysicsJointData);
  79519. /**
  79520. * Set the motor values.
  79521. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79522. * @param {number} targetSpeed the speed the motor is to reach
  79523. * @param {number} maxForce max force for this motor.
  79524. * @param {motorIndex} the motor's index, 0 or 1.
  79525. */
  79526. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  79527. /**
  79528. * Set the motor limits.
  79529. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79530. * @param {number} upperLimit the upper limit
  79531. * @param {number} lowerLimit lower limit
  79532. * @param {motorIndex} the motor's index, 0 or 1.
  79533. */
  79534. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79535. }
  79536. /**
  79537. * Interface for a motor enabled joint
  79538. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79539. */
  79540. export interface IMotorEnabledJoint {
  79541. /**
  79542. * Physics joint
  79543. */
  79544. physicsJoint: any;
  79545. /**
  79546. * Sets the motor of the motor-enabled joint
  79547. * @param force The force of the motor
  79548. * @param maxForce The maximum force of the motor
  79549. * @param motorIndex The index of the motor
  79550. */
  79551. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  79552. /**
  79553. * Sets the limit of the motor
  79554. * @param upperLimit The upper limit of the motor
  79555. * @param lowerLimit The lower limit of the motor
  79556. * @param motorIndex The index of the motor
  79557. */
  79558. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79559. }
  79560. /**
  79561. * Joint data for a Distance-Joint
  79562. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79563. */
  79564. export interface DistanceJointData extends PhysicsJointData {
  79565. /**
  79566. * Max distance the 2 joint objects can be apart
  79567. */
  79568. maxDistance: number;
  79569. }
  79570. /**
  79571. * Joint data from a spring joint
  79572. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79573. */
  79574. export interface SpringJointData extends PhysicsJointData {
  79575. /**
  79576. * Length of the spring
  79577. */
  79578. length: number;
  79579. /**
  79580. * Stiffness of the spring
  79581. */
  79582. stiffness: number;
  79583. /**
  79584. * Damping of the spring
  79585. */
  79586. damping: number;
  79587. /** this callback will be called when applying the force to the impostors. */
  79588. forceApplicationCallback: () => void;
  79589. }
  79590. }
  79591. declare module BABYLON {
  79592. /**
  79593. * Holds the data for the raycast result
  79594. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79595. */
  79596. export class PhysicsRaycastResult {
  79597. private _hasHit;
  79598. private _hitDistance;
  79599. private _hitNormalWorld;
  79600. private _hitPointWorld;
  79601. private _rayFromWorld;
  79602. private _rayToWorld;
  79603. /**
  79604. * Gets if there was a hit
  79605. */
  79606. readonly hasHit: boolean;
  79607. /**
  79608. * Gets the distance from the hit
  79609. */
  79610. readonly hitDistance: number;
  79611. /**
  79612. * Gets the hit normal/direction in the world
  79613. */
  79614. readonly hitNormalWorld: Vector3;
  79615. /**
  79616. * Gets the hit point in the world
  79617. */
  79618. readonly hitPointWorld: Vector3;
  79619. /**
  79620. * Gets the ray "start point" of the ray in the world
  79621. */
  79622. readonly rayFromWorld: Vector3;
  79623. /**
  79624. * Gets the ray "end point" of the ray in the world
  79625. */
  79626. readonly rayToWorld: Vector3;
  79627. /**
  79628. * Sets the hit data (normal & point in world space)
  79629. * @param hitNormalWorld defines the normal in world space
  79630. * @param hitPointWorld defines the point in world space
  79631. */
  79632. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  79633. /**
  79634. * Sets the distance from the start point to the hit point
  79635. * @param distance
  79636. */
  79637. setHitDistance(distance: number): void;
  79638. /**
  79639. * Calculates the distance manually
  79640. */
  79641. calculateHitDistance(): void;
  79642. /**
  79643. * Resets all the values to default
  79644. * @param from The from point on world space
  79645. * @param to The to point on world space
  79646. */
  79647. reset(from?: Vector3, to?: Vector3): void;
  79648. }
  79649. /**
  79650. * Interface for the size containing width and height
  79651. */
  79652. interface IXYZ {
  79653. /**
  79654. * X
  79655. */
  79656. x: number;
  79657. /**
  79658. * Y
  79659. */
  79660. y: number;
  79661. /**
  79662. * Z
  79663. */
  79664. z: number;
  79665. }
  79666. }
  79667. declare module BABYLON {
  79668. /**
  79669. * Interface used to describe a physics joint
  79670. */
  79671. export interface PhysicsImpostorJoint {
  79672. /** Defines the main impostor to which the joint is linked */
  79673. mainImpostor: PhysicsImpostor;
  79674. /** Defines the impostor that is connected to the main impostor using this joint */
  79675. connectedImpostor: PhysicsImpostor;
  79676. /** Defines the joint itself */
  79677. joint: PhysicsJoint;
  79678. }
  79679. /** @hidden */
  79680. export interface IPhysicsEnginePlugin {
  79681. world: any;
  79682. name: string;
  79683. setGravity(gravity: Vector3): void;
  79684. setTimeStep(timeStep: number): void;
  79685. getTimeStep(): number;
  79686. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  79687. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79688. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79689. generatePhysicsBody(impostor: PhysicsImpostor): void;
  79690. removePhysicsBody(impostor: PhysicsImpostor): void;
  79691. generateJoint(joint: PhysicsImpostorJoint): void;
  79692. removeJoint(joint: PhysicsImpostorJoint): void;
  79693. isSupported(): boolean;
  79694. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  79695. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  79696. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  79697. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  79698. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  79699. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  79700. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  79701. getBodyMass(impostor: PhysicsImpostor): number;
  79702. getBodyFriction(impostor: PhysicsImpostor): number;
  79703. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  79704. getBodyRestitution(impostor: PhysicsImpostor): number;
  79705. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  79706. getBodyPressure?(impostor: PhysicsImpostor): number;
  79707. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  79708. getBodyStiffness?(impostor: PhysicsImpostor): number;
  79709. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  79710. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  79711. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  79712. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  79713. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  79714. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  79715. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  79716. sleepBody(impostor: PhysicsImpostor): void;
  79717. wakeUpBody(impostor: PhysicsImpostor): void;
  79718. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  79719. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  79720. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  79721. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79722. getRadius(impostor: PhysicsImpostor): number;
  79723. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  79724. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  79725. dispose(): void;
  79726. }
  79727. /**
  79728. * Interface used to define a physics engine
  79729. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  79730. */
  79731. export interface IPhysicsEngine {
  79732. /**
  79733. * Gets the gravity vector used by the simulation
  79734. */
  79735. gravity: Vector3;
  79736. /**
  79737. * Sets the gravity vector used by the simulation
  79738. * @param gravity defines the gravity vector to use
  79739. */
  79740. setGravity(gravity: Vector3): void;
  79741. /**
  79742. * Set the time step of the physics engine.
  79743. * Default is 1/60.
  79744. * To slow it down, enter 1/600 for example.
  79745. * To speed it up, 1/30
  79746. * @param newTimeStep the new timestep to apply to this world.
  79747. */
  79748. setTimeStep(newTimeStep: number): void;
  79749. /**
  79750. * Get the time step of the physics engine.
  79751. * @returns the current time step
  79752. */
  79753. getTimeStep(): number;
  79754. /**
  79755. * Release all resources
  79756. */
  79757. dispose(): void;
  79758. /**
  79759. * Gets the name of the current physics plugin
  79760. * @returns the name of the plugin
  79761. */
  79762. getPhysicsPluginName(): string;
  79763. /**
  79764. * Adding a new impostor for the impostor tracking.
  79765. * This will be done by the impostor itself.
  79766. * @param impostor the impostor to add
  79767. */
  79768. addImpostor(impostor: PhysicsImpostor): void;
  79769. /**
  79770. * Remove an impostor from the engine.
  79771. * This impostor and its mesh will not longer be updated by the physics engine.
  79772. * @param impostor the impostor to remove
  79773. */
  79774. removeImpostor(impostor: PhysicsImpostor): void;
  79775. /**
  79776. * Add a joint to the physics engine
  79777. * @param mainImpostor defines the main impostor to which the joint is added.
  79778. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  79779. * @param joint defines the joint that will connect both impostors.
  79780. */
  79781. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  79782. /**
  79783. * Removes a joint from the simulation
  79784. * @param mainImpostor defines the impostor used with the joint
  79785. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  79786. * @param joint defines the joint to remove
  79787. */
  79788. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  79789. /**
  79790. * Gets the current plugin used to run the simulation
  79791. * @returns current plugin
  79792. */
  79793. getPhysicsPlugin(): IPhysicsEnginePlugin;
  79794. /**
  79795. * Gets the list of physic impostors
  79796. * @returns an array of PhysicsImpostor
  79797. */
  79798. getImpostors(): Array<PhysicsImpostor>;
  79799. /**
  79800. * Gets the impostor for a physics enabled object
  79801. * @param object defines the object impersonated by the impostor
  79802. * @returns the PhysicsImpostor or null if not found
  79803. */
  79804. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  79805. /**
  79806. * Gets the impostor for a physics body object
  79807. * @param body defines physics body used by the impostor
  79808. * @returns the PhysicsImpostor or null if not found
  79809. */
  79810. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  79811. /**
  79812. * Does a raycast in the physics world
  79813. * @param from when should the ray start?
  79814. * @param to when should the ray end?
  79815. * @returns PhysicsRaycastResult
  79816. */
  79817. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  79818. /**
  79819. * Called by the scene. No need to call it.
  79820. * @param delta defines the timespam between frames
  79821. */
  79822. _step(delta: number): void;
  79823. }
  79824. }
  79825. declare module BABYLON {
  79826. /**
  79827. * The interface for the physics imposter parameters
  79828. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79829. */
  79830. export interface PhysicsImpostorParameters {
  79831. /**
  79832. * The mass of the physics imposter
  79833. */
  79834. mass: number;
  79835. /**
  79836. * The friction of the physics imposter
  79837. */
  79838. friction?: number;
  79839. /**
  79840. * The coefficient of restitution of the physics imposter
  79841. */
  79842. restitution?: number;
  79843. /**
  79844. * The native options of the physics imposter
  79845. */
  79846. nativeOptions?: any;
  79847. /**
  79848. * Specifies if the parent should be ignored
  79849. */
  79850. ignoreParent?: boolean;
  79851. /**
  79852. * Specifies if bi-directional transformations should be disabled
  79853. */
  79854. disableBidirectionalTransformation?: boolean;
  79855. /**
  79856. * The pressure inside the physics imposter, soft object only
  79857. */
  79858. pressure?: number;
  79859. /**
  79860. * The stiffness the physics imposter, soft object only
  79861. */
  79862. stiffness?: number;
  79863. /**
  79864. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  79865. */
  79866. velocityIterations?: number;
  79867. /**
  79868. * The number of iterations used in maintaining consistent vertex positions, soft object only
  79869. */
  79870. positionIterations?: number;
  79871. /**
  79872. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  79873. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  79874. * Add to fix multiple points
  79875. */
  79876. fixedPoints?: number;
  79877. /**
  79878. * The collision margin around a soft object
  79879. */
  79880. margin?: number;
  79881. /**
  79882. * The collision margin around a soft object
  79883. */
  79884. damping?: number;
  79885. /**
  79886. * The path for a rope based on an extrusion
  79887. */
  79888. path?: any;
  79889. /**
  79890. * The shape of an extrusion used for a rope based on an extrusion
  79891. */
  79892. shape?: any;
  79893. }
  79894. /**
  79895. * Interface for a physics-enabled object
  79896. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79897. */
  79898. export interface IPhysicsEnabledObject {
  79899. /**
  79900. * The position of the physics-enabled object
  79901. */
  79902. position: Vector3;
  79903. /**
  79904. * The rotation of the physics-enabled object
  79905. */
  79906. rotationQuaternion: Nullable<Quaternion>;
  79907. /**
  79908. * The scale of the physics-enabled object
  79909. */
  79910. scaling: Vector3;
  79911. /**
  79912. * The rotation of the physics-enabled object
  79913. */
  79914. rotation?: Vector3;
  79915. /**
  79916. * The parent of the physics-enabled object
  79917. */
  79918. parent?: any;
  79919. /**
  79920. * The bounding info of the physics-enabled object
  79921. * @returns The bounding info of the physics-enabled object
  79922. */
  79923. getBoundingInfo(): BoundingInfo;
  79924. /**
  79925. * Computes the world matrix
  79926. * @param force Specifies if the world matrix should be computed by force
  79927. * @returns A world matrix
  79928. */
  79929. computeWorldMatrix(force: boolean): Matrix;
  79930. /**
  79931. * Gets the world matrix
  79932. * @returns A world matrix
  79933. */
  79934. getWorldMatrix?(): Matrix;
  79935. /**
  79936. * Gets the child meshes
  79937. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  79938. * @returns An array of abstract meshes
  79939. */
  79940. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  79941. /**
  79942. * Gets the vertex data
  79943. * @param kind The type of vertex data
  79944. * @returns A nullable array of numbers, or a float32 array
  79945. */
  79946. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  79947. /**
  79948. * Gets the indices from the mesh
  79949. * @returns A nullable array of index arrays
  79950. */
  79951. getIndices?(): Nullable<IndicesArray>;
  79952. /**
  79953. * Gets the scene from the mesh
  79954. * @returns the indices array or null
  79955. */
  79956. getScene?(): Scene;
  79957. /**
  79958. * Gets the absolute position from the mesh
  79959. * @returns the absolute position
  79960. */
  79961. getAbsolutePosition(): Vector3;
  79962. /**
  79963. * Gets the absolute pivot point from the mesh
  79964. * @returns the absolute pivot point
  79965. */
  79966. getAbsolutePivotPoint(): Vector3;
  79967. /**
  79968. * Rotates the mesh
  79969. * @param axis The axis of rotation
  79970. * @param amount The amount of rotation
  79971. * @param space The space of the rotation
  79972. * @returns The rotation transform node
  79973. */
  79974. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  79975. /**
  79976. * Translates the mesh
  79977. * @param axis The axis of translation
  79978. * @param distance The distance of translation
  79979. * @param space The space of the translation
  79980. * @returns The transform node
  79981. */
  79982. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  79983. /**
  79984. * Sets the absolute position of the mesh
  79985. * @param absolutePosition The absolute position of the mesh
  79986. * @returns The transform node
  79987. */
  79988. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  79989. /**
  79990. * Gets the class name of the mesh
  79991. * @returns The class name
  79992. */
  79993. getClassName(): string;
  79994. }
  79995. /**
  79996. * Represents a physics imposter
  79997. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79998. */
  79999. export class PhysicsImpostor {
  80000. /**
  80001. * The physics-enabled object used as the physics imposter
  80002. */
  80003. object: IPhysicsEnabledObject;
  80004. /**
  80005. * The type of the physics imposter
  80006. */
  80007. type: number;
  80008. private _options;
  80009. private _scene?;
  80010. /**
  80011. * The default object size of the imposter
  80012. */
  80013. static DEFAULT_OBJECT_SIZE: Vector3;
  80014. /**
  80015. * The identity quaternion of the imposter
  80016. */
  80017. static IDENTITY_QUATERNION: Quaternion;
  80018. /** @hidden */
  80019. _pluginData: any;
  80020. private _physicsEngine;
  80021. private _physicsBody;
  80022. private _bodyUpdateRequired;
  80023. private _onBeforePhysicsStepCallbacks;
  80024. private _onAfterPhysicsStepCallbacks;
  80025. /** @hidden */
  80026. _onPhysicsCollideCallbacks: Array<{
  80027. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  80028. otherImpostors: Array<PhysicsImpostor>;
  80029. }>;
  80030. private _deltaPosition;
  80031. private _deltaRotation;
  80032. private _deltaRotationConjugated;
  80033. /** hidden */
  80034. _isFromLine: boolean;
  80035. private _parent;
  80036. private _isDisposed;
  80037. private static _tmpVecs;
  80038. private static _tmpQuat;
  80039. /**
  80040. * Specifies if the physics imposter is disposed
  80041. */
  80042. readonly isDisposed: boolean;
  80043. /**
  80044. * Gets the mass of the physics imposter
  80045. */
  80046. mass: number;
  80047. /**
  80048. * Gets the coefficient of friction
  80049. */
  80050. /**
  80051. * Sets the coefficient of friction
  80052. */
  80053. friction: number;
  80054. /**
  80055. * Gets the coefficient of restitution
  80056. */
  80057. /**
  80058. * Sets the coefficient of restitution
  80059. */
  80060. restitution: number;
  80061. /**
  80062. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  80063. */
  80064. /**
  80065. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  80066. */
  80067. pressure: number;
  80068. /**
  80069. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  80070. */
  80071. /**
  80072. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  80073. */
  80074. stiffness: number;
  80075. /**
  80076. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  80077. */
  80078. /**
  80079. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  80080. */
  80081. velocityIterations: number;
  80082. /**
  80083. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  80084. */
  80085. /**
  80086. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  80087. */
  80088. positionIterations: number;
  80089. /**
  80090. * The unique id of the physics imposter
  80091. * set by the physics engine when adding this impostor to the array
  80092. */
  80093. uniqueId: number;
  80094. /**
  80095. * @hidden
  80096. */
  80097. soft: boolean;
  80098. /**
  80099. * @hidden
  80100. */
  80101. segments: number;
  80102. private _joints;
  80103. /**
  80104. * Initializes the physics imposter
  80105. * @param object The physics-enabled object used as the physics imposter
  80106. * @param type The type of the physics imposter
  80107. * @param _options The options for the physics imposter
  80108. * @param _scene The Babylon scene
  80109. */
  80110. constructor(
  80111. /**
  80112. * The physics-enabled object used as the physics imposter
  80113. */
  80114. object: IPhysicsEnabledObject,
  80115. /**
  80116. * The type of the physics imposter
  80117. */
  80118. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  80119. /**
  80120. * This function will completly initialize this impostor.
  80121. * It will create a new body - but only if this mesh has no parent.
  80122. * If it has, this impostor will not be used other than to define the impostor
  80123. * of the child mesh.
  80124. * @hidden
  80125. */
  80126. _init(): void;
  80127. private _getPhysicsParent;
  80128. /**
  80129. * Should a new body be generated.
  80130. * @returns boolean specifying if body initialization is required
  80131. */
  80132. isBodyInitRequired(): boolean;
  80133. /**
  80134. * Sets the updated scaling
  80135. * @param updated Specifies if the scaling is updated
  80136. */
  80137. setScalingUpdated(): void;
  80138. /**
  80139. * Force a regeneration of this or the parent's impostor's body.
  80140. * Use under cautious - This will remove all joints already implemented.
  80141. */
  80142. forceUpdate(): void;
  80143. /**
  80144. * Gets the body that holds this impostor. Either its own, or its parent.
  80145. */
  80146. /**
  80147. * Set the physics body. Used mainly by the physics engine/plugin
  80148. */
  80149. physicsBody: any;
  80150. /**
  80151. * Get the parent of the physics imposter
  80152. * @returns Physics imposter or null
  80153. */
  80154. /**
  80155. * Sets the parent of the physics imposter
  80156. */
  80157. parent: Nullable<PhysicsImpostor>;
  80158. /**
  80159. * Resets the update flags
  80160. */
  80161. resetUpdateFlags(): void;
  80162. /**
  80163. * Gets the object extend size
  80164. * @returns the object extend size
  80165. */
  80166. getObjectExtendSize(): Vector3;
  80167. /**
  80168. * Gets the object center
  80169. * @returns The object center
  80170. */
  80171. getObjectCenter(): Vector3;
  80172. /**
  80173. * Get a specific parametes from the options parameter
  80174. * @param paramName The object parameter name
  80175. * @returns The object parameter
  80176. */
  80177. getParam(paramName: string): any;
  80178. /**
  80179. * Sets a specific parameter in the options given to the physics plugin
  80180. * @param paramName The parameter name
  80181. * @param value The value of the parameter
  80182. */
  80183. setParam(paramName: string, value: number): void;
  80184. /**
  80185. * Specifically change the body's mass option. Won't recreate the physics body object
  80186. * @param mass The mass of the physics imposter
  80187. */
  80188. setMass(mass: number): void;
  80189. /**
  80190. * Gets the linear velocity
  80191. * @returns linear velocity or null
  80192. */
  80193. getLinearVelocity(): Nullable<Vector3>;
  80194. /**
  80195. * Sets the linear velocity
  80196. * @param velocity linear velocity or null
  80197. */
  80198. setLinearVelocity(velocity: Nullable<Vector3>): void;
  80199. /**
  80200. * Gets the angular velocity
  80201. * @returns angular velocity or null
  80202. */
  80203. getAngularVelocity(): Nullable<Vector3>;
  80204. /**
  80205. * Sets the angular velocity
  80206. * @param velocity The velocity or null
  80207. */
  80208. setAngularVelocity(velocity: Nullable<Vector3>): void;
  80209. /**
  80210. * Execute a function with the physics plugin native code
  80211. * Provide a function the will have two variables - the world object and the physics body object
  80212. * @param func The function to execute with the physics plugin native code
  80213. */
  80214. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  80215. /**
  80216. * Register a function that will be executed before the physics world is stepping forward
  80217. * @param func The function to execute before the physics world is stepped forward
  80218. */
  80219. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80220. /**
  80221. * Unregister a function that will be executed before the physics world is stepping forward
  80222. * @param func The function to execute before the physics world is stepped forward
  80223. */
  80224. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80225. /**
  80226. * Register a function that will be executed after the physics step
  80227. * @param func The function to execute after physics step
  80228. */
  80229. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80230. /**
  80231. * Unregisters a function that will be executed after the physics step
  80232. * @param func The function to execute after physics step
  80233. */
  80234. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80235. /**
  80236. * register a function that will be executed when this impostor collides against a different body
  80237. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  80238. * @param func Callback that is executed on collision
  80239. */
  80240. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  80241. /**
  80242. * Unregisters the physics imposter on contact
  80243. * @param collideAgainst The physics object to collide against
  80244. * @param func Callback to execute on collision
  80245. */
  80246. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  80247. private _tmpQuat;
  80248. private _tmpQuat2;
  80249. /**
  80250. * Get the parent rotation
  80251. * @returns The parent rotation
  80252. */
  80253. getParentsRotation(): Quaternion;
  80254. /**
  80255. * this function is executed by the physics engine.
  80256. */
  80257. beforeStep: () => void;
  80258. /**
  80259. * this function is executed by the physics engine
  80260. */
  80261. afterStep: () => void;
  80262. /**
  80263. * Legacy collision detection event support
  80264. */
  80265. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  80266. /**
  80267. * event and body object due to cannon's event-based architecture.
  80268. */
  80269. onCollide: (e: {
  80270. body: any;
  80271. }) => void;
  80272. /**
  80273. * Apply a force
  80274. * @param force The force to apply
  80275. * @param contactPoint The contact point for the force
  80276. * @returns The physics imposter
  80277. */
  80278. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  80279. /**
  80280. * Apply an impulse
  80281. * @param force The impulse force
  80282. * @param contactPoint The contact point for the impulse force
  80283. * @returns The physics imposter
  80284. */
  80285. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  80286. /**
  80287. * A help function to create a joint
  80288. * @param otherImpostor A physics imposter used to create a joint
  80289. * @param jointType The type of joint
  80290. * @param jointData The data for the joint
  80291. * @returns The physics imposter
  80292. */
  80293. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  80294. /**
  80295. * Add a joint to this impostor with a different impostor
  80296. * @param otherImpostor A physics imposter used to add a joint
  80297. * @param joint The joint to add
  80298. * @returns The physics imposter
  80299. */
  80300. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  80301. /**
  80302. * Add an anchor to a cloth impostor
  80303. * @param otherImpostor rigid impostor to anchor to
  80304. * @param width ratio across width from 0 to 1
  80305. * @param height ratio up height from 0 to 1
  80306. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  80307. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  80308. * @returns impostor the soft imposter
  80309. */
  80310. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  80311. /**
  80312. * Add a hook to a rope impostor
  80313. * @param otherImpostor rigid impostor to anchor to
  80314. * @param length ratio across rope from 0 to 1
  80315. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  80316. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  80317. * @returns impostor the rope imposter
  80318. */
  80319. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  80320. /**
  80321. * Will keep this body still, in a sleep mode.
  80322. * @returns the physics imposter
  80323. */
  80324. sleep(): PhysicsImpostor;
  80325. /**
  80326. * Wake the body up.
  80327. * @returns The physics imposter
  80328. */
  80329. wakeUp(): PhysicsImpostor;
  80330. /**
  80331. * Clones the physics imposter
  80332. * @param newObject The physics imposter clones to this physics-enabled object
  80333. * @returns A nullable physics imposter
  80334. */
  80335. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  80336. /**
  80337. * Disposes the physics imposter
  80338. */
  80339. dispose(): void;
  80340. /**
  80341. * Sets the delta position
  80342. * @param position The delta position amount
  80343. */
  80344. setDeltaPosition(position: Vector3): void;
  80345. /**
  80346. * Sets the delta rotation
  80347. * @param rotation The delta rotation amount
  80348. */
  80349. setDeltaRotation(rotation: Quaternion): void;
  80350. /**
  80351. * Gets the box size of the physics imposter and stores the result in the input parameter
  80352. * @param result Stores the box size
  80353. * @returns The physics imposter
  80354. */
  80355. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  80356. /**
  80357. * Gets the radius of the physics imposter
  80358. * @returns Radius of the physics imposter
  80359. */
  80360. getRadius(): number;
  80361. /**
  80362. * Sync a bone with this impostor
  80363. * @param bone The bone to sync to the impostor.
  80364. * @param boneMesh The mesh that the bone is influencing.
  80365. * @param jointPivot The pivot of the joint / bone in local space.
  80366. * @param distToJoint Optional distance from the impostor to the joint.
  80367. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80368. */
  80369. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  80370. /**
  80371. * Sync impostor to a bone
  80372. * @param bone The bone that the impostor will be synced to.
  80373. * @param boneMesh The mesh that the bone is influencing.
  80374. * @param jointPivot The pivot of the joint / bone in local space.
  80375. * @param distToJoint Optional distance from the impostor to the joint.
  80376. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80377. * @param boneAxis Optional vector3 axis the bone is aligned with
  80378. */
  80379. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  80380. /**
  80381. * No-Imposter type
  80382. */
  80383. static NoImpostor: number;
  80384. /**
  80385. * Sphere-Imposter type
  80386. */
  80387. static SphereImpostor: number;
  80388. /**
  80389. * Box-Imposter type
  80390. */
  80391. static BoxImpostor: number;
  80392. /**
  80393. * Plane-Imposter type
  80394. */
  80395. static PlaneImpostor: number;
  80396. /**
  80397. * Mesh-imposter type
  80398. */
  80399. static MeshImpostor: number;
  80400. /**
  80401. * Cylinder-Imposter type
  80402. */
  80403. static CylinderImpostor: number;
  80404. /**
  80405. * Particle-Imposter type
  80406. */
  80407. static ParticleImpostor: number;
  80408. /**
  80409. * Heightmap-Imposter type
  80410. */
  80411. static HeightmapImpostor: number;
  80412. /**
  80413. * ConvexHull-Impostor type (Ammo.js plugin only)
  80414. */
  80415. static ConvexHullImpostor: number;
  80416. /**
  80417. * Rope-Imposter type
  80418. */
  80419. static RopeImpostor: number;
  80420. /**
  80421. * Cloth-Imposter type
  80422. */
  80423. static ClothImpostor: number;
  80424. /**
  80425. * Softbody-Imposter type
  80426. */
  80427. static SoftbodyImpostor: number;
  80428. }
  80429. }
  80430. declare module BABYLON {
  80431. /**
  80432. * @hidden
  80433. **/
  80434. export class _CreationDataStorage {
  80435. closePath?: boolean;
  80436. closeArray?: boolean;
  80437. idx: number[];
  80438. dashSize: number;
  80439. gapSize: number;
  80440. path3D: Path3D;
  80441. pathArray: Vector3[][];
  80442. arc: number;
  80443. radius: number;
  80444. cap: number;
  80445. tessellation: number;
  80446. }
  80447. /**
  80448. * @hidden
  80449. **/
  80450. class _InstanceDataStorage {
  80451. visibleInstances: any;
  80452. batchCache: _InstancesBatch;
  80453. instancesBufferSize: number;
  80454. instancesBuffer: Nullable<Buffer>;
  80455. instancesData: Float32Array;
  80456. overridenInstanceCount: number;
  80457. isFrozen: boolean;
  80458. previousBatch: _InstancesBatch;
  80459. hardwareInstancedRendering: boolean;
  80460. sideOrientation: number;
  80461. }
  80462. /**
  80463. * @hidden
  80464. **/
  80465. export class _InstancesBatch {
  80466. mustReturn: boolean;
  80467. visibleInstances: Nullable<InstancedMesh[]>[];
  80468. renderSelf: boolean[];
  80469. hardwareInstancedRendering: boolean[];
  80470. }
  80471. /**
  80472. * Class used to represent renderable models
  80473. */
  80474. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  80475. /**
  80476. * Mesh side orientation : usually the external or front surface
  80477. */
  80478. static readonly FRONTSIDE: number;
  80479. /**
  80480. * Mesh side orientation : usually the internal or back surface
  80481. */
  80482. static readonly BACKSIDE: number;
  80483. /**
  80484. * Mesh side orientation : both internal and external or front and back surfaces
  80485. */
  80486. static readonly DOUBLESIDE: number;
  80487. /**
  80488. * Mesh side orientation : by default, `FRONTSIDE`
  80489. */
  80490. static readonly DEFAULTSIDE: number;
  80491. /**
  80492. * Mesh cap setting : no cap
  80493. */
  80494. static readonly NO_CAP: number;
  80495. /**
  80496. * Mesh cap setting : one cap at the beginning of the mesh
  80497. */
  80498. static readonly CAP_START: number;
  80499. /**
  80500. * Mesh cap setting : one cap at the end of the mesh
  80501. */
  80502. static readonly CAP_END: number;
  80503. /**
  80504. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  80505. */
  80506. static readonly CAP_ALL: number;
  80507. /**
  80508. * Gets the default side orientation.
  80509. * @param orientation the orientation to value to attempt to get
  80510. * @returns the default orientation
  80511. * @hidden
  80512. */
  80513. static _GetDefaultSideOrientation(orientation?: number): number;
  80514. private _onBeforeRenderObservable;
  80515. private _onBeforeBindObservable;
  80516. private _onAfterRenderObservable;
  80517. private _onBeforeDrawObservable;
  80518. /**
  80519. * An event triggered before rendering the mesh
  80520. */
  80521. readonly onBeforeRenderObservable: Observable<Mesh>;
  80522. /**
  80523. * An event triggered before binding the mesh
  80524. */
  80525. readonly onBeforeBindObservable: Observable<Mesh>;
  80526. /**
  80527. * An event triggered after rendering the mesh
  80528. */
  80529. readonly onAfterRenderObservable: Observable<Mesh>;
  80530. /**
  80531. * An event triggered before drawing the mesh
  80532. */
  80533. readonly onBeforeDrawObservable: Observable<Mesh>;
  80534. private _onBeforeDrawObserver;
  80535. /**
  80536. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  80537. */
  80538. onBeforeDraw: () => void;
  80539. /**
  80540. * Gets the delay loading state of the mesh (when delay loading is turned on)
  80541. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  80542. */
  80543. delayLoadState: number;
  80544. /**
  80545. * Gets the list of instances created from this mesh
  80546. * it is not supposed to be modified manually.
  80547. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  80548. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80549. */
  80550. instances: InstancedMesh[];
  80551. /**
  80552. * Gets the file containing delay loading data for this mesh
  80553. */
  80554. delayLoadingFile: string;
  80555. /** @hidden */
  80556. _binaryInfo: any;
  80557. private _LODLevels;
  80558. /**
  80559. * User defined function used to change how LOD level selection is done
  80560. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  80561. */
  80562. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  80563. private _morphTargetManager;
  80564. /**
  80565. * Gets or sets the morph target manager
  80566. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  80567. */
  80568. morphTargetManager: Nullable<MorphTargetManager>;
  80569. /** @hidden */
  80570. _creationDataStorage: Nullable<_CreationDataStorage>;
  80571. /** @hidden */
  80572. _geometry: Nullable<Geometry>;
  80573. /** @hidden */
  80574. _delayInfo: Array<string>;
  80575. /** @hidden */
  80576. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  80577. /** @hidden */
  80578. _instanceDataStorage: _InstanceDataStorage;
  80579. private _effectiveMaterial;
  80580. /** @hidden */
  80581. _shouldGenerateFlatShading: boolean;
  80582. private _preActivateId;
  80583. /** @hidden */
  80584. _originalBuilderSideOrientation: number;
  80585. /**
  80586. * Use this property to change the original side orientation defined at construction time
  80587. */
  80588. overrideMaterialSideOrientation: Nullable<number>;
  80589. private _areNormalsFrozen;
  80590. private _sourcePositions;
  80591. private _sourceNormals;
  80592. private _source;
  80593. private meshMap;
  80594. /**
  80595. * Gets the source mesh (the one used to clone this one from)
  80596. */
  80597. readonly source: Nullable<Mesh>;
  80598. /**
  80599. * Gets or sets a boolean indicating that this mesh does not use index buffer
  80600. */
  80601. isUnIndexed: boolean;
  80602. /**
  80603. * @constructor
  80604. * @param name The value used by scene.getMeshByName() to do a lookup.
  80605. * @param scene The scene to add this mesh to.
  80606. * @param parent The parent of this mesh, if it has one
  80607. * @param source An optional Mesh from which geometry is shared, cloned.
  80608. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  80609. * When false, achieved by calling a clone(), also passing False.
  80610. * This will make creation of children, recursive.
  80611. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  80612. */
  80613. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  80614. /**
  80615. * Gets the class name
  80616. * @returns the string "Mesh".
  80617. */
  80618. getClassName(): string;
  80619. /** @hidden */
  80620. readonly _isMesh: boolean;
  80621. /**
  80622. * Returns a description of this mesh
  80623. * @param fullDetails define if full details about this mesh must be used
  80624. * @returns a descriptive string representing this mesh
  80625. */
  80626. toString(fullDetails?: boolean): string;
  80627. /** @hidden */
  80628. _unBindEffect(): void;
  80629. /**
  80630. * Gets a boolean indicating if this mesh has LOD
  80631. */
  80632. readonly hasLODLevels: boolean;
  80633. /**
  80634. * Gets the list of MeshLODLevel associated with the current mesh
  80635. * @returns an array of MeshLODLevel
  80636. */
  80637. getLODLevels(): MeshLODLevel[];
  80638. private _sortLODLevels;
  80639. /**
  80640. * Add a mesh as LOD level triggered at the given distance.
  80641. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80642. * @param distance The distance from the center of the object to show this level
  80643. * @param mesh The mesh to be added as LOD level (can be null)
  80644. * @return This mesh (for chaining)
  80645. */
  80646. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  80647. /**
  80648. * Returns the LOD level mesh at the passed distance or null if not found.
  80649. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80650. * @param distance The distance from the center of the object to show this level
  80651. * @returns a Mesh or `null`
  80652. */
  80653. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  80654. /**
  80655. * Remove a mesh from the LOD array
  80656. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80657. * @param mesh defines the mesh to be removed
  80658. * @return This mesh (for chaining)
  80659. */
  80660. removeLODLevel(mesh: Mesh): Mesh;
  80661. /**
  80662. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  80663. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80664. * @param camera defines the camera to use to compute distance
  80665. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  80666. * @return This mesh (for chaining)
  80667. */
  80668. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  80669. /**
  80670. * Gets the mesh internal Geometry object
  80671. */
  80672. readonly geometry: Nullable<Geometry>;
  80673. /**
  80674. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  80675. * @returns the total number of vertices
  80676. */
  80677. getTotalVertices(): number;
  80678. /**
  80679. * Returns the content of an associated vertex buffer
  80680. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80681. * - VertexBuffer.PositionKind
  80682. * - VertexBuffer.UVKind
  80683. * - VertexBuffer.UV2Kind
  80684. * - VertexBuffer.UV3Kind
  80685. * - VertexBuffer.UV4Kind
  80686. * - VertexBuffer.UV5Kind
  80687. * - VertexBuffer.UV6Kind
  80688. * - VertexBuffer.ColorKind
  80689. * - VertexBuffer.MatricesIndicesKind
  80690. * - VertexBuffer.MatricesIndicesExtraKind
  80691. * - VertexBuffer.MatricesWeightsKind
  80692. * - VertexBuffer.MatricesWeightsExtraKind
  80693. * @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
  80694. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  80695. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  80696. */
  80697. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  80698. /**
  80699. * Returns the mesh VertexBuffer object from the requested `kind`
  80700. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80701. * - VertexBuffer.PositionKind
  80702. * - VertexBuffer.UVKind
  80703. * - VertexBuffer.UV2Kind
  80704. * - VertexBuffer.UV3Kind
  80705. * - VertexBuffer.UV4Kind
  80706. * - VertexBuffer.UV5Kind
  80707. * - VertexBuffer.UV6Kind
  80708. * - VertexBuffer.ColorKind
  80709. * - VertexBuffer.MatricesIndicesKind
  80710. * - VertexBuffer.MatricesIndicesExtraKind
  80711. * - VertexBuffer.MatricesWeightsKind
  80712. * - VertexBuffer.MatricesWeightsExtraKind
  80713. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  80714. */
  80715. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  80716. /**
  80717. * Tests if a specific vertex buffer is associated with this mesh
  80718. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  80719. * - VertexBuffer.PositionKind
  80720. * - VertexBuffer.UVKind
  80721. * - VertexBuffer.UV2Kind
  80722. * - VertexBuffer.UV3Kind
  80723. * - VertexBuffer.UV4Kind
  80724. * - VertexBuffer.UV5Kind
  80725. * - VertexBuffer.UV6Kind
  80726. * - VertexBuffer.ColorKind
  80727. * - VertexBuffer.MatricesIndicesKind
  80728. * - VertexBuffer.MatricesIndicesExtraKind
  80729. * - VertexBuffer.MatricesWeightsKind
  80730. * - VertexBuffer.MatricesWeightsExtraKind
  80731. * @returns a boolean
  80732. */
  80733. isVerticesDataPresent(kind: string): boolean;
  80734. /**
  80735. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  80736. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  80737. * - VertexBuffer.PositionKind
  80738. * - VertexBuffer.UVKind
  80739. * - VertexBuffer.UV2Kind
  80740. * - VertexBuffer.UV3Kind
  80741. * - VertexBuffer.UV4Kind
  80742. * - VertexBuffer.UV5Kind
  80743. * - VertexBuffer.UV6Kind
  80744. * - VertexBuffer.ColorKind
  80745. * - VertexBuffer.MatricesIndicesKind
  80746. * - VertexBuffer.MatricesIndicesExtraKind
  80747. * - VertexBuffer.MatricesWeightsKind
  80748. * - VertexBuffer.MatricesWeightsExtraKind
  80749. * @returns a boolean
  80750. */
  80751. isVertexBufferUpdatable(kind: string): boolean;
  80752. /**
  80753. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  80754. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80755. * - VertexBuffer.PositionKind
  80756. * - VertexBuffer.UVKind
  80757. * - VertexBuffer.UV2Kind
  80758. * - VertexBuffer.UV3Kind
  80759. * - VertexBuffer.UV4Kind
  80760. * - VertexBuffer.UV5Kind
  80761. * - VertexBuffer.UV6Kind
  80762. * - VertexBuffer.ColorKind
  80763. * - VertexBuffer.MatricesIndicesKind
  80764. * - VertexBuffer.MatricesIndicesExtraKind
  80765. * - VertexBuffer.MatricesWeightsKind
  80766. * - VertexBuffer.MatricesWeightsExtraKind
  80767. * @returns an array of strings
  80768. */
  80769. getVerticesDataKinds(): string[];
  80770. /**
  80771. * Returns a positive integer : the total number of indices in this mesh geometry.
  80772. * @returns the numner of indices or zero if the mesh has no geometry.
  80773. */
  80774. getTotalIndices(): number;
  80775. /**
  80776. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  80777. * @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.
  80778. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80779. * @returns the indices array or an empty array if the mesh has no geometry
  80780. */
  80781. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  80782. readonly isBlocked: boolean;
  80783. /**
  80784. * Determine if the current mesh is ready to be rendered
  80785. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  80786. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  80787. * @returns true if all associated assets are ready (material, textures, shaders)
  80788. */
  80789. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  80790. /**
  80791. * 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.
  80792. */
  80793. readonly areNormalsFrozen: boolean;
  80794. /**
  80795. * 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.
  80796. * @returns the current mesh
  80797. */
  80798. freezeNormals(): Mesh;
  80799. /**
  80800. * 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
  80801. * @returns the current mesh
  80802. */
  80803. unfreezeNormals(): Mesh;
  80804. /**
  80805. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  80806. */
  80807. overridenInstanceCount: number;
  80808. /** @hidden */
  80809. _preActivate(): Mesh;
  80810. /** @hidden */
  80811. _preActivateForIntermediateRendering(renderId: number): Mesh;
  80812. /** @hidden */
  80813. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  80814. /**
  80815. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  80816. * This means the mesh underlying bounding box and sphere are recomputed.
  80817. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  80818. * @returns the current mesh
  80819. */
  80820. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  80821. /** @hidden */
  80822. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  80823. /**
  80824. * This function will subdivide the mesh into multiple submeshes
  80825. * @param count defines the expected number of submeshes
  80826. */
  80827. subdivide(count: number): void;
  80828. /**
  80829. * Copy a FloatArray into a specific associated vertex buffer
  80830. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  80831. * - VertexBuffer.PositionKind
  80832. * - VertexBuffer.UVKind
  80833. * - VertexBuffer.UV2Kind
  80834. * - VertexBuffer.UV3Kind
  80835. * - VertexBuffer.UV4Kind
  80836. * - VertexBuffer.UV5Kind
  80837. * - VertexBuffer.UV6Kind
  80838. * - VertexBuffer.ColorKind
  80839. * - VertexBuffer.MatricesIndicesKind
  80840. * - VertexBuffer.MatricesIndicesExtraKind
  80841. * - VertexBuffer.MatricesWeightsKind
  80842. * - VertexBuffer.MatricesWeightsExtraKind
  80843. * @param data defines the data source
  80844. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  80845. * @param stride defines the data stride size (can be null)
  80846. * @returns the current mesh
  80847. */
  80848. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  80849. /**
  80850. * Flags an associated vertex buffer as updatable
  80851. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  80852. * - VertexBuffer.PositionKind
  80853. * - VertexBuffer.UVKind
  80854. * - VertexBuffer.UV2Kind
  80855. * - VertexBuffer.UV3Kind
  80856. * - VertexBuffer.UV4Kind
  80857. * - VertexBuffer.UV5Kind
  80858. * - VertexBuffer.UV6Kind
  80859. * - VertexBuffer.ColorKind
  80860. * - VertexBuffer.MatricesIndicesKind
  80861. * - VertexBuffer.MatricesIndicesExtraKind
  80862. * - VertexBuffer.MatricesWeightsKind
  80863. * - VertexBuffer.MatricesWeightsExtraKind
  80864. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  80865. */
  80866. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  80867. /**
  80868. * Sets the mesh global Vertex Buffer
  80869. * @param buffer defines the buffer to use
  80870. * @returns the current mesh
  80871. */
  80872. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  80873. /**
  80874. * Update a specific associated vertex buffer
  80875. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  80876. * - VertexBuffer.PositionKind
  80877. * - VertexBuffer.UVKind
  80878. * - VertexBuffer.UV2Kind
  80879. * - VertexBuffer.UV3Kind
  80880. * - VertexBuffer.UV4Kind
  80881. * - VertexBuffer.UV5Kind
  80882. * - VertexBuffer.UV6Kind
  80883. * - VertexBuffer.ColorKind
  80884. * - VertexBuffer.MatricesIndicesKind
  80885. * - VertexBuffer.MatricesIndicesExtraKind
  80886. * - VertexBuffer.MatricesWeightsKind
  80887. * - VertexBuffer.MatricesWeightsExtraKind
  80888. * @param data defines the data source
  80889. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  80890. * @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)
  80891. * @returns the current mesh
  80892. */
  80893. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  80894. /**
  80895. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  80896. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  80897. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  80898. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  80899. * @returns the current mesh
  80900. */
  80901. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  80902. /**
  80903. * Creates a un-shared specific occurence of the geometry for the mesh.
  80904. * @returns the current mesh
  80905. */
  80906. makeGeometryUnique(): Mesh;
  80907. /**
  80908. * Set the index buffer of this mesh
  80909. * @param indices defines the source data
  80910. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  80911. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  80912. * @returns the current mesh
  80913. */
  80914. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  80915. /**
  80916. * Update the current index buffer
  80917. * @param indices defines the source data
  80918. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  80919. * @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)
  80920. * @returns the current mesh
  80921. */
  80922. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  80923. /**
  80924. * Invert the geometry to move from a right handed system to a left handed one.
  80925. * @returns the current mesh
  80926. */
  80927. toLeftHanded(): Mesh;
  80928. /** @hidden */
  80929. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  80930. /** @hidden */
  80931. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  80932. /**
  80933. * Registers for this mesh a javascript function called just before the rendering process
  80934. * @param func defines the function to call before rendering this mesh
  80935. * @returns the current mesh
  80936. */
  80937. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  80938. /**
  80939. * Disposes a previously registered javascript function called before the rendering
  80940. * @param func defines the function to remove
  80941. * @returns the current mesh
  80942. */
  80943. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  80944. /**
  80945. * Registers for this mesh a javascript function called just after the rendering is complete
  80946. * @param func defines the function to call after rendering this mesh
  80947. * @returns the current mesh
  80948. */
  80949. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  80950. /**
  80951. * Disposes a previously registered javascript function called after the rendering.
  80952. * @param func defines the function to remove
  80953. * @returns the current mesh
  80954. */
  80955. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  80956. /** @hidden */
  80957. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  80958. /** @hidden */
  80959. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  80960. /** @hidden */
  80961. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  80962. /** @hidden */
  80963. _freeze(): void;
  80964. /** @hidden */
  80965. _unFreeze(): void;
  80966. /**
  80967. * 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
  80968. * @param subMesh defines the subMesh to render
  80969. * @param enableAlphaMode defines if alpha mode can be changed
  80970. * @returns the current mesh
  80971. */
  80972. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  80973. private _onBeforeDraw;
  80974. /**
  80975. * Renormalize the mesh and patch it up if there are no weights
  80976. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  80977. * However in the case of zero weights then we set just a single influence to 1.
  80978. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  80979. */
  80980. cleanMatrixWeights(): void;
  80981. private normalizeSkinFourWeights;
  80982. private normalizeSkinWeightsAndExtra;
  80983. /**
  80984. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  80985. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  80986. * the user know there was an issue with importing the mesh
  80987. * @returns a validation object with skinned, valid and report string
  80988. */
  80989. validateSkinning(): {
  80990. skinned: boolean;
  80991. valid: boolean;
  80992. report: string;
  80993. };
  80994. /** @hidden */
  80995. _checkDelayState(): Mesh;
  80996. private _queueLoad;
  80997. /**
  80998. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  80999. * A mesh is in the frustum if its bounding box intersects the frustum
  81000. * @param frustumPlanes defines the frustum to test
  81001. * @returns true if the mesh is in the frustum planes
  81002. */
  81003. isInFrustum(frustumPlanes: Plane[]): boolean;
  81004. /**
  81005. * Sets the mesh material by the material or multiMaterial `id` property
  81006. * @param id is a string identifying the material or the multiMaterial
  81007. * @returns the current mesh
  81008. */
  81009. setMaterialByID(id: string): Mesh;
  81010. /**
  81011. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  81012. * @returns an array of IAnimatable
  81013. */
  81014. getAnimatables(): IAnimatable[];
  81015. /**
  81016. * Modifies the mesh geometry according to the passed transformation matrix.
  81017. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  81018. * The mesh normals are modified using the same transformation.
  81019. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81020. * @param transform defines the transform matrix to use
  81021. * @see http://doc.babylonjs.com/resources/baking_transformations
  81022. * @returns the current mesh
  81023. */
  81024. bakeTransformIntoVertices(transform: Matrix): Mesh;
  81025. /**
  81026. * Modifies the mesh geometry according to its own current World Matrix.
  81027. * The mesh World Matrix is then reset.
  81028. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  81029. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81030. * @see http://doc.babylonjs.com/resources/baking_transformations
  81031. * @returns the current mesh
  81032. */
  81033. bakeCurrentTransformIntoVertices(): Mesh;
  81034. /** @hidden */
  81035. readonly _positions: Nullable<Vector3[]>;
  81036. /** @hidden */
  81037. _resetPointsArrayCache(): Mesh;
  81038. /** @hidden */
  81039. _generatePointsArray(): boolean;
  81040. /**
  81041. * Returns a new Mesh object generated from the current mesh properties.
  81042. * This method must not get confused with createInstance()
  81043. * @param name is a string, the name given to the new mesh
  81044. * @param newParent can be any Node object (default `null`)
  81045. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  81046. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  81047. * @returns a new mesh
  81048. */
  81049. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  81050. /**
  81051. * Releases resources associated with this mesh.
  81052. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81053. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81054. */
  81055. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81056. /**
  81057. * Modifies the mesh geometry according to a displacement map.
  81058. * 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.
  81059. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  81060. * @param url is a string, the URL from the image file is to be downloaded.
  81061. * @param minHeight is the lower limit of the displacement.
  81062. * @param maxHeight is the upper limit of the displacement.
  81063. * @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.
  81064. * @param uvOffset is an optional vector2 used to offset UV.
  81065. * @param uvScale is an optional vector2 used to scale UV.
  81066. * @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.
  81067. * @returns the Mesh.
  81068. */
  81069. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  81070. /**
  81071. * Modifies the mesh geometry according to a displacementMap buffer.
  81072. * 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.
  81073. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  81074. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  81075. * @param heightMapWidth is the width of the buffer image.
  81076. * @param heightMapHeight is the height of the buffer image.
  81077. * @param minHeight is the lower limit of the displacement.
  81078. * @param maxHeight is the upper limit of the displacement.
  81079. * @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.
  81080. * @param uvOffset is an optional vector2 used to offset UV.
  81081. * @param uvScale is an optional vector2 used to scale UV.
  81082. * @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.
  81083. * @returns the Mesh.
  81084. */
  81085. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  81086. /**
  81087. * Modify the mesh to get a flat shading rendering.
  81088. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  81089. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  81090. * @returns current mesh
  81091. */
  81092. convertToFlatShadedMesh(): Mesh;
  81093. /**
  81094. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  81095. * In other words, more vertices, no more indices and a single bigger VBO.
  81096. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  81097. * @returns current mesh
  81098. */
  81099. convertToUnIndexedMesh(): Mesh;
  81100. /**
  81101. * Inverses facet orientations.
  81102. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81103. * @param flipNormals will also inverts the normals
  81104. * @returns current mesh
  81105. */
  81106. flipFaces(flipNormals?: boolean): Mesh;
  81107. /**
  81108. * Increase the number of facets and hence vertices in a mesh
  81109. * Vertex normals are interpolated from existing vertex normals
  81110. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81111. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  81112. */
  81113. increaseVertices(numberPerEdge: number): void;
  81114. /**
  81115. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  81116. * This will undo any application of covertToFlatShadedMesh
  81117. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81118. */
  81119. forceSharedVertices(): void;
  81120. /** @hidden */
  81121. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  81122. /** @hidden */
  81123. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  81124. /**
  81125. * Creates a new InstancedMesh object from the mesh model.
  81126. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  81127. * @param name defines the name of the new instance
  81128. * @returns a new InstancedMesh
  81129. */
  81130. createInstance(name: string): InstancedMesh;
  81131. /**
  81132. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  81133. * After this call, all the mesh instances have the same submeshes than the current mesh.
  81134. * @returns the current mesh
  81135. */
  81136. synchronizeInstances(): Mesh;
  81137. /**
  81138. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  81139. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  81140. * This should be used together with the simplification to avoid disappearing triangles.
  81141. * @param successCallback an optional success callback to be called after the optimization finished.
  81142. * @returns the current mesh
  81143. */
  81144. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  81145. /**
  81146. * Serialize current mesh
  81147. * @param serializationObject defines the object which will receive the serialization data
  81148. */
  81149. serialize(serializationObject: any): void;
  81150. /** @hidden */
  81151. _syncGeometryWithMorphTargetManager(): void;
  81152. /** @hidden */
  81153. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  81154. /**
  81155. * Returns a new Mesh object parsed from the source provided.
  81156. * @param parsedMesh is the source
  81157. * @param scene defines the hosting scene
  81158. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  81159. * @returns a new Mesh
  81160. */
  81161. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  81162. /**
  81163. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  81164. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81165. * @param name defines the name of the mesh to create
  81166. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  81167. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  81168. * @param closePath creates a seam between the first and the last points of each path of the path array
  81169. * @param offset is taken in account only if the `pathArray` is containing a single path
  81170. * @param scene defines the hosting scene
  81171. * @param updatable defines if the mesh must be flagged as updatable
  81172. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81173. * @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)
  81174. * @returns a new Mesh
  81175. */
  81176. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81177. /**
  81178. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  81179. * @param name defines the name of the mesh to create
  81180. * @param radius sets the radius size (float) of the polygon (default 0.5)
  81181. * @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
  81182. * @param scene defines the hosting scene
  81183. * @param updatable defines if the mesh must be flagged as updatable
  81184. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81185. * @returns a new Mesh
  81186. */
  81187. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  81188. /**
  81189. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  81190. * @param name defines the name of the mesh to create
  81191. * @param size sets the size (float) of each box side (default 1)
  81192. * @param scene defines the hosting scene
  81193. * @param updatable defines if the mesh must be flagged as updatable
  81194. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81195. * @returns a new Mesh
  81196. */
  81197. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  81198. /**
  81199. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  81200. * @param name defines the name of the mesh to create
  81201. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  81202. * @param diameter sets the diameter size (float) of the sphere (default 1)
  81203. * @param scene defines the hosting scene
  81204. * @param updatable defines if the mesh must be flagged as updatable
  81205. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81206. * @returns a new Mesh
  81207. */
  81208. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81209. /**
  81210. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  81211. * @param name defines the name of the mesh to create
  81212. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  81213. * @param diameter sets the diameter size (float) of the sphere (default 1)
  81214. * @param scene defines the hosting scene
  81215. * @returns a new Mesh
  81216. */
  81217. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  81218. /**
  81219. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  81220. * @param name defines the name of the mesh to create
  81221. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  81222. * @param diameterTop set the top cap diameter (floats, default 1)
  81223. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  81224. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  81225. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  81226. * @param scene defines the hosting scene
  81227. * @param updatable defines if the mesh must be flagged as updatable
  81228. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81229. * @returns a new Mesh
  81230. */
  81231. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  81232. /**
  81233. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  81234. * @param name defines the name of the mesh to create
  81235. * @param diameter sets the diameter size (float) of the torus (default 1)
  81236. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  81237. * @param tessellation sets the number of torus sides (postive integer, default 16)
  81238. * @param scene defines the hosting scene
  81239. * @param updatable defines if the mesh must be flagged as updatable
  81240. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81241. * @returns a new Mesh
  81242. */
  81243. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81244. /**
  81245. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  81246. * @param name defines the name of the mesh to create
  81247. * @param radius sets the global radius size (float) of the torus knot (default 2)
  81248. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  81249. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  81250. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  81251. * @param p the number of windings on X axis (positive integers, default 2)
  81252. * @param q the number of windings on Y axis (positive integers, default 3)
  81253. * @param scene defines the hosting scene
  81254. * @param updatable defines if the mesh must be flagged as updatable
  81255. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81256. * @returns a new Mesh
  81257. */
  81258. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81259. /**
  81260. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  81261. * @param name defines the name of the mesh to create
  81262. * @param points is an array successive Vector3
  81263. * @param scene defines the hosting scene
  81264. * @param updatable defines if the mesh must be flagged as updatable
  81265. * @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).
  81266. * @returns a new Mesh
  81267. */
  81268. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  81269. /**
  81270. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  81271. * @param name defines the name of the mesh to create
  81272. * @param points is an array successive Vector3
  81273. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  81274. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  81275. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  81276. * @param scene defines the hosting scene
  81277. * @param updatable defines if the mesh must be flagged as updatable
  81278. * @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)
  81279. * @returns a new Mesh
  81280. */
  81281. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  81282. /**
  81283. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  81284. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  81285. * 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.
  81286. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81287. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  81288. * Remember you can only change the shape positions, not their number when updating a polygon.
  81289. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  81290. * @param name defines the name of the mesh to create
  81291. * @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
  81292. * @param scene defines the hosting scene
  81293. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  81294. * @param updatable defines if the mesh must be flagged as updatable
  81295. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81296. * @param earcutInjection can be used to inject your own earcut reference
  81297. * @returns a new Mesh
  81298. */
  81299. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  81300. /**
  81301. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  81302. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  81303. * @param name defines the name of the mesh to create
  81304. * @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
  81305. * @param depth defines the height of extrusion
  81306. * @param scene defines the hosting scene
  81307. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  81308. * @param updatable defines if the mesh must be flagged as updatable
  81309. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81310. * @param earcutInjection can be used to inject your own earcut reference
  81311. * @returns a new Mesh
  81312. */
  81313. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  81314. /**
  81315. * Creates an extruded shape mesh.
  81316. * 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
  81317. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81318. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81319. * @param name defines the name of the mesh to create
  81320. * @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
  81321. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  81322. * @param scale is the value to scale the shape
  81323. * @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
  81324. * @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
  81325. * @param scene defines the hosting scene
  81326. * @param updatable defines if the mesh must be flagged as updatable
  81327. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81328. * @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)
  81329. * @returns a new Mesh
  81330. */
  81331. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81332. /**
  81333. * Creates an custom extruded shape mesh.
  81334. * The custom extrusion is a parametric shape.
  81335. * It has no predefined shape. Its final shape will depend on the input parameters.
  81336. * Please consider using the same method from the MeshBuilder class instead
  81337. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81338. * @param name defines the name of the mesh to create
  81339. * @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
  81340. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  81341. * @param scaleFunction is a custom Javascript function called on each path point
  81342. * @param rotationFunction is a custom Javascript function called on each path point
  81343. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  81344. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  81345. * @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
  81346. * @param scene defines the hosting scene
  81347. * @param updatable defines if the mesh must be flagged as updatable
  81348. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81349. * @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)
  81350. * @returns a new Mesh
  81351. */
  81352. 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;
  81353. /**
  81354. * Creates lathe mesh.
  81355. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  81356. * Please consider using the same method from the MeshBuilder class instead
  81357. * @param name defines the name of the mesh to create
  81358. * @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
  81359. * @param radius is the radius value of the lathe
  81360. * @param tessellation is the side number of the lathe.
  81361. * @param scene defines the hosting scene
  81362. * @param updatable defines if the mesh must be flagged as updatable
  81363. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81364. * @returns a new Mesh
  81365. */
  81366. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81367. /**
  81368. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  81369. * @param name defines the name of the mesh to create
  81370. * @param size sets the size (float) of both sides of the plane at once (default 1)
  81371. * @param scene defines the hosting scene
  81372. * @param updatable defines if the mesh must be flagged as updatable
  81373. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81374. * @returns a new Mesh
  81375. */
  81376. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81377. /**
  81378. * Creates a ground mesh.
  81379. * Please consider using the same method from the MeshBuilder class instead
  81380. * @param name defines the name of the mesh to create
  81381. * @param width set the width of the ground
  81382. * @param height set the height of the ground
  81383. * @param subdivisions sets the number of subdivisions per side
  81384. * @param scene defines the hosting scene
  81385. * @param updatable defines if the mesh must be flagged as updatable
  81386. * @returns a new Mesh
  81387. */
  81388. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  81389. /**
  81390. * Creates a tiled ground mesh.
  81391. * Please consider using the same method from the MeshBuilder class instead
  81392. * @param name defines the name of the mesh to create
  81393. * @param xmin set the ground minimum X coordinate
  81394. * @param zmin set the ground minimum Y coordinate
  81395. * @param xmax set the ground maximum X coordinate
  81396. * @param zmax set the ground maximum Z coordinate
  81397. * @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
  81398. * @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
  81399. * @param scene defines the hosting scene
  81400. * @param updatable defines if the mesh must be flagged as updatable
  81401. * @returns a new Mesh
  81402. */
  81403. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  81404. w: number;
  81405. h: number;
  81406. }, precision: {
  81407. w: number;
  81408. h: number;
  81409. }, scene: Scene, updatable?: boolean): Mesh;
  81410. /**
  81411. * Creates a ground mesh from a height map.
  81412. * Please consider using the same method from the MeshBuilder class instead
  81413. * @see http://doc.babylonjs.com/babylon101/height_map
  81414. * @param name defines the name of the mesh to create
  81415. * @param url sets the URL of the height map image resource
  81416. * @param width set the ground width size
  81417. * @param height set the ground height size
  81418. * @param subdivisions sets the number of subdivision per side
  81419. * @param minHeight is the minimum altitude on the ground
  81420. * @param maxHeight is the maximum altitude on the ground
  81421. * @param scene defines the hosting scene
  81422. * @param updatable defines if the mesh must be flagged as updatable
  81423. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  81424. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  81425. * @returns a new Mesh
  81426. */
  81427. 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;
  81428. /**
  81429. * Creates a tube mesh.
  81430. * The tube is a parametric shape.
  81431. * It has no predefined shape. Its final shape will depend on the input parameters.
  81432. * Please consider using the same method from the MeshBuilder class instead
  81433. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81434. * @param name defines the name of the mesh to create
  81435. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  81436. * @param radius sets the tube radius size
  81437. * @param tessellation is the number of sides on the tubular surface
  81438. * @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
  81439. * @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
  81440. * @param scene defines the hosting scene
  81441. * @param updatable defines if the mesh must be flagged as updatable
  81442. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81443. * @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)
  81444. * @returns a new Mesh
  81445. */
  81446. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  81447. (i: number, distance: number): number;
  81448. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81449. /**
  81450. * Creates a polyhedron mesh.
  81451. * Please consider using the same method from the MeshBuilder class instead.
  81452. * * 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
  81453. * * The parameter `size` (positive float, default 1) sets the polygon size
  81454. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  81455. * * 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`
  81456. * * 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
  81457. * * 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)`)
  81458. * * 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
  81459. * * 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
  81460. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81461. * * If you create a double-sided mesh, you can choose what parts of 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
  81462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81463. * @param name defines the name of the mesh to create
  81464. * @param options defines the options used to create the mesh
  81465. * @param scene defines the hosting scene
  81466. * @returns a new Mesh
  81467. */
  81468. static CreatePolyhedron(name: string, options: {
  81469. type?: number;
  81470. size?: number;
  81471. sizeX?: number;
  81472. sizeY?: number;
  81473. sizeZ?: number;
  81474. custom?: any;
  81475. faceUV?: Vector4[];
  81476. faceColors?: Color4[];
  81477. updatable?: boolean;
  81478. sideOrientation?: number;
  81479. }, scene: Scene): Mesh;
  81480. /**
  81481. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  81482. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  81483. * * 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`)
  81484. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  81485. * * 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
  81486. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81487. * * If you create a double-sided mesh, you can choose what parts of 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
  81488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81489. * @param name defines the name of the mesh
  81490. * @param options defines the options used to create the mesh
  81491. * @param scene defines the hosting scene
  81492. * @returns a new Mesh
  81493. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  81494. */
  81495. static CreateIcoSphere(name: string, options: {
  81496. radius?: number;
  81497. flat?: boolean;
  81498. subdivisions?: number;
  81499. sideOrientation?: number;
  81500. updatable?: boolean;
  81501. }, scene: Scene): Mesh;
  81502. /**
  81503. * Creates a decal mesh.
  81504. * Please consider using the same method from the MeshBuilder class instead.
  81505. * A decal is a mesh usually applied as a model onto the surface of another mesh
  81506. * @param name defines the name of the mesh
  81507. * @param sourceMesh defines the mesh receiving the decal
  81508. * @param position sets the position of the decal in world coordinates
  81509. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  81510. * @param size sets the decal scaling
  81511. * @param angle sets the angle to rotate the decal
  81512. * @returns a new Mesh
  81513. */
  81514. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  81515. /**
  81516. * Prepare internal position array for software CPU skinning
  81517. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  81518. */
  81519. setPositionsForCPUSkinning(): Float32Array;
  81520. /**
  81521. * Prepare internal normal array for software CPU skinning
  81522. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  81523. */
  81524. setNormalsForCPUSkinning(): Float32Array;
  81525. /**
  81526. * Updates the vertex buffer by applying transformation from the bones
  81527. * @param skeleton defines the skeleton to apply to current mesh
  81528. * @returns the current mesh
  81529. */
  81530. applySkeleton(skeleton: Skeleton): Mesh;
  81531. /**
  81532. * 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
  81533. * @param meshes defines the list of meshes to scan
  81534. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  81535. */
  81536. static MinMax(meshes: AbstractMesh[]): {
  81537. min: Vector3;
  81538. max: Vector3;
  81539. };
  81540. /**
  81541. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  81542. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  81543. * @returns a vector3
  81544. */
  81545. static Center(meshesOrMinMaxVector: {
  81546. min: Vector3;
  81547. max: Vector3;
  81548. } | AbstractMesh[]): Vector3;
  81549. /**
  81550. * Merge the array of meshes into a single mesh for performance reasons.
  81551. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  81552. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  81553. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  81554. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  81555. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  81556. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  81557. * @returns a new mesh
  81558. */
  81559. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  81560. /** @hidden */
  81561. addInstance(instance: InstancedMesh): void;
  81562. /** @hidden */
  81563. removeInstance(instance: InstancedMesh): void;
  81564. }
  81565. }
  81566. declare module BABYLON {
  81567. /**
  81568. * Base class for the main features of a material in Babylon.js
  81569. */
  81570. export class Material implements IAnimatable {
  81571. /**
  81572. * Returns the triangle fill mode
  81573. */
  81574. static readonly TriangleFillMode: number;
  81575. /**
  81576. * Returns the wireframe mode
  81577. */
  81578. static readonly WireFrameFillMode: number;
  81579. /**
  81580. * Returns the point fill mode
  81581. */
  81582. static readonly PointFillMode: number;
  81583. /**
  81584. * Returns the point list draw mode
  81585. */
  81586. static readonly PointListDrawMode: number;
  81587. /**
  81588. * Returns the line list draw mode
  81589. */
  81590. static readonly LineListDrawMode: number;
  81591. /**
  81592. * Returns the line loop draw mode
  81593. */
  81594. static readonly LineLoopDrawMode: number;
  81595. /**
  81596. * Returns the line strip draw mode
  81597. */
  81598. static readonly LineStripDrawMode: number;
  81599. /**
  81600. * Returns the triangle strip draw mode
  81601. */
  81602. static readonly TriangleStripDrawMode: number;
  81603. /**
  81604. * Returns the triangle fan draw mode
  81605. */
  81606. static readonly TriangleFanDrawMode: number;
  81607. /**
  81608. * Stores the clock-wise side orientation
  81609. */
  81610. static readonly ClockWiseSideOrientation: number;
  81611. /**
  81612. * Stores the counter clock-wise side orientation
  81613. */
  81614. static readonly CounterClockWiseSideOrientation: number;
  81615. /**
  81616. * The dirty texture flag value
  81617. */
  81618. static readonly TextureDirtyFlag: number;
  81619. /**
  81620. * The dirty light flag value
  81621. */
  81622. static readonly LightDirtyFlag: number;
  81623. /**
  81624. * The dirty fresnel flag value
  81625. */
  81626. static readonly FresnelDirtyFlag: number;
  81627. /**
  81628. * The dirty attribute flag value
  81629. */
  81630. static readonly AttributesDirtyFlag: number;
  81631. /**
  81632. * The dirty misc flag value
  81633. */
  81634. static readonly MiscDirtyFlag: number;
  81635. /**
  81636. * The all dirty flag value
  81637. */
  81638. static readonly AllDirtyFlag: number;
  81639. /**
  81640. * The ID of the material
  81641. */
  81642. id: string;
  81643. /**
  81644. * Gets or sets the unique id of the material
  81645. */
  81646. uniqueId: number;
  81647. /**
  81648. * The name of the material
  81649. */
  81650. name: string;
  81651. /**
  81652. * Gets or sets user defined metadata
  81653. */
  81654. metadata: any;
  81655. /**
  81656. * For internal use only. Please do not use.
  81657. */
  81658. reservedDataStore: any;
  81659. /**
  81660. * Specifies if the ready state should be checked on each call
  81661. */
  81662. checkReadyOnEveryCall: boolean;
  81663. /**
  81664. * Specifies if the ready state should be checked once
  81665. */
  81666. checkReadyOnlyOnce: boolean;
  81667. /**
  81668. * The state of the material
  81669. */
  81670. state: string;
  81671. /**
  81672. * The alpha value of the material
  81673. */
  81674. protected _alpha: number;
  81675. /**
  81676. * List of inspectable custom properties (used by the Inspector)
  81677. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81678. */
  81679. inspectableCustomProperties: IInspectable[];
  81680. /**
  81681. * Sets the alpha value of the material
  81682. */
  81683. /**
  81684. * Gets the alpha value of the material
  81685. */
  81686. alpha: number;
  81687. /**
  81688. * Specifies if back face culling is enabled
  81689. */
  81690. protected _backFaceCulling: boolean;
  81691. /**
  81692. * Sets the back-face culling state
  81693. */
  81694. /**
  81695. * Gets the back-face culling state
  81696. */
  81697. backFaceCulling: boolean;
  81698. /**
  81699. * Stores the value for side orientation
  81700. */
  81701. sideOrientation: number;
  81702. /**
  81703. * Callback triggered when the material is compiled
  81704. */
  81705. onCompiled: Nullable<(effect: Effect) => void>;
  81706. /**
  81707. * Callback triggered when an error occurs
  81708. */
  81709. onError: Nullable<(effect: Effect, errors: string) => void>;
  81710. /**
  81711. * Callback triggered to get the render target textures
  81712. */
  81713. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  81714. /**
  81715. * Gets a boolean indicating that current material needs to register RTT
  81716. */
  81717. readonly hasRenderTargetTextures: boolean;
  81718. /**
  81719. * Specifies if the material should be serialized
  81720. */
  81721. doNotSerialize: boolean;
  81722. /**
  81723. * @hidden
  81724. */
  81725. _storeEffectOnSubMeshes: boolean;
  81726. /**
  81727. * Stores the animations for the material
  81728. */
  81729. animations: Nullable<Array<Animation>>;
  81730. /**
  81731. * An event triggered when the material is disposed
  81732. */
  81733. onDisposeObservable: Observable<Material>;
  81734. /**
  81735. * An observer which watches for dispose events
  81736. */
  81737. private _onDisposeObserver;
  81738. private _onUnBindObservable;
  81739. /**
  81740. * Called during a dispose event
  81741. */
  81742. onDispose: () => void;
  81743. private _onBindObservable;
  81744. /**
  81745. * An event triggered when the material is bound
  81746. */
  81747. readonly onBindObservable: Observable<AbstractMesh>;
  81748. /**
  81749. * An observer which watches for bind events
  81750. */
  81751. private _onBindObserver;
  81752. /**
  81753. * Called during a bind event
  81754. */
  81755. onBind: (Mesh: AbstractMesh) => void;
  81756. /**
  81757. * An event triggered when the material is unbound
  81758. */
  81759. readonly onUnBindObservable: Observable<Material>;
  81760. /**
  81761. * Stores the value of the alpha mode
  81762. */
  81763. private _alphaMode;
  81764. /**
  81765. * Sets the value of the alpha mode.
  81766. *
  81767. * | Value | Type | Description |
  81768. * | --- | --- | --- |
  81769. * | 0 | ALPHA_DISABLE | |
  81770. * | 1 | ALPHA_ADD | |
  81771. * | 2 | ALPHA_COMBINE | |
  81772. * | 3 | ALPHA_SUBTRACT | |
  81773. * | 4 | ALPHA_MULTIPLY | |
  81774. * | 5 | ALPHA_MAXIMIZED | |
  81775. * | 6 | ALPHA_ONEONE | |
  81776. * | 7 | ALPHA_PREMULTIPLIED | |
  81777. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  81778. * | 9 | ALPHA_INTERPOLATE | |
  81779. * | 10 | ALPHA_SCREENMODE | |
  81780. *
  81781. */
  81782. /**
  81783. * Gets the value of the alpha mode
  81784. */
  81785. alphaMode: number;
  81786. /**
  81787. * Stores the state of the need depth pre-pass value
  81788. */
  81789. private _needDepthPrePass;
  81790. /**
  81791. * Sets the need depth pre-pass value
  81792. */
  81793. /**
  81794. * Gets the depth pre-pass value
  81795. */
  81796. needDepthPrePass: boolean;
  81797. /**
  81798. * Specifies if depth writing should be disabled
  81799. */
  81800. disableDepthWrite: boolean;
  81801. /**
  81802. * Specifies if depth writing should be forced
  81803. */
  81804. forceDepthWrite: boolean;
  81805. /**
  81806. * Specifies if there should be a separate pass for culling
  81807. */
  81808. separateCullingPass: boolean;
  81809. /**
  81810. * Stores the state specifing if fog should be enabled
  81811. */
  81812. private _fogEnabled;
  81813. /**
  81814. * Sets the state for enabling fog
  81815. */
  81816. /**
  81817. * Gets the value of the fog enabled state
  81818. */
  81819. fogEnabled: boolean;
  81820. /**
  81821. * Stores the size of points
  81822. */
  81823. pointSize: number;
  81824. /**
  81825. * Stores the z offset value
  81826. */
  81827. zOffset: number;
  81828. /**
  81829. * Gets a value specifying if wireframe mode is enabled
  81830. */
  81831. /**
  81832. * Sets the state of wireframe mode
  81833. */
  81834. wireframe: boolean;
  81835. /**
  81836. * Gets the value specifying if point clouds are enabled
  81837. */
  81838. /**
  81839. * Sets the state of point cloud mode
  81840. */
  81841. pointsCloud: boolean;
  81842. /**
  81843. * Gets the material fill mode
  81844. */
  81845. /**
  81846. * Sets the material fill mode
  81847. */
  81848. fillMode: number;
  81849. /**
  81850. * @hidden
  81851. * Stores the effects for the material
  81852. */
  81853. _effect: Nullable<Effect>;
  81854. /**
  81855. * @hidden
  81856. * Specifies if the material was previously ready
  81857. */
  81858. _wasPreviouslyReady: boolean;
  81859. /**
  81860. * Specifies if uniform buffers should be used
  81861. */
  81862. private _useUBO;
  81863. /**
  81864. * Stores a reference to the scene
  81865. */
  81866. private _scene;
  81867. /**
  81868. * Stores the fill mode state
  81869. */
  81870. private _fillMode;
  81871. /**
  81872. * Specifies if the depth write state should be cached
  81873. */
  81874. private _cachedDepthWriteState;
  81875. /**
  81876. * Stores the uniform buffer
  81877. */
  81878. protected _uniformBuffer: UniformBuffer;
  81879. /** @hidden */
  81880. _indexInSceneMaterialArray: number;
  81881. /** @hidden */
  81882. meshMap: Nullable<{
  81883. [id: string]: AbstractMesh | undefined;
  81884. }>;
  81885. /**
  81886. * Creates a material instance
  81887. * @param name defines the name of the material
  81888. * @param scene defines the scene to reference
  81889. * @param doNotAdd specifies if the material should be added to the scene
  81890. */
  81891. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  81892. /**
  81893. * Returns a string representation of the current material
  81894. * @param fullDetails defines a boolean indicating which levels of logging is desired
  81895. * @returns a string with material information
  81896. */
  81897. toString(fullDetails?: boolean): string;
  81898. /**
  81899. * Gets the class name of the material
  81900. * @returns a string with the class name of the material
  81901. */
  81902. getClassName(): string;
  81903. /**
  81904. * Specifies if updates for the material been locked
  81905. */
  81906. readonly isFrozen: boolean;
  81907. /**
  81908. * Locks updates for the material
  81909. */
  81910. freeze(): void;
  81911. /**
  81912. * Unlocks updates for the material
  81913. */
  81914. unfreeze(): void;
  81915. /**
  81916. * Specifies if the material is ready to be used
  81917. * @param mesh defines the mesh to check
  81918. * @param useInstances specifies if instances should be used
  81919. * @returns a boolean indicating if the material is ready to be used
  81920. */
  81921. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  81922. /**
  81923. * Specifies that the submesh is ready to be used
  81924. * @param mesh defines the mesh to check
  81925. * @param subMesh defines which submesh to check
  81926. * @param useInstances specifies that instances should be used
  81927. * @returns a boolean indicating that the submesh is ready or not
  81928. */
  81929. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  81930. /**
  81931. * Returns the material effect
  81932. * @returns the effect associated with the material
  81933. */
  81934. getEffect(): Nullable<Effect>;
  81935. /**
  81936. * Returns the current scene
  81937. * @returns a Scene
  81938. */
  81939. getScene(): Scene;
  81940. /**
  81941. * Specifies if the material will require alpha blending
  81942. * @returns a boolean specifying if alpha blending is needed
  81943. */
  81944. needAlphaBlending(): boolean;
  81945. /**
  81946. * Specifies if the mesh will require alpha blending
  81947. * @param mesh defines the mesh to check
  81948. * @returns a boolean specifying if alpha blending is needed for the mesh
  81949. */
  81950. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  81951. /**
  81952. * Specifies if this material should be rendered in alpha test mode
  81953. * @returns a boolean specifying if an alpha test is needed.
  81954. */
  81955. needAlphaTesting(): boolean;
  81956. /**
  81957. * Gets the texture used for the alpha test
  81958. * @returns the texture to use for alpha testing
  81959. */
  81960. getAlphaTestTexture(): Nullable<BaseTexture>;
  81961. /**
  81962. * Marks the material to indicate that it needs to be re-calculated
  81963. */
  81964. markDirty(): void;
  81965. /** @hidden */
  81966. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  81967. /**
  81968. * Binds the material to the mesh
  81969. * @param world defines the world transformation matrix
  81970. * @param mesh defines the mesh to bind the material to
  81971. */
  81972. bind(world: Matrix, mesh?: Mesh): void;
  81973. /**
  81974. * Binds the submesh to the material
  81975. * @param world defines the world transformation matrix
  81976. * @param mesh defines the mesh containing the submesh
  81977. * @param subMesh defines the submesh to bind the material to
  81978. */
  81979. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  81980. /**
  81981. * Binds the world matrix to the material
  81982. * @param world defines the world transformation matrix
  81983. */
  81984. bindOnlyWorldMatrix(world: Matrix): void;
  81985. /**
  81986. * Binds the scene's uniform buffer to the effect.
  81987. * @param effect defines the effect to bind to the scene uniform buffer
  81988. * @param sceneUbo defines the uniform buffer storing scene data
  81989. */
  81990. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  81991. /**
  81992. * Binds the view matrix to the effect
  81993. * @param effect defines the effect to bind the view matrix to
  81994. */
  81995. bindView(effect: Effect): void;
  81996. /**
  81997. * Binds the view projection matrix to the effect
  81998. * @param effect defines the effect to bind the view projection matrix to
  81999. */
  82000. bindViewProjection(effect: Effect): void;
  82001. /**
  82002. * Specifies if material alpha testing should be turned on for the mesh
  82003. * @param mesh defines the mesh to check
  82004. */
  82005. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  82006. /**
  82007. * Processes to execute after binding the material to a mesh
  82008. * @param mesh defines the rendered mesh
  82009. */
  82010. protected _afterBind(mesh?: Mesh): void;
  82011. /**
  82012. * Unbinds the material from the mesh
  82013. */
  82014. unbind(): void;
  82015. /**
  82016. * Gets the active textures from the material
  82017. * @returns an array of textures
  82018. */
  82019. getActiveTextures(): BaseTexture[];
  82020. /**
  82021. * Specifies if the material uses a texture
  82022. * @param texture defines the texture to check against the material
  82023. * @returns a boolean specifying if the material uses the texture
  82024. */
  82025. hasTexture(texture: BaseTexture): boolean;
  82026. /**
  82027. * Makes a duplicate of the material, and gives it a new name
  82028. * @param name defines the new name for the duplicated material
  82029. * @returns the cloned material
  82030. */
  82031. clone(name: string): Nullable<Material>;
  82032. /**
  82033. * Gets the meshes bound to the material
  82034. * @returns an array of meshes bound to the material
  82035. */
  82036. getBindedMeshes(): AbstractMesh[];
  82037. /**
  82038. * Force shader compilation
  82039. * @param mesh defines the mesh associated with this material
  82040. * @param onCompiled defines a function to execute once the material is compiled
  82041. * @param options defines the options to configure the compilation
  82042. */
  82043. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  82044. clipPlane: boolean;
  82045. }>): void;
  82046. /**
  82047. * Force shader compilation
  82048. * @param mesh defines the mesh that will use this material
  82049. * @param options defines additional options for compiling the shaders
  82050. * @returns a promise that resolves when the compilation completes
  82051. */
  82052. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  82053. clipPlane: boolean;
  82054. }>): Promise<void>;
  82055. private static readonly _ImageProcessingDirtyCallBack;
  82056. private static readonly _TextureDirtyCallBack;
  82057. private static readonly _FresnelDirtyCallBack;
  82058. private static readonly _MiscDirtyCallBack;
  82059. private static readonly _LightsDirtyCallBack;
  82060. private static readonly _AttributeDirtyCallBack;
  82061. private static _FresnelAndMiscDirtyCallBack;
  82062. private static _TextureAndMiscDirtyCallBack;
  82063. private static readonly _DirtyCallbackArray;
  82064. private static readonly _RunDirtyCallBacks;
  82065. /**
  82066. * Marks a define in the material to indicate that it needs to be re-computed
  82067. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  82068. */
  82069. markAsDirty(flag: number): void;
  82070. /**
  82071. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  82072. * @param func defines a function which checks material defines against the submeshes
  82073. */
  82074. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  82075. /**
  82076. * Indicates that image processing needs to be re-calculated for all submeshes
  82077. */
  82078. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  82079. /**
  82080. * Indicates that textures need to be re-calculated for all submeshes
  82081. */
  82082. protected _markAllSubMeshesAsTexturesDirty(): void;
  82083. /**
  82084. * Indicates that fresnel needs to be re-calculated for all submeshes
  82085. */
  82086. protected _markAllSubMeshesAsFresnelDirty(): void;
  82087. /**
  82088. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  82089. */
  82090. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  82091. /**
  82092. * Indicates that lights need to be re-calculated for all submeshes
  82093. */
  82094. protected _markAllSubMeshesAsLightsDirty(): void;
  82095. /**
  82096. * Indicates that attributes need to be re-calculated for all submeshes
  82097. */
  82098. protected _markAllSubMeshesAsAttributesDirty(): void;
  82099. /**
  82100. * Indicates that misc needs to be re-calculated for all submeshes
  82101. */
  82102. protected _markAllSubMeshesAsMiscDirty(): void;
  82103. /**
  82104. * Indicates that textures and misc need to be re-calculated for all submeshes
  82105. */
  82106. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  82107. /**
  82108. * Disposes the material
  82109. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  82110. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  82111. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  82112. */
  82113. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  82114. /** @hidden */
  82115. private releaseVertexArrayObject;
  82116. /**
  82117. * Serializes this material
  82118. * @returns the serialized material object
  82119. */
  82120. serialize(): any;
  82121. /**
  82122. * Creates a material from parsed material data
  82123. * @param parsedMaterial defines parsed material data
  82124. * @param scene defines the hosting scene
  82125. * @param rootUrl defines the root URL to use to load textures
  82126. * @returns a new material
  82127. */
  82128. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  82129. }
  82130. }
  82131. declare module BABYLON {
  82132. /**
  82133. * Base class for submeshes
  82134. */
  82135. export class BaseSubMesh {
  82136. /** @hidden */
  82137. _materialDefines: Nullable<MaterialDefines>;
  82138. /** @hidden */
  82139. _materialEffect: Nullable<Effect>;
  82140. /**
  82141. * Gets associated effect
  82142. */
  82143. readonly effect: Nullable<Effect>;
  82144. /**
  82145. * Sets associated effect (effect used to render this submesh)
  82146. * @param effect defines the effect to associate with
  82147. * @param defines defines the set of defines used to compile this effect
  82148. */
  82149. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  82150. }
  82151. /**
  82152. * Defines a subdivision inside a mesh
  82153. */
  82154. export class SubMesh extends BaseSubMesh implements ICullable {
  82155. /** the material index to use */
  82156. materialIndex: number;
  82157. /** vertex index start */
  82158. verticesStart: number;
  82159. /** vertices count */
  82160. verticesCount: number;
  82161. /** index start */
  82162. indexStart: number;
  82163. /** indices count */
  82164. indexCount: number;
  82165. /** @hidden */
  82166. _linesIndexCount: number;
  82167. private _mesh;
  82168. private _renderingMesh;
  82169. private _boundingInfo;
  82170. private _linesIndexBuffer;
  82171. /** @hidden */
  82172. _lastColliderWorldVertices: Nullable<Vector3[]>;
  82173. /** @hidden */
  82174. _trianglePlanes: Plane[];
  82175. /** @hidden */
  82176. _lastColliderTransformMatrix: Nullable<Matrix>;
  82177. /** @hidden */
  82178. _renderId: number;
  82179. /** @hidden */
  82180. _alphaIndex: number;
  82181. /** @hidden */
  82182. _distanceToCamera: number;
  82183. /** @hidden */
  82184. _id: number;
  82185. private _currentMaterial;
  82186. /**
  82187. * Add a new submesh to a mesh
  82188. * @param materialIndex defines the material index to use
  82189. * @param verticesStart defines vertex index start
  82190. * @param verticesCount defines vertices count
  82191. * @param indexStart defines index start
  82192. * @param indexCount defines indices count
  82193. * @param mesh defines the parent mesh
  82194. * @param renderingMesh defines an optional rendering mesh
  82195. * @param createBoundingBox defines if bounding box should be created for this submesh
  82196. * @returns the new submesh
  82197. */
  82198. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  82199. /**
  82200. * Creates a new submesh
  82201. * @param materialIndex defines the material index to use
  82202. * @param verticesStart defines vertex index start
  82203. * @param verticesCount defines vertices count
  82204. * @param indexStart defines index start
  82205. * @param indexCount defines indices count
  82206. * @param mesh defines the parent mesh
  82207. * @param renderingMesh defines an optional rendering mesh
  82208. * @param createBoundingBox defines if bounding box should be created for this submesh
  82209. */
  82210. constructor(
  82211. /** the material index to use */
  82212. materialIndex: number,
  82213. /** vertex index start */
  82214. verticesStart: number,
  82215. /** vertices count */
  82216. verticesCount: number,
  82217. /** index start */
  82218. indexStart: number,
  82219. /** indices count */
  82220. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  82221. /**
  82222. * Returns true if this submesh covers the entire parent mesh
  82223. * @ignorenaming
  82224. */
  82225. readonly IsGlobal: boolean;
  82226. /**
  82227. * Returns the submesh BoudingInfo object
  82228. * @returns current bounding info (or mesh's one if the submesh is global)
  82229. */
  82230. getBoundingInfo(): BoundingInfo;
  82231. /**
  82232. * Sets the submesh BoundingInfo
  82233. * @param boundingInfo defines the new bounding info to use
  82234. * @returns the SubMesh
  82235. */
  82236. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  82237. /**
  82238. * Returns the mesh of the current submesh
  82239. * @return the parent mesh
  82240. */
  82241. getMesh(): AbstractMesh;
  82242. /**
  82243. * Returns the rendering mesh of the submesh
  82244. * @returns the rendering mesh (could be different from parent mesh)
  82245. */
  82246. getRenderingMesh(): Mesh;
  82247. /**
  82248. * Returns the submesh material
  82249. * @returns null or the current material
  82250. */
  82251. getMaterial(): Nullable<Material>;
  82252. /**
  82253. * Sets a new updated BoundingInfo object to the submesh
  82254. * @param data defines an optional position array to use to determine the bounding info
  82255. * @returns the SubMesh
  82256. */
  82257. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  82258. /** @hidden */
  82259. _checkCollision(collider: Collider): boolean;
  82260. /**
  82261. * Updates the submesh BoundingInfo
  82262. * @param world defines the world matrix to use to update the bounding info
  82263. * @returns the submesh
  82264. */
  82265. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  82266. /**
  82267. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  82268. * @param frustumPlanes defines the frustum planes
  82269. * @returns true if the submesh is intersecting with the frustum
  82270. */
  82271. isInFrustum(frustumPlanes: Plane[]): boolean;
  82272. /**
  82273. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  82274. * @param frustumPlanes defines the frustum planes
  82275. * @returns true if the submesh is inside the frustum
  82276. */
  82277. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  82278. /**
  82279. * Renders the submesh
  82280. * @param enableAlphaMode defines if alpha needs to be used
  82281. * @returns the submesh
  82282. */
  82283. render(enableAlphaMode: boolean): SubMesh;
  82284. /**
  82285. * @hidden
  82286. */
  82287. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  82288. /**
  82289. * Checks if the submesh intersects with a ray
  82290. * @param ray defines the ray to test
  82291. * @returns true is the passed ray intersects the submesh bounding box
  82292. */
  82293. canIntersects(ray: Ray): boolean;
  82294. /**
  82295. * Intersects current submesh with a ray
  82296. * @param ray defines the ray to test
  82297. * @param positions defines mesh's positions array
  82298. * @param indices defines mesh's indices array
  82299. * @param fastCheck defines if only bounding info should be used
  82300. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  82301. * @returns intersection info or null if no intersection
  82302. */
  82303. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  82304. /** @hidden */
  82305. private _intersectLines;
  82306. /** @hidden */
  82307. private _intersectTriangles;
  82308. /** @hidden */
  82309. _rebuild(): void;
  82310. /**
  82311. * Creates a new submesh from the passed mesh
  82312. * @param newMesh defines the new hosting mesh
  82313. * @param newRenderingMesh defines an optional rendering mesh
  82314. * @returns the new submesh
  82315. */
  82316. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  82317. /**
  82318. * Release associated resources
  82319. */
  82320. dispose(): void;
  82321. /**
  82322. * Gets the class name
  82323. * @returns the string "SubMesh".
  82324. */
  82325. getClassName(): string;
  82326. /**
  82327. * Creates a new submesh from indices data
  82328. * @param materialIndex the index of the main mesh material
  82329. * @param startIndex the index where to start the copy in the mesh indices array
  82330. * @param indexCount the number of indices to copy then from the startIndex
  82331. * @param mesh the main mesh to create the submesh from
  82332. * @param renderingMesh the optional rendering mesh
  82333. * @returns a new submesh
  82334. */
  82335. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  82336. }
  82337. }
  82338. declare module BABYLON {
  82339. /**
  82340. * Class used to store geometry data (vertex buffers + index buffer)
  82341. */
  82342. export class Geometry implements IGetSetVerticesData {
  82343. /**
  82344. * Gets or sets the ID of the geometry
  82345. */
  82346. id: string;
  82347. /**
  82348. * Gets or sets the unique ID of the geometry
  82349. */
  82350. uniqueId: number;
  82351. /**
  82352. * Gets the delay loading state of the geometry (none by default which means not delayed)
  82353. */
  82354. delayLoadState: number;
  82355. /**
  82356. * Gets the file containing the data to load when running in delay load state
  82357. */
  82358. delayLoadingFile: Nullable<string>;
  82359. /**
  82360. * Callback called when the geometry is updated
  82361. */
  82362. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  82363. private _scene;
  82364. private _engine;
  82365. private _meshes;
  82366. private _totalVertices;
  82367. /** @hidden */
  82368. _indices: IndicesArray;
  82369. /** @hidden */
  82370. _vertexBuffers: {
  82371. [key: string]: VertexBuffer;
  82372. };
  82373. private _isDisposed;
  82374. private _extend;
  82375. private _boundingBias;
  82376. /** @hidden */
  82377. _delayInfo: Array<string>;
  82378. private _indexBuffer;
  82379. private _indexBufferIsUpdatable;
  82380. /** @hidden */
  82381. _boundingInfo: Nullable<BoundingInfo>;
  82382. /** @hidden */
  82383. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  82384. /** @hidden */
  82385. _softwareSkinningFrameId: number;
  82386. private _vertexArrayObjects;
  82387. private _updatable;
  82388. /** @hidden */
  82389. _positions: Nullable<Vector3[]>;
  82390. /**
  82391. * 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
  82392. */
  82393. /**
  82394. * 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
  82395. */
  82396. boundingBias: Vector2;
  82397. /**
  82398. * Static function used to attach a new empty geometry to a mesh
  82399. * @param mesh defines the mesh to attach the geometry to
  82400. * @returns the new Geometry
  82401. */
  82402. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  82403. /**
  82404. * Creates a new geometry
  82405. * @param id defines the unique ID
  82406. * @param scene defines the hosting scene
  82407. * @param vertexData defines the VertexData used to get geometry data
  82408. * @param updatable defines if geometry must be updatable (false by default)
  82409. * @param mesh defines the mesh that will be associated with the geometry
  82410. */
  82411. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  82412. /**
  82413. * Gets the current extend of the geometry
  82414. */
  82415. readonly extend: {
  82416. minimum: Vector3;
  82417. maximum: Vector3;
  82418. };
  82419. /**
  82420. * Gets the hosting scene
  82421. * @returns the hosting Scene
  82422. */
  82423. getScene(): Scene;
  82424. /**
  82425. * Gets the hosting engine
  82426. * @returns the hosting Engine
  82427. */
  82428. getEngine(): Engine;
  82429. /**
  82430. * Defines if the geometry is ready to use
  82431. * @returns true if the geometry is ready to be used
  82432. */
  82433. isReady(): boolean;
  82434. /**
  82435. * Gets a value indicating that the geometry should not be serialized
  82436. */
  82437. readonly doNotSerialize: boolean;
  82438. /** @hidden */
  82439. _rebuild(): void;
  82440. /**
  82441. * Affects all geometry data in one call
  82442. * @param vertexData defines the geometry data
  82443. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  82444. */
  82445. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  82446. /**
  82447. * Set specific vertex data
  82448. * @param kind defines the data kind (Position, normal, etc...)
  82449. * @param data defines the vertex data to use
  82450. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82451. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82452. */
  82453. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  82454. /**
  82455. * Removes a specific vertex data
  82456. * @param kind defines the data kind (Position, normal, etc...)
  82457. */
  82458. removeVerticesData(kind: string): void;
  82459. /**
  82460. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  82461. * @param buffer defines the vertex buffer to use
  82462. * @param totalVertices defines the total number of vertices for position kind (could be null)
  82463. */
  82464. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  82465. /**
  82466. * Update a specific vertex buffer
  82467. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  82468. * It will do nothing if the buffer is not updatable
  82469. * @param kind defines the data kind (Position, normal, etc...)
  82470. * @param data defines the data to use
  82471. * @param offset defines the offset in the target buffer where to store the data
  82472. * @param useBytes set to true if the offset is in bytes
  82473. */
  82474. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  82475. /**
  82476. * Update a specific vertex buffer
  82477. * This function will create a new buffer if the current one is not updatable
  82478. * @param kind defines the data kind (Position, normal, etc...)
  82479. * @param data defines the data to use
  82480. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  82481. */
  82482. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  82483. private _updateBoundingInfo;
  82484. /** @hidden */
  82485. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  82486. /**
  82487. * Gets total number of vertices
  82488. * @returns the total number of vertices
  82489. */
  82490. getTotalVertices(): number;
  82491. /**
  82492. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82493. * @param kind defines the data kind (Position, normal, etc...)
  82494. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82495. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82496. * @returns a float array containing vertex data
  82497. */
  82498. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82499. /**
  82500. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  82501. * @param kind defines the data kind (Position, normal, etc...)
  82502. * @returns true if the vertex buffer with the specified kind is updatable
  82503. */
  82504. isVertexBufferUpdatable(kind: string): boolean;
  82505. /**
  82506. * Gets a specific vertex buffer
  82507. * @param kind defines the data kind (Position, normal, etc...)
  82508. * @returns a VertexBuffer
  82509. */
  82510. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  82511. /**
  82512. * Returns all vertex buffers
  82513. * @return an object holding all vertex buffers indexed by kind
  82514. */
  82515. getVertexBuffers(): Nullable<{
  82516. [key: string]: VertexBuffer;
  82517. }>;
  82518. /**
  82519. * Gets a boolean indicating if specific vertex buffer is present
  82520. * @param kind defines the data kind (Position, normal, etc...)
  82521. * @returns true if data is present
  82522. */
  82523. isVerticesDataPresent(kind: string): boolean;
  82524. /**
  82525. * Gets a list of all attached data kinds (Position, normal, etc...)
  82526. * @returns a list of string containing all kinds
  82527. */
  82528. getVerticesDataKinds(): string[];
  82529. /**
  82530. * Update index buffer
  82531. * @param indices defines the indices to store in the index buffer
  82532. * @param offset defines the offset in the target buffer where to store the data
  82533. * @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)
  82534. */
  82535. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  82536. /**
  82537. * Creates a new index buffer
  82538. * @param indices defines the indices to store in the index buffer
  82539. * @param totalVertices defines the total number of vertices (could be null)
  82540. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  82541. */
  82542. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  82543. /**
  82544. * Return the total number of indices
  82545. * @returns the total number of indices
  82546. */
  82547. getTotalIndices(): number;
  82548. /**
  82549. * Gets the index buffer array
  82550. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82551. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82552. * @returns the index buffer array
  82553. */
  82554. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82555. /**
  82556. * Gets the index buffer
  82557. * @return the index buffer
  82558. */
  82559. getIndexBuffer(): Nullable<DataBuffer>;
  82560. /** @hidden */
  82561. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  82562. /**
  82563. * Release the associated resources for a specific mesh
  82564. * @param mesh defines the source mesh
  82565. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  82566. */
  82567. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  82568. /**
  82569. * Apply current geometry to a given mesh
  82570. * @param mesh defines the mesh to apply geometry to
  82571. */
  82572. applyToMesh(mesh: Mesh): void;
  82573. private _updateExtend;
  82574. private _applyToMesh;
  82575. private notifyUpdate;
  82576. /**
  82577. * Load the geometry if it was flagged as delay loaded
  82578. * @param scene defines the hosting scene
  82579. * @param onLoaded defines a callback called when the geometry is loaded
  82580. */
  82581. load(scene: Scene, onLoaded?: () => void): void;
  82582. private _queueLoad;
  82583. /**
  82584. * Invert the geometry to move from a right handed system to a left handed one.
  82585. */
  82586. toLeftHanded(): void;
  82587. /** @hidden */
  82588. _resetPointsArrayCache(): void;
  82589. /** @hidden */
  82590. _generatePointsArray(): boolean;
  82591. /**
  82592. * Gets a value indicating if the geometry is disposed
  82593. * @returns true if the geometry was disposed
  82594. */
  82595. isDisposed(): boolean;
  82596. private _disposeVertexArrayObjects;
  82597. /**
  82598. * Free all associated resources
  82599. */
  82600. dispose(): void;
  82601. /**
  82602. * Clone the current geometry into a new geometry
  82603. * @param id defines the unique ID of the new geometry
  82604. * @returns a new geometry object
  82605. */
  82606. copy(id: string): Geometry;
  82607. /**
  82608. * Serialize the current geometry info (and not the vertices data) into a JSON object
  82609. * @return a JSON representation of the current geometry data (without the vertices data)
  82610. */
  82611. serialize(): any;
  82612. private toNumberArray;
  82613. /**
  82614. * Serialize all vertices data into a JSON oject
  82615. * @returns a JSON representation of the current geometry data
  82616. */
  82617. serializeVerticeData(): any;
  82618. /**
  82619. * Extracts a clone of a mesh geometry
  82620. * @param mesh defines the source mesh
  82621. * @param id defines the unique ID of the new geometry object
  82622. * @returns the new geometry object
  82623. */
  82624. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  82625. /**
  82626. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  82627. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  82628. * Be aware Math.random() could cause collisions, but:
  82629. * "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"
  82630. * @returns a string containing a new GUID
  82631. */
  82632. static RandomId(): string;
  82633. /** @hidden */
  82634. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  82635. private static _CleanMatricesWeights;
  82636. /**
  82637. * Create a new geometry from persisted data (Using .babylon file format)
  82638. * @param parsedVertexData defines the persisted data
  82639. * @param scene defines the hosting scene
  82640. * @param rootUrl defines the root url to use to load assets (like delayed data)
  82641. * @returns the new geometry object
  82642. */
  82643. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  82644. }
  82645. }
  82646. declare module BABYLON {
  82647. /**
  82648. * Define an interface for all classes that will get and set the data on vertices
  82649. */
  82650. export interface IGetSetVerticesData {
  82651. /**
  82652. * Gets a boolean indicating if specific vertex data is present
  82653. * @param kind defines the vertex data kind to use
  82654. * @returns true is data kind is present
  82655. */
  82656. isVerticesDataPresent(kind: string): boolean;
  82657. /**
  82658. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82659. * @param kind defines the data kind (Position, normal, etc...)
  82660. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82661. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82662. * @returns a float array containing vertex data
  82663. */
  82664. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82665. /**
  82666. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  82667. * @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.
  82668. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82669. * @returns the indices array or an empty array if the mesh has no geometry
  82670. */
  82671. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82672. /**
  82673. * Set specific vertex data
  82674. * @param kind defines the data kind (Position, normal, etc...)
  82675. * @param data defines the vertex data to use
  82676. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82677. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82678. */
  82679. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  82680. /**
  82681. * Update a specific associated vertex buffer
  82682. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  82683. * - VertexBuffer.PositionKind
  82684. * - VertexBuffer.UVKind
  82685. * - VertexBuffer.UV2Kind
  82686. * - VertexBuffer.UV3Kind
  82687. * - VertexBuffer.UV4Kind
  82688. * - VertexBuffer.UV5Kind
  82689. * - VertexBuffer.UV6Kind
  82690. * - VertexBuffer.ColorKind
  82691. * - VertexBuffer.MatricesIndicesKind
  82692. * - VertexBuffer.MatricesIndicesExtraKind
  82693. * - VertexBuffer.MatricesWeightsKind
  82694. * - VertexBuffer.MatricesWeightsExtraKind
  82695. * @param data defines the data source
  82696. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  82697. * @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)
  82698. */
  82699. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  82700. /**
  82701. * Creates a new index buffer
  82702. * @param indices defines the indices to store in the index buffer
  82703. * @param totalVertices defines the total number of vertices (could be null)
  82704. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  82705. */
  82706. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  82707. }
  82708. /**
  82709. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  82710. */
  82711. export class VertexData {
  82712. /**
  82713. * Mesh side orientation : usually the external or front surface
  82714. */
  82715. static readonly FRONTSIDE: number;
  82716. /**
  82717. * Mesh side orientation : usually the internal or back surface
  82718. */
  82719. static readonly BACKSIDE: number;
  82720. /**
  82721. * Mesh side orientation : both internal and external or front and back surfaces
  82722. */
  82723. static readonly DOUBLESIDE: number;
  82724. /**
  82725. * Mesh side orientation : by default, `FRONTSIDE`
  82726. */
  82727. static readonly DEFAULTSIDE: number;
  82728. /**
  82729. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  82730. */
  82731. positions: Nullable<FloatArray>;
  82732. /**
  82733. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  82734. */
  82735. normals: Nullable<FloatArray>;
  82736. /**
  82737. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  82738. */
  82739. tangents: Nullable<FloatArray>;
  82740. /**
  82741. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82742. */
  82743. uvs: Nullable<FloatArray>;
  82744. /**
  82745. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82746. */
  82747. uvs2: Nullable<FloatArray>;
  82748. /**
  82749. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82750. */
  82751. uvs3: Nullable<FloatArray>;
  82752. /**
  82753. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82754. */
  82755. uvs4: Nullable<FloatArray>;
  82756. /**
  82757. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82758. */
  82759. uvs5: Nullable<FloatArray>;
  82760. /**
  82761. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82762. */
  82763. uvs6: Nullable<FloatArray>;
  82764. /**
  82765. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  82766. */
  82767. colors: Nullable<FloatArray>;
  82768. /**
  82769. * 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).
  82770. */
  82771. matricesIndices: Nullable<FloatArray>;
  82772. /**
  82773. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  82774. */
  82775. matricesWeights: Nullable<FloatArray>;
  82776. /**
  82777. * An array extending the number of possible indices
  82778. */
  82779. matricesIndicesExtra: Nullable<FloatArray>;
  82780. /**
  82781. * An array extending the number of possible weights when the number of indices is extended
  82782. */
  82783. matricesWeightsExtra: Nullable<FloatArray>;
  82784. /**
  82785. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  82786. */
  82787. indices: Nullable<IndicesArray>;
  82788. /**
  82789. * Uses the passed data array to set the set the values for the specified kind of data
  82790. * @param data a linear array of floating numbers
  82791. * @param kind the type of data that is being set, eg positions, colors etc
  82792. */
  82793. set(data: FloatArray, kind: string): void;
  82794. /**
  82795. * Associates the vertexData to the passed Mesh.
  82796. * Sets it as updatable or not (default `false`)
  82797. * @param mesh the mesh the vertexData is applied to
  82798. * @param updatable when used and having the value true allows new data to update the vertexData
  82799. * @returns the VertexData
  82800. */
  82801. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  82802. /**
  82803. * Associates the vertexData to the passed Geometry.
  82804. * Sets it as updatable or not (default `false`)
  82805. * @param geometry the geometry the vertexData is applied to
  82806. * @param updatable when used and having the value true allows new data to update the vertexData
  82807. * @returns VertexData
  82808. */
  82809. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  82810. /**
  82811. * Updates the associated mesh
  82812. * @param mesh the mesh to be updated
  82813. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  82814. * @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
  82815. * @returns VertexData
  82816. */
  82817. updateMesh(mesh: Mesh): VertexData;
  82818. /**
  82819. * Updates the associated geometry
  82820. * @param geometry the geometry to be updated
  82821. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  82822. * @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
  82823. * @returns VertexData.
  82824. */
  82825. updateGeometry(geometry: Geometry): VertexData;
  82826. private _applyTo;
  82827. private _update;
  82828. /**
  82829. * Transforms each position and each normal of the vertexData according to the passed Matrix
  82830. * @param matrix the transforming matrix
  82831. * @returns the VertexData
  82832. */
  82833. transform(matrix: Matrix): VertexData;
  82834. /**
  82835. * Merges the passed VertexData into the current one
  82836. * @param other the VertexData to be merged into the current one
  82837. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  82838. * @returns the modified VertexData
  82839. */
  82840. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  82841. private _mergeElement;
  82842. private _validate;
  82843. /**
  82844. * Serializes the VertexData
  82845. * @returns a serialized object
  82846. */
  82847. serialize(): any;
  82848. /**
  82849. * Extracts the vertexData from a mesh
  82850. * @param mesh the mesh from which to extract the VertexData
  82851. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  82852. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  82853. * @returns the object VertexData associated to the passed mesh
  82854. */
  82855. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  82856. /**
  82857. * Extracts the vertexData from the geometry
  82858. * @param geometry the geometry from which to extract the VertexData
  82859. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  82860. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  82861. * @returns the object VertexData associated to the passed mesh
  82862. */
  82863. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  82864. private static _ExtractFrom;
  82865. /**
  82866. * Creates the VertexData for a Ribbon
  82867. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  82868. * * pathArray array of paths, each of which an array of successive Vector3
  82869. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  82870. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  82871. * * 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
  82872. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82873. * * 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)
  82874. * * 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)
  82875. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  82876. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  82877. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  82878. * @returns the VertexData of the ribbon
  82879. */
  82880. static CreateRibbon(options: {
  82881. pathArray: Vector3[][];
  82882. closeArray?: boolean;
  82883. closePath?: boolean;
  82884. offset?: number;
  82885. sideOrientation?: number;
  82886. frontUVs?: Vector4;
  82887. backUVs?: Vector4;
  82888. invertUV?: boolean;
  82889. uvs?: Vector2[];
  82890. colors?: Color4[];
  82891. }): VertexData;
  82892. /**
  82893. * Creates the VertexData for a box
  82894. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82895. * * size sets the width, height and depth of the box to the value of size, optional default 1
  82896. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  82897. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  82898. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  82899. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  82900. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  82901. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82902. * * 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)
  82903. * * 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)
  82904. * @returns the VertexData of the box
  82905. */
  82906. static CreateBox(options: {
  82907. size?: number;
  82908. width?: number;
  82909. height?: number;
  82910. depth?: number;
  82911. faceUV?: Vector4[];
  82912. faceColors?: Color4[];
  82913. sideOrientation?: number;
  82914. frontUVs?: Vector4;
  82915. backUVs?: Vector4;
  82916. }): VertexData;
  82917. /**
  82918. * Creates the VertexData for an ellipsoid, defaults to a sphere
  82919. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82920. * * segments sets the number of horizontal strips optional, default 32
  82921. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  82922. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  82923. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  82924. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  82925. * * 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
  82926. * * 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
  82927. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82928. * * 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)
  82929. * * 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)
  82930. * @returns the VertexData of the ellipsoid
  82931. */
  82932. static CreateSphere(options: {
  82933. segments?: number;
  82934. diameter?: number;
  82935. diameterX?: number;
  82936. diameterY?: number;
  82937. diameterZ?: number;
  82938. arc?: number;
  82939. slice?: number;
  82940. sideOrientation?: number;
  82941. frontUVs?: Vector4;
  82942. backUVs?: Vector4;
  82943. }): VertexData;
  82944. /**
  82945. * Creates the VertexData for a cylinder, cone or prism
  82946. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82947. * * height sets the height (y direction) of the cylinder, optional, default 2
  82948. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  82949. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  82950. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  82951. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  82952. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  82953. * * 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
  82954. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82955. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82956. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  82957. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  82958. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82959. * * 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)
  82960. * * 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)
  82961. * @returns the VertexData of the cylinder, cone or prism
  82962. */
  82963. static CreateCylinder(options: {
  82964. height?: number;
  82965. diameterTop?: number;
  82966. diameterBottom?: number;
  82967. diameter?: number;
  82968. tessellation?: number;
  82969. subdivisions?: number;
  82970. arc?: number;
  82971. faceColors?: Color4[];
  82972. faceUV?: Vector4[];
  82973. hasRings?: boolean;
  82974. enclose?: boolean;
  82975. sideOrientation?: number;
  82976. frontUVs?: Vector4;
  82977. backUVs?: Vector4;
  82978. }): VertexData;
  82979. /**
  82980. * Creates the VertexData for a torus
  82981. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82982. * * diameter the diameter of the torus, optional default 1
  82983. * * thickness the diameter of the tube forming the torus, optional default 0.5
  82984. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  82985. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82986. * * 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)
  82987. * * 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)
  82988. * @returns the VertexData of the torus
  82989. */
  82990. static CreateTorus(options: {
  82991. diameter?: number;
  82992. thickness?: number;
  82993. tessellation?: number;
  82994. sideOrientation?: number;
  82995. frontUVs?: Vector4;
  82996. backUVs?: Vector4;
  82997. }): VertexData;
  82998. /**
  82999. * Creates the VertexData of the LineSystem
  83000. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  83001. * - lines an array of lines, each line being an array of successive Vector3
  83002. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  83003. * @returns the VertexData of the LineSystem
  83004. */
  83005. static CreateLineSystem(options: {
  83006. lines: Vector3[][];
  83007. colors?: Nullable<Color4[][]>;
  83008. }): VertexData;
  83009. /**
  83010. * Create the VertexData for a DashedLines
  83011. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  83012. * - points an array successive Vector3
  83013. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  83014. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  83015. * - dashNb the intended total number of dashes, optional, default 200
  83016. * @returns the VertexData for the DashedLines
  83017. */
  83018. static CreateDashedLines(options: {
  83019. points: Vector3[];
  83020. dashSize?: number;
  83021. gapSize?: number;
  83022. dashNb?: number;
  83023. }): VertexData;
  83024. /**
  83025. * Creates the VertexData for a Ground
  83026. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  83027. * - width the width (x direction) of the ground, optional, default 1
  83028. * - height the height (z direction) of the ground, optional, default 1
  83029. * - subdivisions the number of subdivisions per side, optional, default 1
  83030. * @returns the VertexData of the Ground
  83031. */
  83032. static CreateGround(options: {
  83033. width?: number;
  83034. height?: number;
  83035. subdivisions?: number;
  83036. subdivisionsX?: number;
  83037. subdivisionsY?: number;
  83038. }): VertexData;
  83039. /**
  83040. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  83041. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  83042. * * xmin the ground minimum X coordinate, optional, default -1
  83043. * * zmin the ground minimum Z coordinate, optional, default -1
  83044. * * xmax the ground maximum X coordinate, optional, default 1
  83045. * * zmax the ground maximum Z coordinate, optional, default 1
  83046. * * 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}
  83047. * * 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}
  83048. * @returns the VertexData of the TiledGround
  83049. */
  83050. static CreateTiledGround(options: {
  83051. xmin: number;
  83052. zmin: number;
  83053. xmax: number;
  83054. zmax: number;
  83055. subdivisions?: {
  83056. w: number;
  83057. h: number;
  83058. };
  83059. precision?: {
  83060. w: number;
  83061. h: number;
  83062. };
  83063. }): VertexData;
  83064. /**
  83065. * Creates the VertexData of the Ground designed from a heightmap
  83066. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  83067. * * width the width (x direction) of the ground
  83068. * * height the height (z direction) of the ground
  83069. * * subdivisions the number of subdivisions per side
  83070. * * minHeight the minimum altitude on the ground, optional, default 0
  83071. * * maxHeight the maximum altitude on the ground, optional default 1
  83072. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  83073. * * buffer the array holding the image color data
  83074. * * bufferWidth the width of image
  83075. * * bufferHeight the height of image
  83076. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  83077. * @returns the VertexData of the Ground designed from a heightmap
  83078. */
  83079. static CreateGroundFromHeightMap(options: {
  83080. width: number;
  83081. height: number;
  83082. subdivisions: number;
  83083. minHeight: number;
  83084. maxHeight: number;
  83085. colorFilter: Color3;
  83086. buffer: Uint8Array;
  83087. bufferWidth: number;
  83088. bufferHeight: number;
  83089. alphaFilter: number;
  83090. }): VertexData;
  83091. /**
  83092. * Creates the VertexData for a Plane
  83093. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  83094. * * size sets the width and height of the plane to the value of size, optional default 1
  83095. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  83096. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  83097. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83098. * * 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)
  83099. * * 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)
  83100. * @returns the VertexData of the box
  83101. */
  83102. static CreatePlane(options: {
  83103. size?: number;
  83104. width?: number;
  83105. height?: number;
  83106. sideOrientation?: number;
  83107. frontUVs?: Vector4;
  83108. backUVs?: Vector4;
  83109. }): VertexData;
  83110. /**
  83111. * Creates the VertexData of the Disc or regular Polygon
  83112. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  83113. * * radius the radius of the disc, optional default 0.5
  83114. * * tessellation the number of polygon sides, optional, default 64
  83115. * * 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
  83116. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83117. * * 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)
  83118. * * 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)
  83119. * @returns the VertexData of the box
  83120. */
  83121. static CreateDisc(options: {
  83122. radius?: number;
  83123. tessellation?: number;
  83124. arc?: number;
  83125. sideOrientation?: number;
  83126. frontUVs?: Vector4;
  83127. backUVs?: Vector4;
  83128. }): VertexData;
  83129. /**
  83130. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  83131. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  83132. * @param polygon a mesh built from polygonTriangulation.build()
  83133. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83134. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83135. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83136. * @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)
  83137. * @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)
  83138. * @returns the VertexData of the Polygon
  83139. */
  83140. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  83141. /**
  83142. * Creates the VertexData of the IcoSphere
  83143. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  83144. * * radius the radius of the IcoSphere, optional default 1
  83145. * * radiusX allows stretching in the x direction, optional, default radius
  83146. * * radiusY allows stretching in the y direction, optional, default radius
  83147. * * radiusZ allows stretching in the z direction, optional, default radius
  83148. * * flat when true creates a flat shaded mesh, optional, default true
  83149. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  83150. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83151. * * 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)
  83152. * * 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)
  83153. * @returns the VertexData of the IcoSphere
  83154. */
  83155. static CreateIcoSphere(options: {
  83156. radius?: number;
  83157. radiusX?: number;
  83158. radiusY?: number;
  83159. radiusZ?: number;
  83160. flat?: boolean;
  83161. subdivisions?: number;
  83162. sideOrientation?: number;
  83163. frontUVs?: Vector4;
  83164. backUVs?: Vector4;
  83165. }): VertexData;
  83166. /**
  83167. * Creates the VertexData for a Polyhedron
  83168. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  83169. * * type provided types are:
  83170. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  83171. * * 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)
  83172. * * size the size of the IcoSphere, optional default 1
  83173. * * sizeX allows stretching in the x direction, optional, default size
  83174. * * sizeY allows stretching in the y direction, optional, default size
  83175. * * sizeZ allows stretching in the z direction, optional, default size
  83176. * * 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
  83177. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83178. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83179. * * flat when true creates a flat shaded mesh, optional, default true
  83180. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  83181. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83182. * * 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)
  83183. * * 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)
  83184. * @returns the VertexData of the Polyhedron
  83185. */
  83186. static CreatePolyhedron(options: {
  83187. type?: number;
  83188. size?: number;
  83189. sizeX?: number;
  83190. sizeY?: number;
  83191. sizeZ?: number;
  83192. custom?: any;
  83193. faceUV?: Vector4[];
  83194. faceColors?: Color4[];
  83195. flat?: boolean;
  83196. sideOrientation?: number;
  83197. frontUVs?: Vector4;
  83198. backUVs?: Vector4;
  83199. }): VertexData;
  83200. /**
  83201. * Creates the VertexData for a TorusKnot
  83202. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  83203. * * radius the radius of the torus knot, optional, default 2
  83204. * * tube the thickness of the tube, optional, default 0.5
  83205. * * radialSegments the number of sides on each tube segments, optional, default 32
  83206. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  83207. * * p the number of windings around the z axis, optional, default 2
  83208. * * q the number of windings around the x axis, optional, default 3
  83209. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83210. * * 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)
  83211. * * 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)
  83212. * @returns the VertexData of the Torus Knot
  83213. */
  83214. static CreateTorusKnot(options: {
  83215. radius?: number;
  83216. tube?: number;
  83217. radialSegments?: number;
  83218. tubularSegments?: number;
  83219. p?: number;
  83220. q?: number;
  83221. sideOrientation?: number;
  83222. frontUVs?: Vector4;
  83223. backUVs?: Vector4;
  83224. }): VertexData;
  83225. /**
  83226. * Compute normals for given positions and indices
  83227. * @param positions an array of vertex positions, [...., x, y, z, ......]
  83228. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  83229. * @param normals an array of vertex normals, [...., x, y, z, ......]
  83230. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  83231. * * facetNormals : optional array of facet normals (vector3)
  83232. * * facetPositions : optional array of facet positions (vector3)
  83233. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  83234. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  83235. * * bInfo : optional bounding info, required for facetPartitioning computation
  83236. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  83237. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  83238. * * useRightHandedSystem: optional boolean to for right handed system computation
  83239. * * depthSort : optional boolean to enable the facet depth sort computation
  83240. * * distanceTo : optional Vector3 to compute the facet depth from this location
  83241. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  83242. */
  83243. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  83244. facetNormals?: any;
  83245. facetPositions?: any;
  83246. facetPartitioning?: any;
  83247. ratio?: number;
  83248. bInfo?: any;
  83249. bbSize?: Vector3;
  83250. subDiv?: any;
  83251. useRightHandedSystem?: boolean;
  83252. depthSort?: boolean;
  83253. distanceTo?: Vector3;
  83254. depthSortedFacets?: any;
  83255. }): void;
  83256. /** @hidden */
  83257. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  83258. /**
  83259. * Applies VertexData created from the imported parameters to the geometry
  83260. * @param parsedVertexData the parsed data from an imported file
  83261. * @param geometry the geometry to apply the VertexData to
  83262. */
  83263. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  83264. }
  83265. }
  83266. declare module BABYLON {
  83267. /**
  83268. * Class containing static functions to help procedurally build meshes
  83269. */
  83270. export class DiscBuilder {
  83271. /**
  83272. * Creates a plane polygonal mesh. By default, this is a disc
  83273. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  83274. * * 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
  83275. * * 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
  83276. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  83277. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  83278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  83279. * @param name defines the name of the mesh
  83280. * @param options defines the options used to create the mesh
  83281. * @param scene defines the hosting scene
  83282. * @returns the plane polygonal mesh
  83283. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  83284. */
  83285. static CreateDisc(name: string, options: {
  83286. radius?: number;
  83287. tessellation?: number;
  83288. arc?: number;
  83289. updatable?: boolean;
  83290. sideOrientation?: number;
  83291. frontUVs?: Vector4;
  83292. backUVs?: Vector4;
  83293. }, scene?: Nullable<Scene>): Mesh;
  83294. }
  83295. }
  83296. declare module BABYLON {
  83297. /**
  83298. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  83299. *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.
  83300. * The SPS is also a particle system. It provides some methods to manage the particles.
  83301. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  83302. *
  83303. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  83304. */
  83305. export class SolidParticleSystem implements IDisposable {
  83306. /**
  83307. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  83308. * Example : var p = SPS.particles[i];
  83309. */
  83310. particles: SolidParticle[];
  83311. /**
  83312. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  83313. */
  83314. nbParticles: number;
  83315. /**
  83316. * If the particles must ever face the camera (default false). Useful for planar particles.
  83317. */
  83318. billboard: boolean;
  83319. /**
  83320. * Recompute normals when adding a shape
  83321. */
  83322. recomputeNormals: boolean;
  83323. /**
  83324. * This a counter ofr your own usage. It's not set by any SPS functions.
  83325. */
  83326. counter: number;
  83327. /**
  83328. * The SPS name. This name is also given to the underlying mesh.
  83329. */
  83330. name: string;
  83331. /**
  83332. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  83333. */
  83334. mesh: Mesh;
  83335. /**
  83336. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  83337. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  83338. */
  83339. vars: any;
  83340. /**
  83341. * This array is populated when the SPS is set as 'pickable'.
  83342. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  83343. * Each element of this array is an object `{idx: int, faceId: int}`.
  83344. * `idx` is the picked particle index in the `SPS.particles` array
  83345. * `faceId` is the picked face index counted within this particle.
  83346. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  83347. */
  83348. pickedParticles: {
  83349. idx: number;
  83350. faceId: number;
  83351. }[];
  83352. /**
  83353. * This array is populated when `enableDepthSort` is set to true.
  83354. * Each element of this array is an instance of the class DepthSortedParticle.
  83355. */
  83356. depthSortedParticles: DepthSortedParticle[];
  83357. /**
  83358. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  83359. * @hidden
  83360. */
  83361. _bSphereOnly: boolean;
  83362. /**
  83363. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  83364. * @hidden
  83365. */
  83366. _bSphereRadiusFactor: number;
  83367. private _scene;
  83368. private _positions;
  83369. private _indices;
  83370. private _normals;
  83371. private _colors;
  83372. private _uvs;
  83373. private _indices32;
  83374. private _positions32;
  83375. private _normals32;
  83376. private _fixedNormal32;
  83377. private _colors32;
  83378. private _uvs32;
  83379. private _index;
  83380. private _updatable;
  83381. private _pickable;
  83382. private _isVisibilityBoxLocked;
  83383. private _alwaysVisible;
  83384. private _depthSort;
  83385. private _shapeCounter;
  83386. private _copy;
  83387. private _color;
  83388. private _computeParticleColor;
  83389. private _computeParticleTexture;
  83390. private _computeParticleRotation;
  83391. private _computeParticleVertex;
  83392. private _computeBoundingBox;
  83393. private _depthSortParticles;
  83394. private _camera;
  83395. private _mustUnrotateFixedNormals;
  83396. private _particlesIntersect;
  83397. private _needs32Bits;
  83398. /**
  83399. * Creates a SPS (Solid Particle System) object.
  83400. * @param name (String) is the SPS name, this will be the underlying mesh name.
  83401. * @param scene (Scene) is the scene in which the SPS is added.
  83402. * @param options defines the options of the sps e.g.
  83403. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  83404. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  83405. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  83406. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  83407. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  83408. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  83409. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  83410. */
  83411. constructor(name: string, scene: Scene, options?: {
  83412. updatable?: boolean;
  83413. isPickable?: boolean;
  83414. enableDepthSort?: boolean;
  83415. particleIntersection?: boolean;
  83416. boundingSphereOnly?: boolean;
  83417. bSphereRadiusFactor?: number;
  83418. });
  83419. /**
  83420. * Builds the SPS underlying mesh. Returns a standard Mesh.
  83421. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  83422. * @returns the created mesh
  83423. */
  83424. buildMesh(): Mesh;
  83425. /**
  83426. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  83427. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  83428. * Thus the particles generated from `digest()` have their property `position` set yet.
  83429. * @param mesh ( Mesh ) is the mesh to be digested
  83430. * @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
  83431. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  83432. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  83433. * @returns the current SPS
  83434. */
  83435. digest(mesh: Mesh, options?: {
  83436. facetNb?: number;
  83437. number?: number;
  83438. delta?: number;
  83439. }): SolidParticleSystem;
  83440. private _unrotateFixedNormals;
  83441. private _resetCopy;
  83442. private _meshBuilder;
  83443. private _posToShape;
  83444. private _uvsToShapeUV;
  83445. private _addParticle;
  83446. /**
  83447. * Adds some particles to the SPS from the model shape. Returns the shape id.
  83448. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  83449. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  83450. * @param nb (positive integer) the number of particles to be created from this model
  83451. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  83452. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  83453. * @returns the number of shapes in the system
  83454. */
  83455. addShape(mesh: Mesh, nb: number, options?: {
  83456. positionFunction?: any;
  83457. vertexFunction?: any;
  83458. }): number;
  83459. private _rebuildParticle;
  83460. /**
  83461. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  83462. * @returns the SPS.
  83463. */
  83464. rebuildMesh(): SolidParticleSystem;
  83465. /**
  83466. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  83467. * This method calls `updateParticle()` for each particle of the SPS.
  83468. * For an animated SPS, it is usually called within the render loop.
  83469. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  83470. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  83471. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  83472. * @returns the SPS.
  83473. */
  83474. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  83475. /**
  83476. * Disposes the SPS.
  83477. */
  83478. dispose(): void;
  83479. /**
  83480. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  83481. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83482. * @returns the SPS.
  83483. */
  83484. refreshVisibleSize(): SolidParticleSystem;
  83485. /**
  83486. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  83487. * @param size the size (float) of the visibility box
  83488. * note : this doesn't lock the SPS mesh bounding box.
  83489. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83490. */
  83491. setVisibilityBox(size: number): void;
  83492. /**
  83493. * Gets whether the SPS as always visible or not
  83494. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83495. */
  83496. /**
  83497. * Sets the SPS as always visible or not
  83498. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83499. */
  83500. isAlwaysVisible: boolean;
  83501. /**
  83502. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  83503. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83504. */
  83505. /**
  83506. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  83507. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83508. */
  83509. isVisibilityBoxLocked: boolean;
  83510. /**
  83511. * Tells to `setParticles()` to compute the particle rotations or not.
  83512. * Default value : true. The SPS is faster when it's set to false.
  83513. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83514. */
  83515. /**
  83516. * Gets if `setParticles()` computes the particle rotations or not.
  83517. * Default value : true. The SPS is faster when it's set to false.
  83518. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83519. */
  83520. computeParticleRotation: boolean;
  83521. /**
  83522. * Tells to `setParticles()` to compute the particle colors or not.
  83523. * Default value : true. The SPS is faster when it's set to false.
  83524. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83525. */
  83526. /**
  83527. * Gets if `setParticles()` computes the particle colors or not.
  83528. * Default value : true. The SPS is faster when it's set to false.
  83529. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83530. */
  83531. computeParticleColor: boolean;
  83532. /**
  83533. * Gets if `setParticles()` computes the particle textures or not.
  83534. * Default value : true. The SPS is faster when it's set to false.
  83535. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  83536. */
  83537. computeParticleTexture: boolean;
  83538. /**
  83539. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  83540. * Default value : false. The SPS is faster when it's set to false.
  83541. * Note : the particle custom vertex positions aren't stored values.
  83542. */
  83543. /**
  83544. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  83545. * Default value : false. The SPS is faster when it's set to false.
  83546. * Note : the particle custom vertex positions aren't stored values.
  83547. */
  83548. computeParticleVertex: boolean;
  83549. /**
  83550. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  83551. */
  83552. /**
  83553. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  83554. */
  83555. computeBoundingBox: boolean;
  83556. /**
  83557. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  83558. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83559. * Default : `true`
  83560. */
  83561. /**
  83562. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  83563. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83564. * Default : `true`
  83565. */
  83566. depthSortParticles: boolean;
  83567. /**
  83568. * This function does nothing. It may be overwritten to set all the particle first values.
  83569. * The SPS doesn't call this function, you may have to call it by your own.
  83570. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83571. */
  83572. initParticles(): void;
  83573. /**
  83574. * This function does nothing. It may be overwritten to recycle a particle.
  83575. * The SPS doesn't call this function, you may have to call it by your own.
  83576. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83577. * @param particle The particle to recycle
  83578. * @returns the recycled particle
  83579. */
  83580. recycleParticle(particle: SolidParticle): SolidParticle;
  83581. /**
  83582. * Updates a particle : this function should be overwritten by the user.
  83583. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  83584. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83585. * @example : just set a particle position or velocity and recycle conditions
  83586. * @param particle The particle to update
  83587. * @returns the updated particle
  83588. */
  83589. updateParticle(particle: SolidParticle): SolidParticle;
  83590. /**
  83591. * Updates a vertex of a particle : it can be overwritten by the user.
  83592. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  83593. * @param particle the current particle
  83594. * @param vertex the current index of the current particle
  83595. * @param pt the index of the current vertex in the particle shape
  83596. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  83597. * @example : just set a vertex particle position
  83598. * @returns the updated vertex
  83599. */
  83600. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  83601. /**
  83602. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  83603. * This does nothing and may be overwritten by the user.
  83604. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83605. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83606. * @param update the boolean update value actually passed to setParticles()
  83607. */
  83608. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83609. /**
  83610. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  83611. * This will be passed three parameters.
  83612. * This does nothing and may be overwritten by the user.
  83613. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83614. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83615. * @param update the boolean update value actually passed to setParticles()
  83616. */
  83617. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83618. }
  83619. }
  83620. declare module BABYLON {
  83621. /**
  83622. * Represents one particle of a solid particle system.
  83623. */
  83624. export class SolidParticle {
  83625. /**
  83626. * particle global index
  83627. */
  83628. idx: number;
  83629. /**
  83630. * The color of the particle
  83631. */
  83632. color: Nullable<Color4>;
  83633. /**
  83634. * The world space position of the particle.
  83635. */
  83636. position: Vector3;
  83637. /**
  83638. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  83639. */
  83640. rotation: Vector3;
  83641. /**
  83642. * The world space rotation quaternion of the particle.
  83643. */
  83644. rotationQuaternion: Nullable<Quaternion>;
  83645. /**
  83646. * The scaling of the particle.
  83647. */
  83648. scaling: Vector3;
  83649. /**
  83650. * The uvs of the particle.
  83651. */
  83652. uvs: Vector4;
  83653. /**
  83654. * The current speed of the particle.
  83655. */
  83656. velocity: Vector3;
  83657. /**
  83658. * The pivot point in the particle local space.
  83659. */
  83660. pivot: Vector3;
  83661. /**
  83662. * Must the particle be translated from its pivot point in its local space ?
  83663. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  83664. * Default : false
  83665. */
  83666. translateFromPivot: boolean;
  83667. /**
  83668. * Is the particle active or not ?
  83669. */
  83670. alive: boolean;
  83671. /**
  83672. * Is the particle visible or not ?
  83673. */
  83674. isVisible: boolean;
  83675. /**
  83676. * Index of this particle in the global "positions" array (Internal use)
  83677. * @hidden
  83678. */
  83679. _pos: number;
  83680. /**
  83681. * @hidden Index of this particle in the global "indices" array (Internal use)
  83682. */
  83683. _ind: number;
  83684. /**
  83685. * @hidden ModelShape of this particle (Internal use)
  83686. */
  83687. _model: ModelShape;
  83688. /**
  83689. * ModelShape id of this particle
  83690. */
  83691. shapeId: number;
  83692. /**
  83693. * Index of the particle in its shape id (Internal use)
  83694. */
  83695. idxInShape: number;
  83696. /**
  83697. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  83698. */
  83699. _modelBoundingInfo: BoundingInfo;
  83700. /**
  83701. * @hidden Particle BoundingInfo object (Internal use)
  83702. */
  83703. _boundingInfo: BoundingInfo;
  83704. /**
  83705. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  83706. */
  83707. _sps: SolidParticleSystem;
  83708. /**
  83709. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  83710. */
  83711. _stillInvisible: boolean;
  83712. /**
  83713. * @hidden Last computed particle rotation matrix
  83714. */
  83715. _rotationMatrix: number[];
  83716. /**
  83717. * Parent particle Id, if any.
  83718. * Default null.
  83719. */
  83720. parentId: Nullable<number>;
  83721. /**
  83722. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  83723. * The possible values are :
  83724. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  83725. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83726. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  83727. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  83728. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83729. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  83730. * */
  83731. cullingStrategy: number;
  83732. /**
  83733. * @hidden Internal global position in the SPS.
  83734. */
  83735. _globalPosition: Vector3;
  83736. /**
  83737. * Creates a Solid Particle object.
  83738. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  83739. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  83740. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  83741. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  83742. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  83743. * @param shapeId (integer) is the model shape identifier in the SPS.
  83744. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  83745. * @param sps defines the sps it is associated to
  83746. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  83747. */
  83748. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  83749. /**
  83750. * Legacy support, changed scale to scaling
  83751. */
  83752. /**
  83753. * Legacy support, changed scale to scaling
  83754. */
  83755. scale: Vector3;
  83756. /**
  83757. * Legacy support, changed quaternion to rotationQuaternion
  83758. */
  83759. /**
  83760. * Legacy support, changed quaternion to rotationQuaternion
  83761. */
  83762. quaternion: Nullable<Quaternion>;
  83763. /**
  83764. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  83765. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  83766. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  83767. * @returns true if it intersects
  83768. */
  83769. intersectsMesh(target: Mesh | SolidParticle): boolean;
  83770. /**
  83771. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  83772. * A particle is in the frustum if its bounding box intersects the frustum
  83773. * @param frustumPlanes defines the frustum to test
  83774. * @returns true if the particle is in the frustum planes
  83775. */
  83776. isInFrustum(frustumPlanes: Plane[]): boolean;
  83777. /**
  83778. * get the rotation matrix of the particle
  83779. * @hidden
  83780. */
  83781. getRotationMatrix(m: Matrix): void;
  83782. }
  83783. /**
  83784. * Represents the shape of the model used by one particle of a solid particle system.
  83785. * SPS internal tool, don't use it manually.
  83786. */
  83787. export class ModelShape {
  83788. /**
  83789. * The shape id
  83790. * @hidden
  83791. */
  83792. shapeID: number;
  83793. /**
  83794. * flat array of model positions (internal use)
  83795. * @hidden
  83796. */
  83797. _shape: Vector3[];
  83798. /**
  83799. * flat array of model UVs (internal use)
  83800. * @hidden
  83801. */
  83802. _shapeUV: number[];
  83803. /**
  83804. * length of the shape in the model indices array (internal use)
  83805. * @hidden
  83806. */
  83807. _indicesLength: number;
  83808. /**
  83809. * Custom position function (internal use)
  83810. * @hidden
  83811. */
  83812. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  83813. /**
  83814. * Custom vertex function (internal use)
  83815. * @hidden
  83816. */
  83817. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  83818. /**
  83819. * 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.
  83820. * SPS internal tool, don't use it manually.
  83821. * @hidden
  83822. */
  83823. 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>);
  83824. }
  83825. /**
  83826. * Represents a Depth Sorted Particle in the solid particle system.
  83827. */
  83828. export class DepthSortedParticle {
  83829. /**
  83830. * Index of the particle in the "indices" array
  83831. */
  83832. ind: number;
  83833. /**
  83834. * Length of the particle shape in the "indices" array
  83835. */
  83836. indicesLength: number;
  83837. /**
  83838. * Squared distance from the particle to the camera
  83839. */
  83840. sqDistance: number;
  83841. }
  83842. }
  83843. declare module BABYLON {
  83844. /**
  83845. * Class used to store all common mesh properties
  83846. */
  83847. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  83848. /** No occlusion */
  83849. static OCCLUSION_TYPE_NONE: number;
  83850. /** Occlusion set to optimisitic */
  83851. static OCCLUSION_TYPE_OPTIMISTIC: number;
  83852. /** Occlusion set to strict */
  83853. static OCCLUSION_TYPE_STRICT: number;
  83854. /** Use an accurante occlusion algorithm */
  83855. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  83856. /** Use a conservative occlusion algorithm */
  83857. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  83858. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  83859. * Test order :
  83860. * Is the bounding sphere outside the frustum ?
  83861. * If not, are the bounding box vertices outside the frustum ?
  83862. * It not, then the cullable object is in the frustum.
  83863. */
  83864. static readonly CULLINGSTRATEGY_STANDARD: number;
  83865. /** Culling strategy : Bounding Sphere Only.
  83866. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  83867. * It's also less accurate than the standard because some not visible objects can still be selected.
  83868. * Test : is the bounding sphere outside the frustum ?
  83869. * If not, then the cullable object is in the frustum.
  83870. */
  83871. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  83872. /** Culling strategy : Optimistic Inclusion.
  83873. * This in an inclusion test first, then the standard exclusion test.
  83874. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  83875. * 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.
  83876. * Anyway, it's as accurate as the standard strategy.
  83877. * Test :
  83878. * Is the cullable object bounding sphere center in the frustum ?
  83879. * If not, apply the default culling strategy.
  83880. */
  83881. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  83882. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  83883. * This in an inclusion test first, then the bounding sphere only exclusion test.
  83884. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  83885. * 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.
  83886. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  83887. * Test :
  83888. * Is the cullable object bounding sphere center in the frustum ?
  83889. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  83890. */
  83891. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  83892. /**
  83893. * No billboard
  83894. */
  83895. static readonly BILLBOARDMODE_NONE: number;
  83896. /** Billboard on X axis */
  83897. static readonly BILLBOARDMODE_X: number;
  83898. /** Billboard on Y axis */
  83899. static readonly BILLBOARDMODE_Y: number;
  83900. /** Billboard on Z axis */
  83901. static readonly BILLBOARDMODE_Z: number;
  83902. /** Billboard on all axes */
  83903. static readonly BILLBOARDMODE_ALL: number;
  83904. private _facetData;
  83905. /**
  83906. * The culling strategy to use to check whether the mesh must be rendered or not.
  83907. * This value can be changed at any time and will be used on the next render mesh selection.
  83908. * The possible values are :
  83909. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  83910. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83911. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  83912. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  83913. * Please read each static variable documentation to get details about the culling process.
  83914. * */
  83915. cullingStrategy: number;
  83916. /**
  83917. * Gets the number of facets in the mesh
  83918. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  83919. */
  83920. readonly facetNb: number;
  83921. /**
  83922. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  83923. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  83924. */
  83925. partitioningSubdivisions: number;
  83926. /**
  83927. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  83928. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  83929. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  83930. */
  83931. partitioningBBoxRatio: number;
  83932. /**
  83933. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  83934. * Works only for updatable meshes.
  83935. * Doesn't work with multi-materials
  83936. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  83937. */
  83938. mustDepthSortFacets: boolean;
  83939. /**
  83940. * The location (Vector3) where the facet depth sort must be computed from.
  83941. * By default, the active camera position.
  83942. * Used only when facet depth sort is enabled
  83943. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  83944. */
  83945. facetDepthSortFrom: Vector3;
  83946. /**
  83947. * gets a boolean indicating if facetData is enabled
  83948. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  83949. */
  83950. readonly isFacetDataEnabled: boolean;
  83951. /** @hidden */
  83952. _updateNonUniformScalingState(value: boolean): boolean;
  83953. /**
  83954. * An event triggered when this mesh collides with another one
  83955. */
  83956. onCollideObservable: Observable<AbstractMesh>;
  83957. private _onCollideObserver;
  83958. /** Set a function to call when this mesh collides with another one */
  83959. onCollide: () => void;
  83960. /**
  83961. * An event triggered when the collision's position changes
  83962. */
  83963. onCollisionPositionChangeObservable: Observable<Vector3>;
  83964. private _onCollisionPositionChangeObserver;
  83965. /** Set a function to call when the collision's position changes */
  83966. onCollisionPositionChange: () => void;
  83967. /**
  83968. * An event triggered when material is changed
  83969. */
  83970. onMaterialChangedObservable: Observable<AbstractMesh>;
  83971. /**
  83972. * Gets or sets the orientation for POV movement & rotation
  83973. */
  83974. definedFacingForward: boolean;
  83975. /** @hidden */
  83976. _occlusionQuery: Nullable<WebGLQuery>;
  83977. private _visibility;
  83978. /** @hidden */
  83979. _isActive: boolean;
  83980. /** @hidden */
  83981. _onlyForInstances: boolean;
  83982. /** @hidden */
  83983. _renderingGroup: Nullable<RenderingGroup>;
  83984. /**
  83985. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  83986. */
  83987. /**
  83988. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  83989. */
  83990. visibility: number;
  83991. /** Gets or sets the alpha index used to sort transparent meshes
  83992. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  83993. */
  83994. alphaIndex: number;
  83995. /**
  83996. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  83997. */
  83998. isVisible: boolean;
  83999. /**
  84000. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  84001. */
  84002. isPickable: boolean;
  84003. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  84004. showSubMeshesBoundingBox: boolean;
  84005. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  84006. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  84007. */
  84008. isBlocker: boolean;
  84009. /**
  84010. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  84011. */
  84012. enablePointerMoveEvents: boolean;
  84013. /**
  84014. * Specifies the rendering group id for this mesh (0 by default)
  84015. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  84016. */
  84017. renderingGroupId: number;
  84018. private _material;
  84019. /** Gets or sets current material */
  84020. material: Nullable<Material>;
  84021. private _receiveShadows;
  84022. /**
  84023. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  84024. * @see http://doc.babylonjs.com/babylon101/shadows
  84025. */
  84026. receiveShadows: boolean;
  84027. /** Defines color to use when rendering outline */
  84028. outlineColor: Color3;
  84029. /** Define width to use when rendering outline */
  84030. outlineWidth: number;
  84031. /** Defines color to use when rendering overlay */
  84032. overlayColor: Color3;
  84033. /** Defines alpha to use when rendering overlay */
  84034. overlayAlpha: number;
  84035. private _hasVertexAlpha;
  84036. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  84037. hasVertexAlpha: boolean;
  84038. private _useVertexColors;
  84039. /** 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) */
  84040. useVertexColors: boolean;
  84041. private _computeBonesUsingShaders;
  84042. /**
  84043. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  84044. */
  84045. computeBonesUsingShaders: boolean;
  84046. private _numBoneInfluencers;
  84047. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  84048. numBoneInfluencers: number;
  84049. private _applyFog;
  84050. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  84051. applyFog: boolean;
  84052. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  84053. useOctreeForRenderingSelection: boolean;
  84054. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  84055. useOctreeForPicking: boolean;
  84056. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  84057. useOctreeForCollisions: boolean;
  84058. private _layerMask;
  84059. /**
  84060. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  84061. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  84062. */
  84063. layerMask: number;
  84064. /**
  84065. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  84066. */
  84067. alwaysSelectAsActiveMesh: boolean;
  84068. /**
  84069. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  84070. */
  84071. doNotSyncBoundingInfo: boolean;
  84072. /**
  84073. * Gets or sets the current action manager
  84074. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84075. */
  84076. actionManager: Nullable<AbstractActionManager>;
  84077. private _checkCollisions;
  84078. private _collisionMask;
  84079. private _collisionGroup;
  84080. /**
  84081. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  84082. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84083. */
  84084. ellipsoid: Vector3;
  84085. /**
  84086. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  84087. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84088. */
  84089. ellipsoidOffset: Vector3;
  84090. private _collider;
  84091. private _oldPositionForCollisions;
  84092. private _diffPositionForCollisions;
  84093. /**
  84094. * Gets or sets a collision mask used to mask collisions (default is -1).
  84095. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  84096. */
  84097. collisionMask: number;
  84098. /**
  84099. * Gets or sets the current collision group mask (-1 by default).
  84100. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  84101. */
  84102. collisionGroup: number;
  84103. /**
  84104. * Defines edge width used when edgesRenderer is enabled
  84105. * @see https://www.babylonjs-playground.com/#10OJSG#13
  84106. */
  84107. edgesWidth: number;
  84108. /**
  84109. * Defines edge color used when edgesRenderer is enabled
  84110. * @see https://www.babylonjs-playground.com/#10OJSG#13
  84111. */
  84112. edgesColor: Color4;
  84113. /** @hidden */
  84114. _edgesRenderer: Nullable<IEdgesRenderer>;
  84115. /** @hidden */
  84116. _masterMesh: Nullable<AbstractMesh>;
  84117. /** @hidden */
  84118. _boundingInfo: Nullable<BoundingInfo>;
  84119. /** @hidden */
  84120. _renderId: number;
  84121. /**
  84122. * Gets or sets the list of subMeshes
  84123. * @see http://doc.babylonjs.com/how_to/multi_materials
  84124. */
  84125. subMeshes: SubMesh[];
  84126. /** @hidden */
  84127. _intersectionsInProgress: AbstractMesh[];
  84128. /** @hidden */
  84129. _unIndexed: boolean;
  84130. /** @hidden */
  84131. _lightSources: Light[];
  84132. /** @hidden */
  84133. readonly _positions: Nullable<Vector3[]>;
  84134. /** @hidden */
  84135. _waitingActions: Nullable<any>;
  84136. /** @hidden */
  84137. _waitingFreezeWorldMatrix: Nullable<boolean>;
  84138. private _skeleton;
  84139. /** @hidden */
  84140. _bonesTransformMatrices: Nullable<Float32Array>;
  84141. /**
  84142. * Gets or sets a skeleton to apply skining transformations
  84143. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84144. */
  84145. skeleton: Nullable<Skeleton>;
  84146. /**
  84147. * An event triggered when the mesh is rebuilt.
  84148. */
  84149. onRebuildObservable: Observable<AbstractMesh>;
  84150. /**
  84151. * Creates a new AbstractMesh
  84152. * @param name defines the name of the mesh
  84153. * @param scene defines the hosting scene
  84154. */
  84155. constructor(name: string, scene?: Nullable<Scene>);
  84156. /**
  84157. * Returns the string "AbstractMesh"
  84158. * @returns "AbstractMesh"
  84159. */
  84160. getClassName(): string;
  84161. /**
  84162. * Gets a string representation of the current mesh
  84163. * @param fullDetails defines a boolean indicating if full details must be included
  84164. * @returns a string representation of the current mesh
  84165. */
  84166. toString(fullDetails?: boolean): string;
  84167. /**
  84168. * @hidden
  84169. */
  84170. protected _getEffectiveParent(): Nullable<Node>;
  84171. /** @hidden */
  84172. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  84173. /** @hidden */
  84174. _rebuild(): void;
  84175. /** @hidden */
  84176. _resyncLightSources(): void;
  84177. /** @hidden */
  84178. _resyncLighSource(light: Light): void;
  84179. /** @hidden */
  84180. _unBindEffect(): void;
  84181. /** @hidden */
  84182. _removeLightSource(light: Light): void;
  84183. private _markSubMeshesAsDirty;
  84184. /** @hidden */
  84185. _markSubMeshesAsLightDirty(): void;
  84186. /** @hidden */
  84187. _markSubMeshesAsAttributesDirty(): void;
  84188. /** @hidden */
  84189. _markSubMeshesAsMiscDirty(): void;
  84190. /**
  84191. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  84192. */
  84193. scaling: Vector3;
  84194. /**
  84195. * Returns true if the mesh is blocked. Implemented by child classes
  84196. */
  84197. readonly isBlocked: boolean;
  84198. /**
  84199. * Returns the mesh itself by default. Implemented by child classes
  84200. * @param camera defines the camera to use to pick the right LOD level
  84201. * @returns the currentAbstractMesh
  84202. */
  84203. getLOD(camera: Camera): Nullable<AbstractMesh>;
  84204. /**
  84205. * Returns 0 by default. Implemented by child classes
  84206. * @returns an integer
  84207. */
  84208. getTotalVertices(): number;
  84209. /**
  84210. * Returns a positive integer : the total number of indices in this mesh geometry.
  84211. * @returns the numner of indices or zero if the mesh has no geometry.
  84212. */
  84213. getTotalIndices(): number;
  84214. /**
  84215. * Returns null by default. Implemented by child classes
  84216. * @returns null
  84217. */
  84218. getIndices(): Nullable<IndicesArray>;
  84219. /**
  84220. * Returns the array of the requested vertex data kind. Implemented by child classes
  84221. * @param kind defines the vertex data kind to use
  84222. * @returns null
  84223. */
  84224. getVerticesData(kind: string): Nullable<FloatArray>;
  84225. /**
  84226. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84227. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84228. * Note that a new underlying VertexBuffer object is created each call.
  84229. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84230. * @param kind defines vertex data kind:
  84231. * * VertexBuffer.PositionKind
  84232. * * VertexBuffer.UVKind
  84233. * * VertexBuffer.UV2Kind
  84234. * * VertexBuffer.UV3Kind
  84235. * * VertexBuffer.UV4Kind
  84236. * * VertexBuffer.UV5Kind
  84237. * * VertexBuffer.UV6Kind
  84238. * * VertexBuffer.ColorKind
  84239. * * VertexBuffer.MatricesIndicesKind
  84240. * * VertexBuffer.MatricesIndicesExtraKind
  84241. * * VertexBuffer.MatricesWeightsKind
  84242. * * VertexBuffer.MatricesWeightsExtraKind
  84243. * @param data defines the data source
  84244. * @param updatable defines if the data must be flagged as updatable (or static)
  84245. * @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
  84246. * @returns the current mesh
  84247. */
  84248. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  84249. /**
  84250. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84251. * If the mesh has no geometry, it is simply returned as it is.
  84252. * @param kind defines vertex data kind:
  84253. * * VertexBuffer.PositionKind
  84254. * * VertexBuffer.UVKind
  84255. * * VertexBuffer.UV2Kind
  84256. * * VertexBuffer.UV3Kind
  84257. * * VertexBuffer.UV4Kind
  84258. * * VertexBuffer.UV5Kind
  84259. * * VertexBuffer.UV6Kind
  84260. * * VertexBuffer.ColorKind
  84261. * * VertexBuffer.MatricesIndicesKind
  84262. * * VertexBuffer.MatricesIndicesExtraKind
  84263. * * VertexBuffer.MatricesWeightsKind
  84264. * * VertexBuffer.MatricesWeightsExtraKind
  84265. * @param data defines the data source
  84266. * @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
  84267. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  84268. * @returns the current mesh
  84269. */
  84270. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  84271. /**
  84272. * Sets the mesh indices,
  84273. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  84274. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  84275. * @param totalVertices Defines the total number of vertices
  84276. * @returns the current mesh
  84277. */
  84278. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  84279. /**
  84280. * Gets a boolean indicating if specific vertex data is present
  84281. * @param kind defines the vertex data kind to use
  84282. * @returns true is data kind is present
  84283. */
  84284. isVerticesDataPresent(kind: string): boolean;
  84285. /**
  84286. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  84287. * @returns a BoundingInfo
  84288. */
  84289. getBoundingInfo(): BoundingInfo;
  84290. /**
  84291. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  84292. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  84293. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  84294. * @returns the current mesh
  84295. */
  84296. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  84297. /**
  84298. * Overwrite the current bounding info
  84299. * @param boundingInfo defines the new bounding info
  84300. * @returns the current mesh
  84301. */
  84302. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  84303. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  84304. readonly useBones: boolean;
  84305. /** @hidden */
  84306. _preActivate(): void;
  84307. /** @hidden */
  84308. _preActivateForIntermediateRendering(renderId: number): void;
  84309. /** @hidden */
  84310. _activate(renderId: number): boolean;
  84311. /** @hidden */
  84312. _freeze(): void;
  84313. /** @hidden */
  84314. _unFreeze(): void;
  84315. /**
  84316. * Gets the current world matrix
  84317. * @returns a Matrix
  84318. */
  84319. getWorldMatrix(): Matrix;
  84320. /** @hidden */
  84321. _getWorldMatrixDeterminant(): number;
  84322. /**
  84323. * Perform relative position change from the point of view of behind the front of the mesh.
  84324. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84325. * Supports definition of mesh facing forward or backward
  84326. * @param amountRight defines the distance on the right axis
  84327. * @param amountUp defines the distance on the up axis
  84328. * @param amountForward defines the distance on the forward axis
  84329. * @returns the current mesh
  84330. */
  84331. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  84332. /**
  84333. * Calculate relative position change from the point of view of behind the front of the mesh.
  84334. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84335. * Supports definition of mesh facing forward or backward
  84336. * @param amountRight defines the distance on the right axis
  84337. * @param amountUp defines the distance on the up axis
  84338. * @param amountForward defines the distance on the forward axis
  84339. * @returns the new displacement vector
  84340. */
  84341. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  84342. /**
  84343. * Perform relative rotation change from the point of view of behind the front of the mesh.
  84344. * Supports definition of mesh facing forward or backward
  84345. * @param flipBack defines the flip
  84346. * @param twirlClockwise defines the twirl
  84347. * @param tiltRight defines the tilt
  84348. * @returns the current mesh
  84349. */
  84350. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  84351. /**
  84352. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  84353. * Supports definition of mesh facing forward or backward.
  84354. * @param flipBack defines the flip
  84355. * @param twirlClockwise defines the twirl
  84356. * @param tiltRight defines the tilt
  84357. * @returns the new rotation vector
  84358. */
  84359. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  84360. /**
  84361. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84362. * This means the mesh underlying bounding box and sphere are recomputed.
  84363. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84364. * @returns the current mesh
  84365. */
  84366. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  84367. /** @hidden */
  84368. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  84369. /** @hidden */
  84370. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  84371. /** @hidden */
  84372. _updateBoundingInfo(): AbstractMesh;
  84373. /** @hidden */
  84374. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  84375. /** @hidden */
  84376. protected _afterComputeWorldMatrix(): void;
  84377. /** @hidden */
  84378. readonly _effectiveMesh: AbstractMesh;
  84379. /**
  84380. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  84381. * A mesh is in the frustum if its bounding box intersects the frustum
  84382. * @param frustumPlanes defines the frustum to test
  84383. * @returns true if the mesh is in the frustum planes
  84384. */
  84385. isInFrustum(frustumPlanes: Plane[]): boolean;
  84386. /**
  84387. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  84388. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  84389. * @param frustumPlanes defines the frustum to test
  84390. * @returns true if the mesh is completely in the frustum planes
  84391. */
  84392. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84393. /**
  84394. * True if the mesh intersects another mesh or a SolidParticle object
  84395. * @param mesh defines a target mesh or SolidParticle to test
  84396. * @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)
  84397. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  84398. * @returns true if there is an intersection
  84399. */
  84400. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  84401. /**
  84402. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  84403. * @param point defines the point to test
  84404. * @returns true if there is an intersection
  84405. */
  84406. intersectsPoint(point: Vector3): boolean;
  84407. /**
  84408. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  84409. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84410. */
  84411. checkCollisions: boolean;
  84412. /**
  84413. * Gets Collider object used to compute collisions (not physics)
  84414. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84415. */
  84416. readonly collider: Nullable<Collider>;
  84417. /**
  84418. * Move the mesh using collision engine
  84419. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84420. * @param displacement defines the requested displacement vector
  84421. * @returns the current mesh
  84422. */
  84423. moveWithCollisions(displacement: Vector3): AbstractMesh;
  84424. private _onCollisionPositionChange;
  84425. /** @hidden */
  84426. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  84427. /** @hidden */
  84428. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  84429. /** @hidden */
  84430. _checkCollision(collider: Collider): AbstractMesh;
  84431. /** @hidden */
  84432. _generatePointsArray(): boolean;
  84433. /**
  84434. * Checks if the passed Ray intersects with the mesh
  84435. * @param ray defines the ray to use
  84436. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  84437. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  84438. * @returns the picking info
  84439. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84440. */
  84441. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  84442. /**
  84443. * Clones the current mesh
  84444. * @param name defines the mesh name
  84445. * @param newParent defines the new mesh parent
  84446. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  84447. * @returns the new mesh
  84448. */
  84449. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84450. /**
  84451. * Disposes all the submeshes of the current meshnp
  84452. * @returns the current mesh
  84453. */
  84454. releaseSubMeshes(): AbstractMesh;
  84455. /**
  84456. * Releases resources associated with this abstract mesh.
  84457. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  84458. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  84459. */
  84460. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84461. /**
  84462. * Adds the passed mesh as a child to the current mesh
  84463. * @param mesh defines the child mesh
  84464. * @returns the current mesh
  84465. */
  84466. addChild(mesh: AbstractMesh): AbstractMesh;
  84467. /**
  84468. * Removes the passed mesh from the current mesh children list
  84469. * @param mesh defines the child mesh
  84470. * @returns the current mesh
  84471. */
  84472. removeChild(mesh: AbstractMesh): AbstractMesh;
  84473. /** @hidden */
  84474. private _initFacetData;
  84475. /**
  84476. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  84477. * This method can be called within the render loop.
  84478. * 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
  84479. * @returns the current mesh
  84480. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84481. */
  84482. updateFacetData(): AbstractMesh;
  84483. /**
  84484. * Returns the facetLocalNormals array.
  84485. * The normals are expressed in the mesh local spac
  84486. * @returns an array of Vector3
  84487. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84488. */
  84489. getFacetLocalNormals(): Vector3[];
  84490. /**
  84491. * Returns the facetLocalPositions array.
  84492. * The facet positions are expressed in the mesh local space
  84493. * @returns an array of Vector3
  84494. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84495. */
  84496. getFacetLocalPositions(): Vector3[];
  84497. /**
  84498. * Returns the facetLocalPartioning array
  84499. * @returns an array of array of numbers
  84500. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84501. */
  84502. getFacetLocalPartitioning(): number[][];
  84503. /**
  84504. * Returns the i-th facet position in the world system.
  84505. * This method allocates a new Vector3 per call
  84506. * @param i defines the facet index
  84507. * @returns a new Vector3
  84508. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84509. */
  84510. getFacetPosition(i: number): Vector3;
  84511. /**
  84512. * Sets the reference Vector3 with the i-th facet position in the world system
  84513. * @param i defines the facet index
  84514. * @param ref defines the target vector
  84515. * @returns the current mesh
  84516. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84517. */
  84518. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  84519. /**
  84520. * Returns the i-th facet normal in the world system.
  84521. * This method allocates a new Vector3 per call
  84522. * @param i defines the facet index
  84523. * @returns a new Vector3
  84524. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84525. */
  84526. getFacetNormal(i: number): Vector3;
  84527. /**
  84528. * Sets the reference Vector3 with the i-th facet normal in the world system
  84529. * @param i defines the facet index
  84530. * @param ref defines the target vector
  84531. * @returns the current mesh
  84532. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84533. */
  84534. getFacetNormalToRef(i: number, ref: Vector3): this;
  84535. /**
  84536. * 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)
  84537. * @param x defines x coordinate
  84538. * @param y defines y coordinate
  84539. * @param z defines z coordinate
  84540. * @returns the array of facet indexes
  84541. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84542. */
  84543. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  84544. /**
  84545. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  84546. * @param projected sets as the (x,y,z) world projection on the facet
  84547. * @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
  84548. * @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
  84549. * @param x defines x coordinate
  84550. * @param y defines y coordinate
  84551. * @param z defines z coordinate
  84552. * @returns the face index if found (or null instead)
  84553. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84554. */
  84555. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  84556. /**
  84557. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  84558. * @param projected sets as the (x,y,z) local projection on the facet
  84559. * @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
  84560. * @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
  84561. * @param x defines x coordinate
  84562. * @param y defines y coordinate
  84563. * @param z defines z coordinate
  84564. * @returns the face index if found (or null instead)
  84565. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84566. */
  84567. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  84568. /**
  84569. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  84570. * @returns the parameters
  84571. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84572. */
  84573. getFacetDataParameters(): any;
  84574. /**
  84575. * Disables the feature FacetData and frees the related memory
  84576. * @returns the current mesh
  84577. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84578. */
  84579. disableFacetData(): AbstractMesh;
  84580. /**
  84581. * Updates the AbstractMesh indices array
  84582. * @param indices defines the data source
  84583. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  84584. * @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)
  84585. * @returns the current mesh
  84586. */
  84587. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  84588. /**
  84589. * Creates new normals data for the mesh
  84590. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  84591. * @returns the current mesh
  84592. */
  84593. createNormals(updatable: boolean): AbstractMesh;
  84594. /**
  84595. * Align the mesh with a normal
  84596. * @param normal defines the normal to use
  84597. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  84598. * @returns the current mesh
  84599. */
  84600. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  84601. /** @hidden */
  84602. _checkOcclusionQuery(): boolean;
  84603. }
  84604. }
  84605. declare module BABYLON {
  84606. /**
  84607. * Interface used to define ActionEvent
  84608. */
  84609. export interface IActionEvent {
  84610. /** The mesh or sprite that triggered the action */
  84611. source: any;
  84612. /** The X mouse cursor position at the time of the event */
  84613. pointerX: number;
  84614. /** The Y mouse cursor position at the time of the event */
  84615. pointerY: number;
  84616. /** The mesh that is currently pointed at (can be null) */
  84617. meshUnderPointer: Nullable<AbstractMesh>;
  84618. /** the original (browser) event that triggered the ActionEvent */
  84619. sourceEvent?: any;
  84620. /** additional data for the event */
  84621. additionalData?: any;
  84622. }
  84623. /**
  84624. * ActionEvent is the event being sent when an action is triggered.
  84625. */
  84626. export class ActionEvent implements IActionEvent {
  84627. /** The mesh or sprite that triggered the action */
  84628. source: any;
  84629. /** The X mouse cursor position at the time of the event */
  84630. pointerX: number;
  84631. /** The Y mouse cursor position at the time of the event */
  84632. pointerY: number;
  84633. /** The mesh that is currently pointed at (can be null) */
  84634. meshUnderPointer: Nullable<AbstractMesh>;
  84635. /** the original (browser) event that triggered the ActionEvent */
  84636. sourceEvent?: any;
  84637. /** additional data for the event */
  84638. additionalData?: any;
  84639. /**
  84640. * Creates a new ActionEvent
  84641. * @param source The mesh or sprite that triggered the action
  84642. * @param pointerX The X mouse cursor position at the time of the event
  84643. * @param pointerY The Y mouse cursor position at the time of the event
  84644. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  84645. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  84646. * @param additionalData additional data for the event
  84647. */
  84648. constructor(
  84649. /** The mesh or sprite that triggered the action */
  84650. source: any,
  84651. /** The X mouse cursor position at the time of the event */
  84652. pointerX: number,
  84653. /** The Y mouse cursor position at the time of the event */
  84654. pointerY: number,
  84655. /** The mesh that is currently pointed at (can be null) */
  84656. meshUnderPointer: Nullable<AbstractMesh>,
  84657. /** the original (browser) event that triggered the ActionEvent */
  84658. sourceEvent?: any,
  84659. /** additional data for the event */
  84660. additionalData?: any);
  84661. /**
  84662. * Helper function to auto-create an ActionEvent from a source mesh.
  84663. * @param source The source mesh that triggered the event
  84664. * @param evt The original (browser) event
  84665. * @param additionalData additional data for the event
  84666. * @returns the new ActionEvent
  84667. */
  84668. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  84669. /**
  84670. * Helper function to auto-create an ActionEvent from a source sprite
  84671. * @param source The source sprite that triggered the event
  84672. * @param scene Scene associated with the sprite
  84673. * @param evt The original (browser) event
  84674. * @param additionalData additional data for the event
  84675. * @returns the new ActionEvent
  84676. */
  84677. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  84678. /**
  84679. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  84680. * @param scene the scene where the event occurred
  84681. * @param evt The original (browser) event
  84682. * @returns the new ActionEvent
  84683. */
  84684. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  84685. /**
  84686. * Helper function to auto-create an ActionEvent from a primitive
  84687. * @param prim defines the target primitive
  84688. * @param pointerPos defines the pointer position
  84689. * @param evt The original (browser) event
  84690. * @param additionalData additional data for the event
  84691. * @returns the new ActionEvent
  84692. */
  84693. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  84694. }
  84695. }
  84696. declare module BABYLON {
  84697. /**
  84698. * Abstract class used to decouple action Manager from scene and meshes.
  84699. * Do not instantiate.
  84700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84701. */
  84702. export abstract class AbstractActionManager implements IDisposable {
  84703. /** Gets the list of active triggers */
  84704. static Triggers: {
  84705. [key: string]: number;
  84706. };
  84707. /** Gets the cursor to use when hovering items */
  84708. hoverCursor: string;
  84709. /** Gets the list of actions */
  84710. actions: IAction[];
  84711. /**
  84712. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  84713. */
  84714. isRecursive: boolean;
  84715. /**
  84716. * Releases all associated resources
  84717. */
  84718. abstract dispose(): void;
  84719. /**
  84720. * Does this action manager has pointer triggers
  84721. */
  84722. abstract readonly hasPointerTriggers: boolean;
  84723. /**
  84724. * Does this action manager has pick triggers
  84725. */
  84726. abstract readonly hasPickTriggers: boolean;
  84727. /**
  84728. * Process a specific trigger
  84729. * @param trigger defines the trigger to process
  84730. * @param evt defines the event details to be processed
  84731. */
  84732. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  84733. /**
  84734. * Does this action manager handles actions of any of the given triggers
  84735. * @param triggers defines the triggers to be tested
  84736. * @return a boolean indicating whether one (or more) of the triggers is handled
  84737. */
  84738. abstract hasSpecificTriggers(triggers: number[]): boolean;
  84739. /**
  84740. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  84741. * speed.
  84742. * @param triggerA defines the trigger to be tested
  84743. * @param triggerB defines the trigger to be tested
  84744. * @return a boolean indicating whether one (or more) of the triggers is handled
  84745. */
  84746. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  84747. /**
  84748. * Does this action manager handles actions of a given trigger
  84749. * @param trigger defines the trigger to be tested
  84750. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  84751. * @return whether the trigger is handled
  84752. */
  84753. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  84754. /**
  84755. * Serialize this manager to a JSON object
  84756. * @param name defines the property name to store this manager
  84757. * @returns a JSON representation of this manager
  84758. */
  84759. abstract serialize(name: string): any;
  84760. /**
  84761. * Registers an action to this action manager
  84762. * @param action defines the action to be registered
  84763. * @return the action amended (prepared) after registration
  84764. */
  84765. abstract registerAction(action: IAction): Nullable<IAction>;
  84766. /**
  84767. * Unregisters an action to this action manager
  84768. * @param action defines the action to be unregistered
  84769. * @return a boolean indicating whether the action has been unregistered
  84770. */
  84771. abstract unregisterAction(action: IAction): Boolean;
  84772. /**
  84773. * Does exist one action manager with at least one trigger
  84774. **/
  84775. static readonly HasTriggers: boolean;
  84776. /**
  84777. * Does exist one action manager with at least one pick trigger
  84778. **/
  84779. static readonly HasPickTriggers: boolean;
  84780. /**
  84781. * Does exist one action manager that handles actions of a given trigger
  84782. * @param trigger defines the trigger to be tested
  84783. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  84784. **/
  84785. static HasSpecificTrigger(trigger: number): boolean;
  84786. }
  84787. }
  84788. declare module BABYLON {
  84789. /**
  84790. * Defines how a node can be built from a string name.
  84791. */
  84792. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  84793. /**
  84794. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  84795. */
  84796. export class Node implements IBehaviorAware<Node> {
  84797. /** @hidden */
  84798. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  84799. private static _NodeConstructors;
  84800. /**
  84801. * Add a new node constructor
  84802. * @param type defines the type name of the node to construct
  84803. * @param constructorFunc defines the constructor function
  84804. */
  84805. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  84806. /**
  84807. * Returns a node constructor based on type name
  84808. * @param type defines the type name
  84809. * @param name defines the new node name
  84810. * @param scene defines the hosting scene
  84811. * @param options defines optional options to transmit to constructors
  84812. * @returns the new constructor or null
  84813. */
  84814. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  84815. /**
  84816. * Gets or sets the name of the node
  84817. */
  84818. name: string;
  84819. /**
  84820. * Gets or sets the id of the node
  84821. */
  84822. id: string;
  84823. /**
  84824. * Gets or sets the unique id of the node
  84825. */
  84826. uniqueId: number;
  84827. /**
  84828. * Gets or sets a string used to store user defined state for the node
  84829. */
  84830. state: string;
  84831. /**
  84832. * Gets or sets an object used to store user defined information for the node
  84833. */
  84834. metadata: any;
  84835. /**
  84836. * For internal use only. Please do not use.
  84837. */
  84838. reservedDataStore: any;
  84839. /**
  84840. * List of inspectable custom properties (used by the Inspector)
  84841. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84842. */
  84843. inspectableCustomProperties: IInspectable[];
  84844. /**
  84845. * Gets or sets a boolean used to define if the node must be serialized
  84846. */
  84847. doNotSerialize: boolean;
  84848. /** @hidden */
  84849. _isDisposed: boolean;
  84850. /**
  84851. * Gets a list of Animations associated with the node
  84852. */
  84853. animations: Animation[];
  84854. protected _ranges: {
  84855. [name: string]: Nullable<AnimationRange>;
  84856. };
  84857. /**
  84858. * Callback raised when the node is ready to be used
  84859. */
  84860. onReady: Nullable<(node: Node) => void>;
  84861. private _isEnabled;
  84862. private _isParentEnabled;
  84863. private _isReady;
  84864. /** @hidden */
  84865. _currentRenderId: number;
  84866. private _parentUpdateId;
  84867. /** @hidden */
  84868. _childUpdateId: number;
  84869. /** @hidden */
  84870. _waitingParentId: Nullable<string>;
  84871. /** @hidden */
  84872. _scene: Scene;
  84873. /** @hidden */
  84874. _cache: any;
  84875. private _parentNode;
  84876. private _children;
  84877. /** @hidden */
  84878. _worldMatrix: Matrix;
  84879. /** @hidden */
  84880. _worldMatrixDeterminant: number;
  84881. /** @hidden */
  84882. _worldMatrixDeterminantIsDirty: boolean;
  84883. /** @hidden */
  84884. private _sceneRootNodesIndex;
  84885. /**
  84886. * Gets a boolean indicating if the node has been disposed
  84887. * @returns true if the node was disposed
  84888. */
  84889. isDisposed(): boolean;
  84890. /**
  84891. * Gets or sets the parent of the node (without keeping the current position in the scene)
  84892. * @see https://doc.babylonjs.com/how_to/parenting
  84893. */
  84894. parent: Nullable<Node>;
  84895. private addToSceneRootNodes;
  84896. private removeFromSceneRootNodes;
  84897. private _animationPropertiesOverride;
  84898. /**
  84899. * Gets or sets the animation properties override
  84900. */
  84901. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  84902. /**
  84903. * Gets a string idenfifying the name of the class
  84904. * @returns "Node" string
  84905. */
  84906. getClassName(): string;
  84907. /** @hidden */
  84908. readonly _isNode: boolean;
  84909. /**
  84910. * An event triggered when the mesh is disposed
  84911. */
  84912. onDisposeObservable: Observable<Node>;
  84913. private _onDisposeObserver;
  84914. /**
  84915. * Sets a callback that will be raised when the node will be disposed
  84916. */
  84917. onDispose: () => void;
  84918. /**
  84919. * Creates a new Node
  84920. * @param name the name and id to be given to this node
  84921. * @param scene the scene this node will be added to
  84922. * @param addToRootNodes the node will be added to scene.rootNodes
  84923. */
  84924. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  84925. /**
  84926. * Gets the scene of the node
  84927. * @returns a scene
  84928. */
  84929. getScene(): Scene;
  84930. /**
  84931. * Gets the engine of the node
  84932. * @returns a Engine
  84933. */
  84934. getEngine(): Engine;
  84935. private _behaviors;
  84936. /**
  84937. * Attach a behavior to the node
  84938. * @see http://doc.babylonjs.com/features/behaviour
  84939. * @param behavior defines the behavior to attach
  84940. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  84941. * @returns the current Node
  84942. */
  84943. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  84944. /**
  84945. * Remove an attached behavior
  84946. * @see http://doc.babylonjs.com/features/behaviour
  84947. * @param behavior defines the behavior to attach
  84948. * @returns the current Node
  84949. */
  84950. removeBehavior(behavior: Behavior<Node>): Node;
  84951. /**
  84952. * Gets the list of attached behaviors
  84953. * @see http://doc.babylonjs.com/features/behaviour
  84954. */
  84955. readonly behaviors: Behavior<Node>[];
  84956. /**
  84957. * Gets an attached behavior by name
  84958. * @param name defines the name of the behavior to look for
  84959. * @see http://doc.babylonjs.com/features/behaviour
  84960. * @returns null if behavior was not found else the requested behavior
  84961. */
  84962. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  84963. /**
  84964. * Returns the latest update of the World matrix
  84965. * @returns a Matrix
  84966. */
  84967. getWorldMatrix(): Matrix;
  84968. /** @hidden */
  84969. _getWorldMatrixDeterminant(): number;
  84970. /**
  84971. * Returns directly the latest state of the mesh World matrix.
  84972. * A Matrix is returned.
  84973. */
  84974. readonly worldMatrixFromCache: Matrix;
  84975. /** @hidden */
  84976. _initCache(): void;
  84977. /** @hidden */
  84978. updateCache(force?: boolean): void;
  84979. /** @hidden */
  84980. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  84981. /** @hidden */
  84982. _updateCache(ignoreParentClass?: boolean): void;
  84983. /** @hidden */
  84984. _isSynchronized(): boolean;
  84985. /** @hidden */
  84986. _markSyncedWithParent(): void;
  84987. /** @hidden */
  84988. isSynchronizedWithParent(): boolean;
  84989. /** @hidden */
  84990. isSynchronized(): boolean;
  84991. /**
  84992. * Is this node ready to be used/rendered
  84993. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84994. * @return true if the node is ready
  84995. */
  84996. isReady(completeCheck?: boolean): boolean;
  84997. /**
  84998. * Is this node enabled?
  84999. * 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
  85000. * @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
  85001. * @return whether this node (and its parent) is enabled
  85002. */
  85003. isEnabled(checkAncestors?: boolean): boolean;
  85004. /** @hidden */
  85005. protected _syncParentEnabledState(): void;
  85006. /**
  85007. * Set the enabled state of this node
  85008. * @param value defines the new enabled state
  85009. */
  85010. setEnabled(value: boolean): void;
  85011. /**
  85012. * Is this node a descendant of the given node?
  85013. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  85014. * @param ancestor defines the parent node to inspect
  85015. * @returns a boolean indicating if this node is a descendant of the given node
  85016. */
  85017. isDescendantOf(ancestor: Node): boolean;
  85018. /** @hidden */
  85019. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  85020. /**
  85021. * Will return all nodes that have this node as ascendant
  85022. * @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
  85023. * @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
  85024. * @return all children nodes of all types
  85025. */
  85026. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  85027. /**
  85028. * Get all child-meshes of this node
  85029. * @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)
  85030. * @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
  85031. * @returns an array of AbstractMesh
  85032. */
  85033. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  85034. /**
  85035. * Get all direct children of this node
  85036. * @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
  85037. * @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)
  85038. * @returns an array of Node
  85039. */
  85040. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  85041. /** @hidden */
  85042. _setReady(state: boolean): void;
  85043. /**
  85044. * Get an animation by name
  85045. * @param name defines the name of the animation to look for
  85046. * @returns null if not found else the requested animation
  85047. */
  85048. getAnimationByName(name: string): Nullable<Animation>;
  85049. /**
  85050. * Creates an animation range for this node
  85051. * @param name defines the name of the range
  85052. * @param from defines the starting key
  85053. * @param to defines the end key
  85054. */
  85055. createAnimationRange(name: string, from: number, to: number): void;
  85056. /**
  85057. * Delete a specific animation range
  85058. * @param name defines the name of the range to delete
  85059. * @param deleteFrames defines if animation frames from the range must be deleted as well
  85060. */
  85061. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  85062. /**
  85063. * Get an animation range by name
  85064. * @param name defines the name of the animation range to look for
  85065. * @returns null if not found else the requested animation range
  85066. */
  85067. getAnimationRange(name: string): Nullable<AnimationRange>;
  85068. /**
  85069. * Gets the list of all animation ranges defined on this node
  85070. * @returns an array
  85071. */
  85072. getAnimationRanges(): Nullable<AnimationRange>[];
  85073. /**
  85074. * Will start the animation sequence
  85075. * @param name defines the range frames for animation sequence
  85076. * @param loop defines if the animation should loop (false by default)
  85077. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  85078. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  85079. * @returns the object created for this animation. If range does not exist, it will return null
  85080. */
  85081. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  85082. /**
  85083. * Serialize animation ranges into a JSON compatible object
  85084. * @returns serialization object
  85085. */
  85086. serializeAnimationRanges(): any;
  85087. /**
  85088. * Computes the world matrix of the node
  85089. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85090. * @returns the world matrix
  85091. */
  85092. computeWorldMatrix(force?: boolean): Matrix;
  85093. /**
  85094. * Releases resources associated with this node.
  85095. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85096. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85097. */
  85098. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85099. /**
  85100. * Parse animation range data from a serialization object and store them into a given node
  85101. * @param node defines where to store the animation ranges
  85102. * @param parsedNode defines the serialization object to read data from
  85103. * @param scene defines the hosting scene
  85104. */
  85105. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  85106. /**
  85107. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  85108. * @param includeDescendants Include bounding info from descendants as well (true by default)
  85109. * @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
  85110. * @returns the new bounding vectors
  85111. */
  85112. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  85113. min: Vector3;
  85114. max: Vector3;
  85115. };
  85116. }
  85117. }
  85118. declare module BABYLON {
  85119. /**
  85120. * @hidden
  85121. */
  85122. export class _IAnimationState {
  85123. key: number;
  85124. repeatCount: number;
  85125. workValue?: any;
  85126. loopMode?: number;
  85127. offsetValue?: any;
  85128. highLimitValue?: any;
  85129. }
  85130. /**
  85131. * Class used to store any kind of animation
  85132. */
  85133. export class Animation {
  85134. /**Name of the animation */
  85135. name: string;
  85136. /**Property to animate */
  85137. targetProperty: string;
  85138. /**The frames per second of the animation */
  85139. framePerSecond: number;
  85140. /**The data type of the animation */
  85141. dataType: number;
  85142. /**The loop mode of the animation */
  85143. loopMode?: number | undefined;
  85144. /**Specifies if blending should be enabled */
  85145. enableBlending?: boolean | undefined;
  85146. /**
  85147. * Use matrix interpolation instead of using direct key value when animating matrices
  85148. */
  85149. static AllowMatricesInterpolation: boolean;
  85150. /**
  85151. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  85152. */
  85153. static AllowMatrixDecomposeForInterpolation: boolean;
  85154. /**
  85155. * Stores the key frames of the animation
  85156. */
  85157. private _keys;
  85158. /**
  85159. * Stores the easing function of the animation
  85160. */
  85161. private _easingFunction;
  85162. /**
  85163. * @hidden Internal use only
  85164. */
  85165. _runtimeAnimations: RuntimeAnimation[];
  85166. /**
  85167. * The set of event that will be linked to this animation
  85168. */
  85169. private _events;
  85170. /**
  85171. * Stores an array of target property paths
  85172. */
  85173. targetPropertyPath: string[];
  85174. /**
  85175. * Stores the blending speed of the animation
  85176. */
  85177. blendingSpeed: number;
  85178. /**
  85179. * Stores the animation ranges for the animation
  85180. */
  85181. private _ranges;
  85182. /**
  85183. * @hidden Internal use
  85184. */
  85185. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  85186. /**
  85187. * Sets up an animation
  85188. * @param property The property to animate
  85189. * @param animationType The animation type to apply
  85190. * @param framePerSecond The frames per second of the animation
  85191. * @param easingFunction The easing function used in the animation
  85192. * @returns The created animation
  85193. */
  85194. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  85195. /**
  85196. * Create and start an animation on a node
  85197. * @param name defines the name of the global animation that will be run on all nodes
  85198. * @param node defines the root node where the animation will take place
  85199. * @param targetProperty defines property to animate
  85200. * @param framePerSecond defines the number of frame per second yo use
  85201. * @param totalFrame defines the number of frames in total
  85202. * @param from defines the initial value
  85203. * @param to defines the final value
  85204. * @param loopMode defines which loop mode you want to use (off by default)
  85205. * @param easingFunction defines the easing function to use (linear by default)
  85206. * @param onAnimationEnd defines the callback to call when animation end
  85207. * @returns the animatable created for this animation
  85208. */
  85209. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  85210. /**
  85211. * Create and start an animation on a node and its descendants
  85212. * @param name defines the name of the global animation that will be run on all nodes
  85213. * @param node defines the root node where the animation will take place
  85214. * @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
  85215. * @param targetProperty defines property to animate
  85216. * @param framePerSecond defines the number of frame per second to use
  85217. * @param totalFrame defines the number of frames in total
  85218. * @param from defines the initial value
  85219. * @param to defines the final value
  85220. * @param loopMode defines which loop mode you want to use (off by default)
  85221. * @param easingFunction defines the easing function to use (linear by default)
  85222. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  85223. * @returns the list of animatables created for all nodes
  85224. * @example https://www.babylonjs-playground.com/#MH0VLI
  85225. */
  85226. 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[]>;
  85227. /**
  85228. * Creates a new animation, merges it with the existing animations and starts it
  85229. * @param name Name of the animation
  85230. * @param node Node which contains the scene that begins the animations
  85231. * @param targetProperty Specifies which property to animate
  85232. * @param framePerSecond The frames per second of the animation
  85233. * @param totalFrame The total number of frames
  85234. * @param from The frame at the beginning of the animation
  85235. * @param to The frame at the end of the animation
  85236. * @param loopMode Specifies the loop mode of the animation
  85237. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  85238. * @param onAnimationEnd Callback to run once the animation is complete
  85239. * @returns Nullable animation
  85240. */
  85241. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  85242. /**
  85243. * Transition property of an host to the target Value
  85244. * @param property The property to transition
  85245. * @param targetValue The target Value of the property
  85246. * @param host The object where the property to animate belongs
  85247. * @param scene Scene used to run the animation
  85248. * @param frameRate Framerate (in frame/s) to use
  85249. * @param transition The transition type we want to use
  85250. * @param duration The duration of the animation, in milliseconds
  85251. * @param onAnimationEnd Callback trigger at the end of the animation
  85252. * @returns Nullable animation
  85253. */
  85254. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  85255. /**
  85256. * Return the array of runtime animations currently using this animation
  85257. */
  85258. readonly runtimeAnimations: RuntimeAnimation[];
  85259. /**
  85260. * Specifies if any of the runtime animations are currently running
  85261. */
  85262. readonly hasRunningRuntimeAnimations: boolean;
  85263. /**
  85264. * Initializes the animation
  85265. * @param name Name of the animation
  85266. * @param targetProperty Property to animate
  85267. * @param framePerSecond The frames per second of the animation
  85268. * @param dataType The data type of the animation
  85269. * @param loopMode The loop mode of the animation
  85270. * @param enableBlending Specifies if blending should be enabled
  85271. */
  85272. constructor(
  85273. /**Name of the animation */
  85274. name: string,
  85275. /**Property to animate */
  85276. targetProperty: string,
  85277. /**The frames per second of the animation */
  85278. framePerSecond: number,
  85279. /**The data type of the animation */
  85280. dataType: number,
  85281. /**The loop mode of the animation */
  85282. loopMode?: number | undefined,
  85283. /**Specifies if blending should be enabled */
  85284. enableBlending?: boolean | undefined);
  85285. /**
  85286. * Converts the animation to a string
  85287. * @param fullDetails support for multiple levels of logging within scene loading
  85288. * @returns String form of the animation
  85289. */
  85290. toString(fullDetails?: boolean): string;
  85291. /**
  85292. * Add an event to this animation
  85293. * @param event Event to add
  85294. */
  85295. addEvent(event: AnimationEvent): void;
  85296. /**
  85297. * Remove all events found at the given frame
  85298. * @param frame The frame to remove events from
  85299. */
  85300. removeEvents(frame: number): void;
  85301. /**
  85302. * Retrieves all the events from the animation
  85303. * @returns Events from the animation
  85304. */
  85305. getEvents(): AnimationEvent[];
  85306. /**
  85307. * Creates an animation range
  85308. * @param name Name of the animation range
  85309. * @param from Starting frame of the animation range
  85310. * @param to Ending frame of the animation
  85311. */
  85312. createRange(name: string, from: number, to: number): void;
  85313. /**
  85314. * Deletes an animation range by name
  85315. * @param name Name of the animation range to delete
  85316. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  85317. */
  85318. deleteRange(name: string, deleteFrames?: boolean): void;
  85319. /**
  85320. * Gets the animation range by name, or null if not defined
  85321. * @param name Name of the animation range
  85322. * @returns Nullable animation range
  85323. */
  85324. getRange(name: string): Nullable<AnimationRange>;
  85325. /**
  85326. * Gets the key frames from the animation
  85327. * @returns The key frames of the animation
  85328. */
  85329. getKeys(): Array<IAnimationKey>;
  85330. /**
  85331. * Gets the highest frame rate of the animation
  85332. * @returns Highest frame rate of the animation
  85333. */
  85334. getHighestFrame(): number;
  85335. /**
  85336. * Gets the easing function of the animation
  85337. * @returns Easing function of the animation
  85338. */
  85339. getEasingFunction(): IEasingFunction;
  85340. /**
  85341. * Sets the easing function of the animation
  85342. * @param easingFunction A custom mathematical formula for animation
  85343. */
  85344. setEasingFunction(easingFunction: EasingFunction): void;
  85345. /**
  85346. * Interpolates a scalar linearly
  85347. * @param startValue Start value of the animation curve
  85348. * @param endValue End value of the animation curve
  85349. * @param gradient Scalar amount to interpolate
  85350. * @returns Interpolated scalar value
  85351. */
  85352. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  85353. /**
  85354. * Interpolates a scalar cubically
  85355. * @param startValue Start value of the animation curve
  85356. * @param outTangent End tangent of the animation
  85357. * @param endValue End value of the animation curve
  85358. * @param inTangent Start tangent of the animation curve
  85359. * @param gradient Scalar amount to interpolate
  85360. * @returns Interpolated scalar value
  85361. */
  85362. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  85363. /**
  85364. * Interpolates a quaternion using a spherical linear interpolation
  85365. * @param startValue Start value of the animation curve
  85366. * @param endValue End value of the animation curve
  85367. * @param gradient Scalar amount to interpolate
  85368. * @returns Interpolated quaternion value
  85369. */
  85370. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  85371. /**
  85372. * Interpolates a quaternion cubically
  85373. * @param startValue Start value of the animation curve
  85374. * @param outTangent End tangent of the animation curve
  85375. * @param endValue End value of the animation curve
  85376. * @param inTangent Start tangent of the animation curve
  85377. * @param gradient Scalar amount to interpolate
  85378. * @returns Interpolated quaternion value
  85379. */
  85380. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  85381. /**
  85382. * Interpolates a Vector3 linearl
  85383. * @param startValue Start value of the animation curve
  85384. * @param endValue End value of the animation curve
  85385. * @param gradient Scalar amount to interpolate
  85386. * @returns Interpolated scalar value
  85387. */
  85388. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  85389. /**
  85390. * Interpolates a Vector3 cubically
  85391. * @param startValue Start value of the animation curve
  85392. * @param outTangent End tangent of the animation
  85393. * @param endValue End value of the animation curve
  85394. * @param inTangent Start tangent of the animation curve
  85395. * @param gradient Scalar amount to interpolate
  85396. * @returns InterpolatedVector3 value
  85397. */
  85398. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  85399. /**
  85400. * Interpolates a Vector2 linearly
  85401. * @param startValue Start value of the animation curve
  85402. * @param endValue End value of the animation curve
  85403. * @param gradient Scalar amount to interpolate
  85404. * @returns Interpolated Vector2 value
  85405. */
  85406. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  85407. /**
  85408. * Interpolates a Vector2 cubically
  85409. * @param startValue Start value of the animation curve
  85410. * @param outTangent End tangent of the animation
  85411. * @param endValue End value of the animation curve
  85412. * @param inTangent Start tangent of the animation curve
  85413. * @param gradient Scalar amount to interpolate
  85414. * @returns Interpolated Vector2 value
  85415. */
  85416. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  85417. /**
  85418. * Interpolates a size linearly
  85419. * @param startValue Start value of the animation curve
  85420. * @param endValue End value of the animation curve
  85421. * @param gradient Scalar amount to interpolate
  85422. * @returns Interpolated Size value
  85423. */
  85424. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  85425. /**
  85426. * Interpolates a Color3 linearly
  85427. * @param startValue Start value of the animation curve
  85428. * @param endValue End value of the animation curve
  85429. * @param gradient Scalar amount to interpolate
  85430. * @returns Interpolated Color3 value
  85431. */
  85432. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  85433. /**
  85434. * @hidden Internal use only
  85435. */
  85436. _getKeyValue(value: any): any;
  85437. /**
  85438. * @hidden Internal use only
  85439. */
  85440. _interpolate(currentFrame: number, state: _IAnimationState): any;
  85441. /**
  85442. * Defines the function to use to interpolate matrices
  85443. * @param startValue defines the start matrix
  85444. * @param endValue defines the end matrix
  85445. * @param gradient defines the gradient between both matrices
  85446. * @param result defines an optional target matrix where to store the interpolation
  85447. * @returns the interpolated matrix
  85448. */
  85449. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  85450. /**
  85451. * Makes a copy of the animation
  85452. * @returns Cloned animation
  85453. */
  85454. clone(): Animation;
  85455. /**
  85456. * Sets the key frames of the animation
  85457. * @param values The animation key frames to set
  85458. */
  85459. setKeys(values: Array<IAnimationKey>): void;
  85460. /**
  85461. * Serializes the animation to an object
  85462. * @returns Serialized object
  85463. */
  85464. serialize(): any;
  85465. /**
  85466. * Float animation type
  85467. */
  85468. private static _ANIMATIONTYPE_FLOAT;
  85469. /**
  85470. * Vector3 animation type
  85471. */
  85472. private static _ANIMATIONTYPE_VECTOR3;
  85473. /**
  85474. * Quaternion animation type
  85475. */
  85476. private static _ANIMATIONTYPE_QUATERNION;
  85477. /**
  85478. * Matrix animation type
  85479. */
  85480. private static _ANIMATIONTYPE_MATRIX;
  85481. /**
  85482. * Color3 animation type
  85483. */
  85484. private static _ANIMATIONTYPE_COLOR3;
  85485. /**
  85486. * Vector2 animation type
  85487. */
  85488. private static _ANIMATIONTYPE_VECTOR2;
  85489. /**
  85490. * Size animation type
  85491. */
  85492. private static _ANIMATIONTYPE_SIZE;
  85493. /**
  85494. * Relative Loop Mode
  85495. */
  85496. private static _ANIMATIONLOOPMODE_RELATIVE;
  85497. /**
  85498. * Cycle Loop Mode
  85499. */
  85500. private static _ANIMATIONLOOPMODE_CYCLE;
  85501. /**
  85502. * Constant Loop Mode
  85503. */
  85504. private static _ANIMATIONLOOPMODE_CONSTANT;
  85505. /**
  85506. * Get the float animation type
  85507. */
  85508. static readonly ANIMATIONTYPE_FLOAT: number;
  85509. /**
  85510. * Get the Vector3 animation type
  85511. */
  85512. static readonly ANIMATIONTYPE_VECTOR3: number;
  85513. /**
  85514. * Get the Vector2 animation type
  85515. */
  85516. static readonly ANIMATIONTYPE_VECTOR2: number;
  85517. /**
  85518. * Get the Size animation type
  85519. */
  85520. static readonly ANIMATIONTYPE_SIZE: number;
  85521. /**
  85522. * Get the Quaternion animation type
  85523. */
  85524. static readonly ANIMATIONTYPE_QUATERNION: number;
  85525. /**
  85526. * Get the Matrix animation type
  85527. */
  85528. static readonly ANIMATIONTYPE_MATRIX: number;
  85529. /**
  85530. * Get the Color3 animation type
  85531. */
  85532. static readonly ANIMATIONTYPE_COLOR3: number;
  85533. /**
  85534. * Get the Relative Loop Mode
  85535. */
  85536. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  85537. /**
  85538. * Get the Cycle Loop Mode
  85539. */
  85540. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  85541. /**
  85542. * Get the Constant Loop Mode
  85543. */
  85544. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  85545. /** @hidden */
  85546. static _UniversalLerp(left: any, right: any, amount: number): any;
  85547. /**
  85548. * Parses an animation object and creates an animation
  85549. * @param parsedAnimation Parsed animation object
  85550. * @returns Animation object
  85551. */
  85552. static Parse(parsedAnimation: any): Animation;
  85553. /**
  85554. * Appends the serialized animations from the source animations
  85555. * @param source Source containing the animations
  85556. * @param destination Target to store the animations
  85557. */
  85558. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  85559. }
  85560. }
  85561. declare module BABYLON {
  85562. /**
  85563. * Base class of all the textures in babylon.
  85564. * It groups all the common properties the materials, post process, lights... might need
  85565. * in order to make a correct use of the texture.
  85566. */
  85567. export class BaseTexture implements IAnimatable {
  85568. /**
  85569. * Default anisotropic filtering level for the application.
  85570. * It is set to 4 as a good tradeoff between perf and quality.
  85571. */
  85572. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  85573. /**
  85574. * Gets or sets the unique id of the texture
  85575. */
  85576. uniqueId: number;
  85577. /**
  85578. * Define the name of the texture.
  85579. */
  85580. name: string;
  85581. /**
  85582. * Gets or sets an object used to store user defined information.
  85583. */
  85584. metadata: any;
  85585. /**
  85586. * For internal use only. Please do not use.
  85587. */
  85588. reservedDataStore: any;
  85589. private _hasAlpha;
  85590. /**
  85591. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  85592. */
  85593. hasAlpha: boolean;
  85594. /**
  85595. * Defines if the alpha value should be determined via the rgb values.
  85596. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  85597. */
  85598. getAlphaFromRGB: boolean;
  85599. /**
  85600. * Intensity or strength of the texture.
  85601. * It is commonly used by materials to fine tune the intensity of the texture
  85602. */
  85603. level: number;
  85604. /**
  85605. * Define the UV chanel to use starting from 0 and defaulting to 0.
  85606. * This is part of the texture as textures usually maps to one uv set.
  85607. */
  85608. coordinatesIndex: number;
  85609. private _coordinatesMode;
  85610. /**
  85611. * How a texture is mapped.
  85612. *
  85613. * | Value | Type | Description |
  85614. * | ----- | ----------------------------------- | ----------- |
  85615. * | 0 | EXPLICIT_MODE | |
  85616. * | 1 | SPHERICAL_MODE | |
  85617. * | 2 | PLANAR_MODE | |
  85618. * | 3 | CUBIC_MODE | |
  85619. * | 4 | PROJECTION_MODE | |
  85620. * | 5 | SKYBOX_MODE | |
  85621. * | 6 | INVCUBIC_MODE | |
  85622. * | 7 | EQUIRECTANGULAR_MODE | |
  85623. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  85624. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  85625. */
  85626. coordinatesMode: number;
  85627. /**
  85628. * | Value | Type | Description |
  85629. * | ----- | ------------------ | ----------- |
  85630. * | 0 | CLAMP_ADDRESSMODE | |
  85631. * | 1 | WRAP_ADDRESSMODE | |
  85632. * | 2 | MIRROR_ADDRESSMODE | |
  85633. */
  85634. wrapU: number;
  85635. /**
  85636. * | Value | Type | Description |
  85637. * | ----- | ------------------ | ----------- |
  85638. * | 0 | CLAMP_ADDRESSMODE | |
  85639. * | 1 | WRAP_ADDRESSMODE | |
  85640. * | 2 | MIRROR_ADDRESSMODE | |
  85641. */
  85642. wrapV: number;
  85643. /**
  85644. * | Value | Type | Description |
  85645. * | ----- | ------------------ | ----------- |
  85646. * | 0 | CLAMP_ADDRESSMODE | |
  85647. * | 1 | WRAP_ADDRESSMODE | |
  85648. * | 2 | MIRROR_ADDRESSMODE | |
  85649. */
  85650. wrapR: number;
  85651. /**
  85652. * With compliant hardware and browser (supporting anisotropic filtering)
  85653. * this defines the level of anisotropic filtering in the texture.
  85654. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  85655. */
  85656. anisotropicFilteringLevel: number;
  85657. /**
  85658. * Define if the texture is a cube texture or if false a 2d texture.
  85659. */
  85660. isCube: boolean;
  85661. /**
  85662. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  85663. */
  85664. is3D: boolean;
  85665. /**
  85666. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  85667. * HDR texture are usually stored in linear space.
  85668. * This only impacts the PBR and Background materials
  85669. */
  85670. gammaSpace: boolean;
  85671. /**
  85672. * Gets whether or not the texture contains RGBD data.
  85673. */
  85674. readonly isRGBD: boolean;
  85675. /**
  85676. * Is Z inverted in the texture (useful in a cube texture).
  85677. */
  85678. invertZ: boolean;
  85679. /**
  85680. * Are mip maps generated for this texture or not.
  85681. */
  85682. readonly noMipmap: boolean;
  85683. /**
  85684. * @hidden
  85685. */
  85686. lodLevelInAlpha: boolean;
  85687. /**
  85688. * With prefiltered texture, defined the offset used during the prefiltering steps.
  85689. */
  85690. lodGenerationOffset: number;
  85691. /**
  85692. * With prefiltered texture, defined the scale used during the prefiltering steps.
  85693. */
  85694. lodGenerationScale: number;
  85695. /**
  85696. * Define if the texture is a render target.
  85697. */
  85698. isRenderTarget: boolean;
  85699. /**
  85700. * Define the unique id of the texture in the scene.
  85701. */
  85702. readonly uid: string;
  85703. /**
  85704. * Return a string representation of the texture.
  85705. * @returns the texture as a string
  85706. */
  85707. toString(): string;
  85708. /**
  85709. * Get the class name of the texture.
  85710. * @returns "BaseTexture"
  85711. */
  85712. getClassName(): string;
  85713. /**
  85714. * Define the list of animation attached to the texture.
  85715. */
  85716. animations: Animation[];
  85717. /**
  85718. * An event triggered when the texture is disposed.
  85719. */
  85720. onDisposeObservable: Observable<BaseTexture>;
  85721. private _onDisposeObserver;
  85722. /**
  85723. * Callback triggered when the texture has been disposed.
  85724. * Kept for back compatibility, you can use the onDisposeObservable instead.
  85725. */
  85726. onDispose: () => void;
  85727. /**
  85728. * Define the current state of the loading sequence when in delayed load mode.
  85729. */
  85730. delayLoadState: number;
  85731. private _scene;
  85732. /** @hidden */
  85733. _texture: Nullable<InternalTexture>;
  85734. private _uid;
  85735. /**
  85736. * Define if the texture is preventinga material to render or not.
  85737. * If not and the texture is not ready, the engine will use a default black texture instead.
  85738. */
  85739. readonly isBlocking: boolean;
  85740. /**
  85741. * Instantiates a new BaseTexture.
  85742. * Base class of all the textures in babylon.
  85743. * It groups all the common properties the materials, post process, lights... might need
  85744. * in order to make a correct use of the texture.
  85745. * @param scene Define the scene the texture blongs to
  85746. */
  85747. constructor(scene: Nullable<Scene>);
  85748. /**
  85749. * Get the scene the texture belongs to.
  85750. * @returns the scene or null if undefined
  85751. */
  85752. getScene(): Nullable<Scene>;
  85753. /**
  85754. * Get the texture transform matrix used to offset tile the texture for istance.
  85755. * @returns the transformation matrix
  85756. */
  85757. getTextureMatrix(): Matrix;
  85758. /**
  85759. * Get the texture reflection matrix used to rotate/transform the reflection.
  85760. * @returns the reflection matrix
  85761. */
  85762. getReflectionTextureMatrix(): Matrix;
  85763. /**
  85764. * Get the underlying lower level texture from Babylon.
  85765. * @returns the insternal texture
  85766. */
  85767. getInternalTexture(): Nullable<InternalTexture>;
  85768. /**
  85769. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  85770. * @returns true if ready or not blocking
  85771. */
  85772. isReadyOrNotBlocking(): boolean;
  85773. /**
  85774. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  85775. * @returns true if fully ready
  85776. */
  85777. isReady(): boolean;
  85778. private _cachedSize;
  85779. /**
  85780. * Get the size of the texture.
  85781. * @returns the texture size.
  85782. */
  85783. getSize(): ISize;
  85784. /**
  85785. * Get the base size of the texture.
  85786. * It can be different from the size if the texture has been resized for POT for instance
  85787. * @returns the base size
  85788. */
  85789. getBaseSize(): ISize;
  85790. /**
  85791. * Update the sampling mode of the texture.
  85792. * Default is Trilinear mode.
  85793. *
  85794. * | Value | Type | Description |
  85795. * | ----- | ------------------ | ----------- |
  85796. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  85797. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  85798. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  85799. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  85800. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  85801. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  85802. * | 7 | NEAREST_LINEAR | |
  85803. * | 8 | NEAREST_NEAREST | |
  85804. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  85805. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  85806. * | 11 | LINEAR_LINEAR | |
  85807. * | 12 | LINEAR_NEAREST | |
  85808. *
  85809. * > _mag_: magnification filter (close to the viewer)
  85810. * > _min_: minification filter (far from the viewer)
  85811. * > _mip_: filter used between mip map levels
  85812. *@param samplingMode Define the new sampling mode of the texture
  85813. */
  85814. updateSamplingMode(samplingMode: number): void;
  85815. /**
  85816. * Scales the texture if is `canRescale()`
  85817. * @param ratio the resize factor we want to use to rescale
  85818. */
  85819. scale(ratio: number): void;
  85820. /**
  85821. * Get if the texture can rescale.
  85822. */
  85823. readonly canRescale: boolean;
  85824. /** @hidden */
  85825. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  85826. /** @hidden */
  85827. _rebuild(): void;
  85828. /**
  85829. * Triggers the load sequence in delayed load mode.
  85830. */
  85831. delayLoad(): void;
  85832. /**
  85833. * Clones the texture.
  85834. * @returns the cloned texture
  85835. */
  85836. clone(): Nullable<BaseTexture>;
  85837. /**
  85838. * Get the texture underlying type (INT, FLOAT...)
  85839. */
  85840. readonly textureType: number;
  85841. /**
  85842. * Get the texture underlying format (RGB, RGBA...)
  85843. */
  85844. readonly textureFormat: number;
  85845. /**
  85846. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  85847. * This will returns an RGBA array buffer containing either in values (0-255) or
  85848. * float values (0-1) depending of the underlying buffer type.
  85849. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  85850. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  85851. * @param buffer defines a user defined buffer to fill with data (can be null)
  85852. * @returns The Array buffer containing the pixels data.
  85853. */
  85854. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  85855. /**
  85856. * Release and destroy the underlying lower level texture aka internalTexture.
  85857. */
  85858. releaseInternalTexture(): void;
  85859. /**
  85860. * Get the polynomial representation of the texture data.
  85861. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  85862. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  85863. */
  85864. sphericalPolynomial: Nullable<SphericalPolynomial>;
  85865. /** @hidden */
  85866. readonly _lodTextureHigh: Nullable<BaseTexture>;
  85867. /** @hidden */
  85868. readonly _lodTextureMid: Nullable<BaseTexture>;
  85869. /** @hidden */
  85870. readonly _lodTextureLow: Nullable<BaseTexture>;
  85871. /**
  85872. * Dispose the texture and release its associated resources.
  85873. */
  85874. dispose(): void;
  85875. /**
  85876. * Serialize the texture into a JSON representation that can be parsed later on.
  85877. * @returns the JSON representation of the texture
  85878. */
  85879. serialize(): any;
  85880. /**
  85881. * Helper function to be called back once a list of texture contains only ready textures.
  85882. * @param textures Define the list of textures to wait for
  85883. * @param callback Define the callback triggered once the entire list will be ready
  85884. */
  85885. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  85886. }
  85887. }
  85888. declare module BABYLON {
  85889. /**
  85890. * Uniform buffer objects.
  85891. *
  85892. * Handles blocks of uniform on the GPU.
  85893. *
  85894. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85895. *
  85896. * For more information, please refer to :
  85897. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85898. */
  85899. export class UniformBuffer {
  85900. private _engine;
  85901. private _buffer;
  85902. private _data;
  85903. private _bufferData;
  85904. private _dynamic?;
  85905. private _uniformLocations;
  85906. private _uniformSizes;
  85907. private _uniformLocationPointer;
  85908. private _needSync;
  85909. private _noUBO;
  85910. private _currentEffect;
  85911. private static _MAX_UNIFORM_SIZE;
  85912. private static _tempBuffer;
  85913. /**
  85914. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  85915. * This is dynamic to allow compat with webgl 1 and 2.
  85916. * You will need to pass the name of the uniform as well as the value.
  85917. */
  85918. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  85919. /**
  85920. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  85921. * This is dynamic to allow compat with webgl 1 and 2.
  85922. * You will need to pass the name of the uniform as well as the value.
  85923. */
  85924. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  85925. /**
  85926. * Lambda to Update a single float in a uniform buffer.
  85927. * This is dynamic to allow compat with webgl 1 and 2.
  85928. * You will need to pass the name of the uniform as well as the value.
  85929. */
  85930. updateFloat: (name: string, x: number) => void;
  85931. /**
  85932. * Lambda to Update a vec2 of float in a uniform buffer.
  85933. * This is dynamic to allow compat with webgl 1 and 2.
  85934. * You will need to pass the name of the uniform as well as the value.
  85935. */
  85936. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  85937. /**
  85938. * Lambda to Update a vec3 of float in a uniform buffer.
  85939. * This is dynamic to allow compat with webgl 1 and 2.
  85940. * You will need to pass the name of the uniform as well as the value.
  85941. */
  85942. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  85943. /**
  85944. * Lambda to Update a vec4 of float in a uniform buffer.
  85945. * This is dynamic to allow compat with webgl 1 and 2.
  85946. * You will need to pass the name of the uniform as well as the value.
  85947. */
  85948. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  85949. /**
  85950. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  85951. * This is dynamic to allow compat with webgl 1 and 2.
  85952. * You will need to pass the name of the uniform as well as the value.
  85953. */
  85954. updateMatrix: (name: string, mat: Matrix) => void;
  85955. /**
  85956. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  85957. * This is dynamic to allow compat with webgl 1 and 2.
  85958. * You will need to pass the name of the uniform as well as the value.
  85959. */
  85960. updateVector3: (name: string, vector: Vector3) => void;
  85961. /**
  85962. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  85963. * This is dynamic to allow compat with webgl 1 and 2.
  85964. * You will need to pass the name of the uniform as well as the value.
  85965. */
  85966. updateVector4: (name: string, vector: Vector4) => void;
  85967. /**
  85968. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  85969. * This is dynamic to allow compat with webgl 1 and 2.
  85970. * You will need to pass the name of the uniform as well as the value.
  85971. */
  85972. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  85973. /**
  85974. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  85975. * This is dynamic to allow compat with webgl 1 and 2.
  85976. * You will need to pass the name of the uniform as well as the value.
  85977. */
  85978. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  85979. /**
  85980. * Instantiates a new Uniform buffer objects.
  85981. *
  85982. * Handles blocks of uniform on the GPU.
  85983. *
  85984. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85985. *
  85986. * For more information, please refer to :
  85987. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85988. * @param engine Define the engine the buffer is associated with
  85989. * @param data Define the data contained in the buffer
  85990. * @param dynamic Define if the buffer is updatable
  85991. */
  85992. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  85993. /**
  85994. * Indicates if the buffer is using the WebGL2 UBO implementation,
  85995. * or just falling back on setUniformXXX calls.
  85996. */
  85997. readonly useUbo: boolean;
  85998. /**
  85999. * Indicates if the WebGL underlying uniform buffer is in sync
  86000. * with the javascript cache data.
  86001. */
  86002. readonly isSync: boolean;
  86003. /**
  86004. * Indicates if the WebGL underlying uniform buffer is dynamic.
  86005. * Also, a dynamic UniformBuffer will disable cache verification and always
  86006. * update the underlying WebGL uniform buffer to the GPU.
  86007. * @returns if Dynamic, otherwise false
  86008. */
  86009. isDynamic(): boolean;
  86010. /**
  86011. * The data cache on JS side.
  86012. * @returns the underlying data as a float array
  86013. */
  86014. getData(): Float32Array;
  86015. /**
  86016. * The underlying WebGL Uniform buffer.
  86017. * @returns the webgl buffer
  86018. */
  86019. getBuffer(): Nullable<DataBuffer>;
  86020. /**
  86021. * std140 layout specifies how to align data within an UBO structure.
  86022. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  86023. * for specs.
  86024. */
  86025. private _fillAlignment;
  86026. /**
  86027. * Adds an uniform in the buffer.
  86028. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  86029. * for the layout to be correct !
  86030. * @param name Name of the uniform, as used in the uniform block in the shader.
  86031. * @param size Data size, or data directly.
  86032. */
  86033. addUniform(name: string, size: number | number[]): void;
  86034. /**
  86035. * Adds a Matrix 4x4 to the uniform buffer.
  86036. * @param name Name of the uniform, as used in the uniform block in the shader.
  86037. * @param mat A 4x4 matrix.
  86038. */
  86039. addMatrix(name: string, mat: Matrix): void;
  86040. /**
  86041. * Adds a vec2 to the uniform buffer.
  86042. * @param name Name of the uniform, as used in the uniform block in the shader.
  86043. * @param x Define the x component value of the vec2
  86044. * @param y Define the y component value of the vec2
  86045. */
  86046. addFloat2(name: string, x: number, y: number): void;
  86047. /**
  86048. * Adds a vec3 to the uniform buffer.
  86049. * @param name Name of the uniform, as used in the uniform block in the shader.
  86050. * @param x Define the x component value of the vec3
  86051. * @param y Define the y component value of the vec3
  86052. * @param z Define the z component value of the vec3
  86053. */
  86054. addFloat3(name: string, x: number, y: number, z: number): void;
  86055. /**
  86056. * Adds a vec3 to the uniform buffer.
  86057. * @param name Name of the uniform, as used in the uniform block in the shader.
  86058. * @param color Define the vec3 from a Color
  86059. */
  86060. addColor3(name: string, color: Color3): void;
  86061. /**
  86062. * Adds a vec4 to the uniform buffer.
  86063. * @param name Name of the uniform, as used in the uniform block in the shader.
  86064. * @param color Define the rgb components from a Color
  86065. * @param alpha Define the a component of the vec4
  86066. */
  86067. addColor4(name: string, color: Color3, alpha: number): void;
  86068. /**
  86069. * Adds a vec3 to the uniform buffer.
  86070. * @param name Name of the uniform, as used in the uniform block in the shader.
  86071. * @param vector Define the vec3 components from a Vector
  86072. */
  86073. addVector3(name: string, vector: Vector3): void;
  86074. /**
  86075. * Adds a Matrix 3x3 to the uniform buffer.
  86076. * @param name Name of the uniform, as used in the uniform block in the shader.
  86077. */
  86078. addMatrix3x3(name: string): void;
  86079. /**
  86080. * Adds a Matrix 2x2 to the uniform buffer.
  86081. * @param name Name of the uniform, as used in the uniform block in the shader.
  86082. */
  86083. addMatrix2x2(name: string): void;
  86084. /**
  86085. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  86086. */
  86087. create(): void;
  86088. /** @hidden */
  86089. _rebuild(): void;
  86090. /**
  86091. * Updates the WebGL Uniform Buffer on the GPU.
  86092. * If the `dynamic` flag is set to true, no cache comparison is done.
  86093. * Otherwise, the buffer will be updated only if the cache differs.
  86094. */
  86095. update(): void;
  86096. /**
  86097. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  86098. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86099. * @param data Define the flattened data
  86100. * @param size Define the size of the data.
  86101. */
  86102. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  86103. private _updateMatrix3x3ForUniform;
  86104. private _updateMatrix3x3ForEffect;
  86105. private _updateMatrix2x2ForEffect;
  86106. private _updateMatrix2x2ForUniform;
  86107. private _updateFloatForEffect;
  86108. private _updateFloatForUniform;
  86109. private _updateFloat2ForEffect;
  86110. private _updateFloat2ForUniform;
  86111. private _updateFloat3ForEffect;
  86112. private _updateFloat3ForUniform;
  86113. private _updateFloat4ForEffect;
  86114. private _updateFloat4ForUniform;
  86115. private _updateMatrixForEffect;
  86116. private _updateMatrixForUniform;
  86117. private _updateVector3ForEffect;
  86118. private _updateVector3ForUniform;
  86119. private _updateVector4ForEffect;
  86120. private _updateVector4ForUniform;
  86121. private _updateColor3ForEffect;
  86122. private _updateColor3ForUniform;
  86123. private _updateColor4ForEffect;
  86124. private _updateColor4ForUniform;
  86125. /**
  86126. * Sets a sampler uniform on the effect.
  86127. * @param name Define the name of the sampler.
  86128. * @param texture Define the texture to set in the sampler
  86129. */
  86130. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  86131. /**
  86132. * Directly updates the value of the uniform in the cache AND on the GPU.
  86133. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86134. * @param data Define the flattened data
  86135. */
  86136. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  86137. /**
  86138. * Binds this uniform buffer to an effect.
  86139. * @param effect Define the effect to bind the buffer to
  86140. * @param name Name of the uniform block in the shader.
  86141. */
  86142. bindToEffect(effect: Effect, name: string): void;
  86143. /**
  86144. * Disposes the uniform buffer.
  86145. */
  86146. dispose(): void;
  86147. }
  86148. }
  86149. declare module BABYLON {
  86150. /**
  86151. * Class used to work with sound analyzer using fast fourier transform (FFT)
  86152. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86153. */
  86154. export class Analyser {
  86155. /**
  86156. * Gets or sets the smoothing
  86157. * @ignorenaming
  86158. */
  86159. SMOOTHING: number;
  86160. /**
  86161. * Gets or sets the FFT table size
  86162. * @ignorenaming
  86163. */
  86164. FFT_SIZE: number;
  86165. /**
  86166. * Gets or sets the bar graph amplitude
  86167. * @ignorenaming
  86168. */
  86169. BARGRAPHAMPLITUDE: number;
  86170. /**
  86171. * Gets or sets the position of the debug canvas
  86172. * @ignorenaming
  86173. */
  86174. DEBUGCANVASPOS: {
  86175. x: number;
  86176. y: number;
  86177. };
  86178. /**
  86179. * Gets or sets the debug canvas size
  86180. * @ignorenaming
  86181. */
  86182. DEBUGCANVASSIZE: {
  86183. width: number;
  86184. height: number;
  86185. };
  86186. private _byteFreqs;
  86187. private _byteTime;
  86188. private _floatFreqs;
  86189. private _webAudioAnalyser;
  86190. private _debugCanvas;
  86191. private _debugCanvasContext;
  86192. private _scene;
  86193. private _registerFunc;
  86194. private _audioEngine;
  86195. /**
  86196. * Creates a new analyser
  86197. * @param scene defines hosting scene
  86198. */
  86199. constructor(scene: Scene);
  86200. /**
  86201. * Get the number of data values you will have to play with for the visualization
  86202. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  86203. * @returns a number
  86204. */
  86205. getFrequencyBinCount(): number;
  86206. /**
  86207. * Gets the current frequency data as a byte array
  86208. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86209. * @returns a Uint8Array
  86210. */
  86211. getByteFrequencyData(): Uint8Array;
  86212. /**
  86213. * Gets the current waveform as a byte array
  86214. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  86215. * @returns a Uint8Array
  86216. */
  86217. getByteTimeDomainData(): Uint8Array;
  86218. /**
  86219. * Gets the current frequency data as a float array
  86220. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86221. * @returns a Float32Array
  86222. */
  86223. getFloatFrequencyData(): Float32Array;
  86224. /**
  86225. * Renders the debug canvas
  86226. */
  86227. drawDebugCanvas(): void;
  86228. /**
  86229. * Stops rendering the debug canvas and removes it
  86230. */
  86231. stopDebugCanvas(): void;
  86232. /**
  86233. * Connects two audio nodes
  86234. * @param inputAudioNode defines first node to connect
  86235. * @param outputAudioNode defines second node to connect
  86236. */
  86237. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  86238. /**
  86239. * Releases all associated resources
  86240. */
  86241. dispose(): void;
  86242. }
  86243. }
  86244. declare module BABYLON {
  86245. /**
  86246. * This represents an audio engine and it is responsible
  86247. * to play, synchronize and analyse sounds throughout the application.
  86248. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86249. */
  86250. export interface IAudioEngine extends IDisposable {
  86251. /**
  86252. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86253. */
  86254. readonly canUseWebAudio: boolean;
  86255. /**
  86256. * Gets the current AudioContext if available.
  86257. */
  86258. readonly audioContext: Nullable<AudioContext>;
  86259. /**
  86260. * The master gain node defines the global audio volume of your audio engine.
  86261. */
  86262. readonly masterGain: GainNode;
  86263. /**
  86264. * Gets whether or not mp3 are supported by your browser.
  86265. */
  86266. readonly isMP3supported: boolean;
  86267. /**
  86268. * Gets whether or not ogg are supported by your browser.
  86269. */
  86270. readonly isOGGsupported: boolean;
  86271. /**
  86272. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86273. * @ignoreNaming
  86274. */
  86275. WarnedWebAudioUnsupported: boolean;
  86276. /**
  86277. * Defines if the audio engine relies on a custom unlocked button.
  86278. * In this case, the embedded button will not be displayed.
  86279. */
  86280. useCustomUnlockedButton: boolean;
  86281. /**
  86282. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  86283. */
  86284. readonly unlocked: boolean;
  86285. /**
  86286. * Event raised when audio has been unlocked on the browser.
  86287. */
  86288. onAudioUnlockedObservable: Observable<AudioEngine>;
  86289. /**
  86290. * Event raised when audio has been locked on the browser.
  86291. */
  86292. onAudioLockedObservable: Observable<AudioEngine>;
  86293. /**
  86294. * Flags the audio engine in Locked state.
  86295. * This happens due to new browser policies preventing audio to autoplay.
  86296. */
  86297. lock(): void;
  86298. /**
  86299. * Unlocks the audio engine once a user action has been done on the dom.
  86300. * This is helpful to resume play once browser policies have been satisfied.
  86301. */
  86302. unlock(): void;
  86303. }
  86304. /**
  86305. * This represents the default audio engine used in babylon.
  86306. * It is responsible to play, synchronize and analyse sounds throughout the application.
  86307. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86308. */
  86309. export class AudioEngine implements IAudioEngine {
  86310. private _audioContext;
  86311. private _audioContextInitialized;
  86312. private _muteButton;
  86313. private _hostElement;
  86314. /**
  86315. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86316. */
  86317. canUseWebAudio: boolean;
  86318. /**
  86319. * The master gain node defines the global audio volume of your audio engine.
  86320. */
  86321. masterGain: GainNode;
  86322. /**
  86323. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86324. * @ignoreNaming
  86325. */
  86326. WarnedWebAudioUnsupported: boolean;
  86327. /**
  86328. * Gets whether or not mp3 are supported by your browser.
  86329. */
  86330. isMP3supported: boolean;
  86331. /**
  86332. * Gets whether or not ogg are supported by your browser.
  86333. */
  86334. isOGGsupported: boolean;
  86335. /**
  86336. * Gets whether audio has been unlocked on the device.
  86337. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  86338. * a user interaction has happened.
  86339. */
  86340. unlocked: boolean;
  86341. /**
  86342. * Defines if the audio engine relies on a custom unlocked button.
  86343. * In this case, the embedded button will not be displayed.
  86344. */
  86345. useCustomUnlockedButton: boolean;
  86346. /**
  86347. * Event raised when audio has been unlocked on the browser.
  86348. */
  86349. onAudioUnlockedObservable: Observable<AudioEngine>;
  86350. /**
  86351. * Event raised when audio has been locked on the browser.
  86352. */
  86353. onAudioLockedObservable: Observable<AudioEngine>;
  86354. /**
  86355. * Gets the current AudioContext if available.
  86356. */
  86357. readonly audioContext: Nullable<AudioContext>;
  86358. private _connectedAnalyser;
  86359. /**
  86360. * Instantiates a new audio engine.
  86361. *
  86362. * There should be only one per page as some browsers restrict the number
  86363. * of audio contexts you can create.
  86364. * @param hostElement defines the host element where to display the mute icon if necessary
  86365. */
  86366. constructor(hostElement?: Nullable<HTMLElement>);
  86367. /**
  86368. * Flags the audio engine in Locked state.
  86369. * This happens due to new browser policies preventing audio to autoplay.
  86370. */
  86371. lock(): void;
  86372. /**
  86373. * Unlocks the audio engine once a user action has been done on the dom.
  86374. * This is helpful to resume play once browser policies have been satisfied.
  86375. */
  86376. unlock(): void;
  86377. private _resumeAudioContext;
  86378. private _initializeAudioContext;
  86379. private _tryToRun;
  86380. private _triggerRunningState;
  86381. private _triggerSuspendedState;
  86382. private _displayMuteButton;
  86383. private _moveButtonToTopLeft;
  86384. private _onResize;
  86385. private _hideMuteButton;
  86386. /**
  86387. * Destroy and release the resources associated with the audio ccontext.
  86388. */
  86389. dispose(): void;
  86390. /**
  86391. * Gets the global volume sets on the master gain.
  86392. * @returns the global volume if set or -1 otherwise
  86393. */
  86394. getGlobalVolume(): number;
  86395. /**
  86396. * Sets the global volume of your experience (sets on the master gain).
  86397. * @param newVolume Defines the new global volume of the application
  86398. */
  86399. setGlobalVolume(newVolume: number): void;
  86400. /**
  86401. * Connect the audio engine to an audio analyser allowing some amazing
  86402. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  86403. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  86404. * @param analyser The analyser to connect to the engine
  86405. */
  86406. connectToAnalyser(analyser: Analyser): void;
  86407. }
  86408. }
  86409. declare module BABYLON {
  86410. /**
  86411. * Interface used to present a loading screen while loading a scene
  86412. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86413. */
  86414. export interface ILoadingScreen {
  86415. /**
  86416. * Function called to display the loading screen
  86417. */
  86418. displayLoadingUI: () => void;
  86419. /**
  86420. * Function called to hide the loading screen
  86421. */
  86422. hideLoadingUI: () => void;
  86423. /**
  86424. * Gets or sets the color to use for the background
  86425. */
  86426. loadingUIBackgroundColor: string;
  86427. /**
  86428. * Gets or sets the text to display while loading
  86429. */
  86430. loadingUIText: string;
  86431. }
  86432. /**
  86433. * Class used for the default loading screen
  86434. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86435. */
  86436. export class DefaultLoadingScreen implements ILoadingScreen {
  86437. private _renderingCanvas;
  86438. private _loadingText;
  86439. private _loadingDivBackgroundColor;
  86440. private _loadingDiv;
  86441. private _loadingTextDiv;
  86442. /**
  86443. * Creates a new default loading screen
  86444. * @param _renderingCanvas defines the canvas used to render the scene
  86445. * @param _loadingText defines the default text to display
  86446. * @param _loadingDivBackgroundColor defines the default background color
  86447. */
  86448. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  86449. /**
  86450. * Function called to display the loading screen
  86451. */
  86452. displayLoadingUI(): void;
  86453. /**
  86454. * Function called to hide the loading screen
  86455. */
  86456. hideLoadingUI(): void;
  86457. /**
  86458. * Gets or sets the text to display while loading
  86459. */
  86460. loadingUIText: string;
  86461. /**
  86462. * Gets or sets the color to use for the background
  86463. */
  86464. loadingUIBackgroundColor: string;
  86465. private _resizeLoadingUI;
  86466. }
  86467. }
  86468. declare module BABYLON {
  86469. /** @hidden */
  86470. export class WebGLPipelineContext implements IPipelineContext {
  86471. engine: Engine;
  86472. program: Nullable<WebGLProgram>;
  86473. context?: WebGLRenderingContext;
  86474. vertexShader?: WebGLShader;
  86475. fragmentShader?: WebGLShader;
  86476. isParallelCompiled: boolean;
  86477. onCompiled?: () => void;
  86478. transformFeedback?: WebGLTransformFeedback | null;
  86479. readonly isAsync: boolean;
  86480. readonly isReady: boolean;
  86481. }
  86482. }
  86483. declare module BABYLON {
  86484. /** @hidden */
  86485. export class WebGLDataBuffer extends DataBuffer {
  86486. private _buffer;
  86487. constructor(resource: WebGLBuffer);
  86488. readonly underlyingResource: any;
  86489. }
  86490. }
  86491. declare module BABYLON {
  86492. /**
  86493. * Settings for finer control over video usage
  86494. */
  86495. export interface VideoTextureSettings {
  86496. /**
  86497. * Applies `autoplay` to video, if specified
  86498. */
  86499. autoPlay?: boolean;
  86500. /**
  86501. * Applies `loop` to video, if specified
  86502. */
  86503. loop?: boolean;
  86504. /**
  86505. * Automatically updates internal texture from video at every frame in the render loop
  86506. */
  86507. autoUpdateTexture: boolean;
  86508. /**
  86509. * Image src displayed during the video loading or until the user interacts with the video.
  86510. */
  86511. poster?: string;
  86512. }
  86513. /**
  86514. * If you want to display a video in your scene, this is the special texture for that.
  86515. * This special texture works similar to other textures, with the exception of a few parameters.
  86516. * @see https://doc.babylonjs.com/how_to/video_texture
  86517. */
  86518. export class VideoTexture extends Texture {
  86519. /**
  86520. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  86521. */
  86522. readonly autoUpdateTexture: boolean;
  86523. /**
  86524. * The video instance used by the texture internally
  86525. */
  86526. readonly video: HTMLVideoElement;
  86527. private _onUserActionRequestedObservable;
  86528. /**
  86529. * Event triggerd when a dom action is required by the user to play the video.
  86530. * This happens due to recent changes in browser policies preventing video to auto start.
  86531. */
  86532. readonly onUserActionRequestedObservable: Observable<Texture>;
  86533. private _generateMipMaps;
  86534. private _engine;
  86535. private _stillImageCaptured;
  86536. private _displayingPosterTexture;
  86537. private _settings;
  86538. private _createInternalTextureOnEvent;
  86539. /**
  86540. * Creates a video texture.
  86541. * If you want to display a video in your scene, this is the special texture for that.
  86542. * This special texture works similar to other textures, with the exception of a few parameters.
  86543. * @see https://doc.babylonjs.com/how_to/video_texture
  86544. * @param name optional name, will detect from video source, if not defined
  86545. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  86546. * @param scene is obviously the current scene.
  86547. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  86548. * @param invertY is false by default but can be used to invert video on Y axis
  86549. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  86550. * @param settings allows finer control over video usage
  86551. */
  86552. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  86553. private _getName;
  86554. private _getVideo;
  86555. private _createInternalTexture;
  86556. private reset;
  86557. /**
  86558. * @hidden Internal method to initiate `update`.
  86559. */
  86560. _rebuild(): void;
  86561. /**
  86562. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  86563. */
  86564. update(): void;
  86565. /**
  86566. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  86567. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  86568. */
  86569. updateTexture(isVisible: boolean): void;
  86570. protected _updateInternalTexture: () => void;
  86571. /**
  86572. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  86573. * @param url New url.
  86574. */
  86575. updateURL(url: string): void;
  86576. /**
  86577. * Dispose the texture and release its associated resources.
  86578. */
  86579. dispose(): void;
  86580. /**
  86581. * Creates a video texture straight from a stream.
  86582. * @param scene Define the scene the texture should be created in
  86583. * @param stream Define the stream the texture should be created from
  86584. * @returns The created video texture as a promise
  86585. */
  86586. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  86587. /**
  86588. * Creates a video texture straight from your WebCam video feed.
  86589. * @param scene Define the scene the texture should be created in
  86590. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86591. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86592. * @returns The created video texture as a promise
  86593. */
  86594. static CreateFromWebCamAsync(scene: Scene, constraints: {
  86595. minWidth: number;
  86596. maxWidth: number;
  86597. minHeight: number;
  86598. maxHeight: number;
  86599. deviceId: string;
  86600. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  86601. /**
  86602. * Creates a video texture straight from your WebCam video feed.
  86603. * @param scene Define the scene the texture should be created in
  86604. * @param onReady Define a callback to triggered once the texture will be ready
  86605. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86606. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86607. */
  86608. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  86609. minWidth: number;
  86610. maxWidth: number;
  86611. minHeight: number;
  86612. maxHeight: number;
  86613. deviceId: string;
  86614. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  86615. }
  86616. }
  86617. declare module BABYLON {
  86618. /**
  86619. * Interface for attribute information associated with buffer instanciation
  86620. */
  86621. export class InstancingAttributeInfo {
  86622. /**
  86623. * Index/offset of the attribute in the vertex shader
  86624. */
  86625. index: number;
  86626. /**
  86627. * size of the attribute, 1, 2, 3 or 4
  86628. */
  86629. attributeSize: number;
  86630. /**
  86631. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  86632. * default is FLOAT
  86633. */
  86634. attribyteType: number;
  86635. /**
  86636. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  86637. */
  86638. normalized: boolean;
  86639. /**
  86640. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  86641. */
  86642. offset: number;
  86643. /**
  86644. * Name of the GLSL attribute, for debugging purpose only
  86645. */
  86646. attributeName: string;
  86647. }
  86648. /**
  86649. * Define options used to create a depth texture
  86650. */
  86651. export class DepthTextureCreationOptions {
  86652. /** Specifies whether or not a stencil should be allocated in the texture */
  86653. generateStencil?: boolean;
  86654. /** Specifies whether or not bilinear filtering is enable on the texture */
  86655. bilinearFiltering?: boolean;
  86656. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86657. comparisonFunction?: number;
  86658. /** Specifies if the created texture is a cube texture */
  86659. isCube?: boolean;
  86660. }
  86661. /**
  86662. * Class used to describe the capabilities of the engine relatively to the current browser
  86663. */
  86664. export class EngineCapabilities {
  86665. /** Maximum textures units per fragment shader */
  86666. maxTexturesImageUnits: number;
  86667. /** Maximum texture units per vertex shader */
  86668. maxVertexTextureImageUnits: number;
  86669. /** Maximum textures units in the entire pipeline */
  86670. maxCombinedTexturesImageUnits: number;
  86671. /** Maximum texture size */
  86672. maxTextureSize: number;
  86673. /** Maximum cube texture size */
  86674. maxCubemapTextureSize: number;
  86675. /** Maximum render texture size */
  86676. maxRenderTextureSize: number;
  86677. /** Maximum number of vertex attributes */
  86678. maxVertexAttribs: number;
  86679. /** Maximum number of varyings */
  86680. maxVaryingVectors: number;
  86681. /** Maximum number of uniforms per vertex shader */
  86682. maxVertexUniformVectors: number;
  86683. /** Maximum number of uniforms per fragment shader */
  86684. maxFragmentUniformVectors: number;
  86685. /** Defines if standard derivates (dx/dy) are supported */
  86686. standardDerivatives: boolean;
  86687. /** Defines if s3tc texture compression is supported */
  86688. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  86689. /** Defines if pvrtc texture compression is supported */
  86690. pvrtc: any;
  86691. /** Defines if etc1 texture compression is supported */
  86692. etc1: any;
  86693. /** Defines if etc2 texture compression is supported */
  86694. etc2: any;
  86695. /** Defines if astc texture compression is supported */
  86696. astc: any;
  86697. /** Defines if float textures are supported */
  86698. textureFloat: boolean;
  86699. /** Defines if vertex array objects are supported */
  86700. vertexArrayObject: boolean;
  86701. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  86702. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  86703. /** Gets the maximum level of anisotropy supported */
  86704. maxAnisotropy: number;
  86705. /** Defines if instancing is supported */
  86706. instancedArrays: boolean;
  86707. /** Defines if 32 bits indices are supported */
  86708. uintIndices: boolean;
  86709. /** Defines if high precision shaders are supported */
  86710. highPrecisionShaderSupported: boolean;
  86711. /** Defines if depth reading in the fragment shader is supported */
  86712. fragmentDepthSupported: boolean;
  86713. /** Defines if float texture linear filtering is supported*/
  86714. textureFloatLinearFiltering: boolean;
  86715. /** Defines if rendering to float textures is supported */
  86716. textureFloatRender: boolean;
  86717. /** Defines if half float textures are supported*/
  86718. textureHalfFloat: boolean;
  86719. /** Defines if half float texture linear filtering is supported*/
  86720. textureHalfFloatLinearFiltering: boolean;
  86721. /** Defines if rendering to half float textures is supported */
  86722. textureHalfFloatRender: boolean;
  86723. /** Defines if textureLOD shader command is supported */
  86724. textureLOD: boolean;
  86725. /** Defines if draw buffers extension is supported */
  86726. drawBuffersExtension: boolean;
  86727. /** Defines if depth textures are supported */
  86728. depthTextureExtension: boolean;
  86729. /** Defines if float color buffer are supported */
  86730. colorBufferFloat: boolean;
  86731. /** Gets disjoint timer query extension (null if not supported) */
  86732. timerQuery: EXT_disjoint_timer_query;
  86733. /** Defines if timestamp can be used with timer query */
  86734. canUseTimestampForTimerQuery: boolean;
  86735. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  86736. multiview: any;
  86737. /** Function used to let the system compiles shaders in background */
  86738. parallelShaderCompile: {
  86739. COMPLETION_STATUS_KHR: number;
  86740. };
  86741. }
  86742. /** Interface defining initialization parameters for Engine class */
  86743. export interface EngineOptions extends WebGLContextAttributes {
  86744. /**
  86745. * Defines if the engine should no exceed a specified device ratio
  86746. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  86747. */
  86748. limitDeviceRatio?: number;
  86749. /**
  86750. * Defines if webvr should be enabled automatically
  86751. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86752. */
  86753. autoEnableWebVR?: boolean;
  86754. /**
  86755. * Defines if webgl2 should be turned off even if supported
  86756. * @see http://doc.babylonjs.com/features/webgl2
  86757. */
  86758. disableWebGL2Support?: boolean;
  86759. /**
  86760. * Defines if webaudio should be initialized as well
  86761. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86762. */
  86763. audioEngine?: boolean;
  86764. /**
  86765. * Defines if animations should run using a deterministic lock step
  86766. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86767. */
  86768. deterministicLockstep?: boolean;
  86769. /** Defines the maximum steps to use with deterministic lock step mode */
  86770. lockstepMaxSteps?: number;
  86771. /**
  86772. * Defines that engine should ignore context lost events
  86773. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  86774. */
  86775. doNotHandleContextLost?: boolean;
  86776. /**
  86777. * Defines that engine should ignore modifying touch action attribute and style
  86778. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  86779. */
  86780. doNotHandleTouchAction?: boolean;
  86781. /**
  86782. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  86783. */
  86784. useHighPrecisionFloats?: boolean;
  86785. }
  86786. /**
  86787. * Defines the interface used by display changed events
  86788. */
  86789. export interface IDisplayChangedEventArgs {
  86790. /** Gets the vrDisplay object (if any) */
  86791. vrDisplay: Nullable<any>;
  86792. /** Gets a boolean indicating if webVR is supported */
  86793. vrSupported: boolean;
  86794. }
  86795. /**
  86796. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  86797. */
  86798. export class Engine {
  86799. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  86800. static ExceptionList: ({
  86801. key: string;
  86802. capture: string;
  86803. captureConstraint: number;
  86804. targets: string[];
  86805. } | {
  86806. key: string;
  86807. capture: null;
  86808. captureConstraint: null;
  86809. targets: string[];
  86810. })[];
  86811. /** Gets the list of created engines */
  86812. static readonly Instances: Engine[];
  86813. /**
  86814. * Gets the latest created engine
  86815. */
  86816. static readonly LastCreatedEngine: Nullable<Engine>;
  86817. /**
  86818. * Gets the latest created scene
  86819. */
  86820. static readonly LastCreatedScene: Nullable<Scene>;
  86821. /**
  86822. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  86823. * @param flag defines which part of the materials must be marked as dirty
  86824. * @param predicate defines a predicate used to filter which materials should be affected
  86825. */
  86826. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  86827. /**
  86828. * Hidden
  86829. */
  86830. static _TextureLoaders: IInternalTextureLoader[];
  86831. /** Defines that alpha blending is disabled */
  86832. static readonly ALPHA_DISABLE: number;
  86833. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  86834. static readonly ALPHA_ADD: number;
  86835. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  86836. static readonly ALPHA_COMBINE: number;
  86837. /** Defines that alpha blending to DEST - SRC * DEST */
  86838. static readonly ALPHA_SUBTRACT: number;
  86839. /** Defines that alpha blending to SRC * DEST */
  86840. static readonly ALPHA_MULTIPLY: number;
  86841. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  86842. static readonly ALPHA_MAXIMIZED: number;
  86843. /** Defines that alpha blending to SRC + DEST */
  86844. static readonly ALPHA_ONEONE: number;
  86845. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  86846. static readonly ALPHA_PREMULTIPLIED: number;
  86847. /**
  86848. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  86849. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  86850. */
  86851. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  86852. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  86853. static readonly ALPHA_INTERPOLATE: number;
  86854. /**
  86855. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  86856. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  86857. */
  86858. static readonly ALPHA_SCREENMODE: number;
  86859. /** Defines that the ressource is not delayed*/
  86860. static readonly DELAYLOADSTATE_NONE: number;
  86861. /** Defines that the ressource was successfully delay loaded */
  86862. static readonly DELAYLOADSTATE_LOADED: number;
  86863. /** Defines that the ressource is currently delay loading */
  86864. static readonly DELAYLOADSTATE_LOADING: number;
  86865. /** Defines that the ressource is delayed and has not started loading */
  86866. static readonly DELAYLOADSTATE_NOTLOADED: number;
  86867. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  86868. static readonly NEVER: number;
  86869. /** 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 */
  86870. static readonly ALWAYS: number;
  86871. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  86872. static readonly LESS: number;
  86873. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  86874. static readonly EQUAL: number;
  86875. /** 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 */
  86876. static readonly LEQUAL: number;
  86877. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  86878. static readonly GREATER: number;
  86879. /** 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 */
  86880. static readonly GEQUAL: number;
  86881. /** 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 */
  86882. static readonly NOTEQUAL: number;
  86883. /** Passed to stencilOperation to specify that stencil value must be kept */
  86884. static readonly KEEP: number;
  86885. /** Passed to stencilOperation to specify that stencil value must be replaced */
  86886. static readonly REPLACE: number;
  86887. /** Passed to stencilOperation to specify that stencil value must be incremented */
  86888. static readonly INCR: number;
  86889. /** Passed to stencilOperation to specify that stencil value must be decremented */
  86890. static readonly DECR: number;
  86891. /** Passed to stencilOperation to specify that stencil value must be inverted */
  86892. static readonly INVERT: number;
  86893. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  86894. static readonly INCR_WRAP: number;
  86895. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  86896. static readonly DECR_WRAP: number;
  86897. /** Texture is not repeating outside of 0..1 UVs */
  86898. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  86899. /** Texture is repeating outside of 0..1 UVs */
  86900. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  86901. /** Texture is repeating and mirrored */
  86902. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  86903. /** ALPHA */
  86904. static readonly TEXTUREFORMAT_ALPHA: number;
  86905. /** LUMINANCE */
  86906. static readonly TEXTUREFORMAT_LUMINANCE: number;
  86907. /** LUMINANCE_ALPHA */
  86908. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  86909. /** RGB */
  86910. static readonly TEXTUREFORMAT_RGB: number;
  86911. /** RGBA */
  86912. static readonly TEXTUREFORMAT_RGBA: number;
  86913. /** RED */
  86914. static readonly TEXTUREFORMAT_RED: number;
  86915. /** RED (2nd reference) */
  86916. static readonly TEXTUREFORMAT_R: number;
  86917. /** RG */
  86918. static readonly TEXTUREFORMAT_RG: number;
  86919. /** RED_INTEGER */
  86920. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  86921. /** RED_INTEGER (2nd reference) */
  86922. static readonly TEXTUREFORMAT_R_INTEGER: number;
  86923. /** RG_INTEGER */
  86924. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  86925. /** RGB_INTEGER */
  86926. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  86927. /** RGBA_INTEGER */
  86928. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  86929. /** UNSIGNED_BYTE */
  86930. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  86931. /** UNSIGNED_BYTE (2nd reference) */
  86932. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  86933. /** FLOAT */
  86934. static readonly TEXTURETYPE_FLOAT: number;
  86935. /** HALF_FLOAT */
  86936. static readonly TEXTURETYPE_HALF_FLOAT: number;
  86937. /** BYTE */
  86938. static readonly TEXTURETYPE_BYTE: number;
  86939. /** SHORT */
  86940. static readonly TEXTURETYPE_SHORT: number;
  86941. /** UNSIGNED_SHORT */
  86942. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  86943. /** INT */
  86944. static readonly TEXTURETYPE_INT: number;
  86945. /** UNSIGNED_INT */
  86946. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  86947. /** UNSIGNED_SHORT_4_4_4_4 */
  86948. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  86949. /** UNSIGNED_SHORT_5_5_5_1 */
  86950. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  86951. /** UNSIGNED_SHORT_5_6_5 */
  86952. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  86953. /** UNSIGNED_INT_2_10_10_10_REV */
  86954. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  86955. /** UNSIGNED_INT_24_8 */
  86956. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  86957. /** UNSIGNED_INT_10F_11F_11F_REV */
  86958. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  86959. /** UNSIGNED_INT_5_9_9_9_REV */
  86960. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  86961. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  86962. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  86963. /** nearest is mag = nearest and min = nearest and mip = linear */
  86964. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  86965. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86966. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  86967. /** Trilinear is mag = linear and min = linear and mip = linear */
  86968. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  86969. /** nearest is mag = nearest and min = nearest and mip = linear */
  86970. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  86971. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86972. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  86973. /** Trilinear is mag = linear and min = linear and mip = linear */
  86974. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  86975. /** mag = nearest and min = nearest and mip = nearest */
  86976. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  86977. /** mag = nearest and min = linear and mip = nearest */
  86978. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  86979. /** mag = nearest and min = linear and mip = linear */
  86980. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  86981. /** mag = nearest and min = linear and mip = none */
  86982. static readonly TEXTURE_NEAREST_LINEAR: number;
  86983. /** mag = nearest and min = nearest and mip = none */
  86984. static readonly TEXTURE_NEAREST_NEAREST: number;
  86985. /** mag = linear and min = nearest and mip = nearest */
  86986. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  86987. /** mag = linear and min = nearest and mip = linear */
  86988. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  86989. /** mag = linear and min = linear and mip = none */
  86990. static readonly TEXTURE_LINEAR_LINEAR: number;
  86991. /** mag = linear and min = nearest and mip = none */
  86992. static readonly TEXTURE_LINEAR_NEAREST: number;
  86993. /** Explicit coordinates mode */
  86994. static readonly TEXTURE_EXPLICIT_MODE: number;
  86995. /** Spherical coordinates mode */
  86996. static readonly TEXTURE_SPHERICAL_MODE: number;
  86997. /** Planar coordinates mode */
  86998. static readonly TEXTURE_PLANAR_MODE: number;
  86999. /** Cubic coordinates mode */
  87000. static readonly TEXTURE_CUBIC_MODE: number;
  87001. /** Projection coordinates mode */
  87002. static readonly TEXTURE_PROJECTION_MODE: number;
  87003. /** Skybox coordinates mode */
  87004. static readonly TEXTURE_SKYBOX_MODE: number;
  87005. /** Inverse Cubic coordinates mode */
  87006. static readonly TEXTURE_INVCUBIC_MODE: number;
  87007. /** Equirectangular coordinates mode */
  87008. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  87009. /** Equirectangular Fixed coordinates mode */
  87010. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  87011. /** Equirectangular Fixed Mirrored coordinates mode */
  87012. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  87013. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  87014. static readonly SCALEMODE_FLOOR: number;
  87015. /** Defines that texture rescaling will look for the nearest power of 2 size */
  87016. static readonly SCALEMODE_NEAREST: number;
  87017. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  87018. static readonly SCALEMODE_CEILING: number;
  87019. /**
  87020. * Returns the current npm package of the sdk
  87021. */
  87022. static readonly NpmPackage: string;
  87023. /**
  87024. * Returns the current version of the framework
  87025. */
  87026. static readonly Version: string;
  87027. /**
  87028. * Returns a string describing the current engine
  87029. */
  87030. readonly description: string;
  87031. /**
  87032. * Gets or sets the epsilon value used by collision engine
  87033. */
  87034. static CollisionsEpsilon: number;
  87035. /**
  87036. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  87037. */
  87038. static ShadersRepository: string;
  87039. /**
  87040. * Method called to create the default loading screen.
  87041. * This can be overriden in your own app.
  87042. * @param canvas The rendering canvas element
  87043. * @returns The loading screen
  87044. */
  87045. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  87046. /**
  87047. * Method called to create the default rescale post process on each engine.
  87048. */
  87049. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  87050. /**
  87051. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  87052. */
  87053. forcePOTTextures: boolean;
  87054. /**
  87055. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  87056. */
  87057. isFullscreen: boolean;
  87058. /**
  87059. * Gets a boolean indicating if the pointer is currently locked
  87060. */
  87061. isPointerLock: boolean;
  87062. /**
  87063. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  87064. */
  87065. cullBackFaces: boolean;
  87066. /**
  87067. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  87068. */
  87069. renderEvenInBackground: boolean;
  87070. /**
  87071. * Gets or sets a boolean indicating that cache can be kept between frames
  87072. */
  87073. preventCacheWipeBetweenFrames: boolean;
  87074. /**
  87075. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  87076. **/
  87077. enableOfflineSupport: boolean;
  87078. /**
  87079. * 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)
  87080. **/
  87081. disableManifestCheck: boolean;
  87082. /**
  87083. * Gets the list of created scenes
  87084. */
  87085. scenes: Scene[];
  87086. /**
  87087. * Event raised when a new scene is created
  87088. */
  87089. onNewSceneAddedObservable: Observable<Scene>;
  87090. /**
  87091. * Gets the list of created postprocesses
  87092. */
  87093. postProcesses: PostProcess[];
  87094. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  87095. validateShaderPrograms: boolean;
  87096. /**
  87097. * Observable event triggered each time the rendering canvas is resized
  87098. */
  87099. onResizeObservable: Observable<Engine>;
  87100. /**
  87101. * Observable event triggered each time the canvas loses focus
  87102. */
  87103. onCanvasBlurObservable: Observable<Engine>;
  87104. /**
  87105. * Observable event triggered each time the canvas gains focus
  87106. */
  87107. onCanvasFocusObservable: Observable<Engine>;
  87108. /**
  87109. * Observable event triggered each time the canvas receives pointerout event
  87110. */
  87111. onCanvasPointerOutObservable: Observable<PointerEvent>;
  87112. /**
  87113. * Observable event triggered before each texture is initialized
  87114. */
  87115. onBeforeTextureInitObservable: Observable<Texture>;
  87116. private _vrDisplay;
  87117. private _vrSupported;
  87118. private _oldSize;
  87119. private _oldHardwareScaleFactor;
  87120. private _vrExclusivePointerMode;
  87121. private _webVRInitPromise;
  87122. /**
  87123. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  87124. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  87125. */
  87126. readonly isInVRExclusivePointerMode: boolean;
  87127. /**
  87128. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  87129. */
  87130. disableUniformBuffers: boolean;
  87131. /** @hidden */
  87132. _uniformBuffers: UniformBuffer[];
  87133. /**
  87134. * Gets a boolean indicating that the engine supports uniform buffers
  87135. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87136. */
  87137. readonly supportsUniformBuffers: boolean;
  87138. /**
  87139. * Observable raised when the engine begins a new frame
  87140. */
  87141. onBeginFrameObservable: Observable<Engine>;
  87142. /**
  87143. * If set, will be used to request the next animation frame for the render loop
  87144. */
  87145. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  87146. /**
  87147. * Observable raised when the engine ends the current frame
  87148. */
  87149. onEndFrameObservable: Observable<Engine>;
  87150. /**
  87151. * Observable raised when the engine is about to compile a shader
  87152. */
  87153. onBeforeShaderCompilationObservable: Observable<Engine>;
  87154. /**
  87155. * Observable raised when the engine has jsut compiled a shader
  87156. */
  87157. onAfterShaderCompilationObservable: Observable<Engine>;
  87158. /** @hidden */
  87159. _gl: WebGLRenderingContext;
  87160. private _renderingCanvas;
  87161. private _windowIsBackground;
  87162. private _webGLVersion;
  87163. protected _highPrecisionShadersAllowed: boolean;
  87164. /** @hidden */
  87165. readonly _shouldUseHighPrecisionShader: boolean;
  87166. /**
  87167. * Gets a boolean indicating that only power of 2 textures are supported
  87168. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  87169. */
  87170. readonly needPOTTextures: boolean;
  87171. /** @hidden */
  87172. _badOS: boolean;
  87173. /** @hidden */
  87174. _badDesktopOS: boolean;
  87175. /**
  87176. * Gets the audio engine
  87177. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  87178. * @ignorenaming
  87179. */
  87180. static audioEngine: IAudioEngine;
  87181. /**
  87182. * Default AudioEngine factory responsible of creating the Audio Engine.
  87183. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  87184. */
  87185. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  87186. /**
  87187. * Default offline support factory responsible of creating a tool used to store data locally.
  87188. * By default, this will create a Database object if the workload has been embedded.
  87189. */
  87190. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  87191. private _onFocus;
  87192. private _onBlur;
  87193. private _onCanvasPointerOut;
  87194. private _onCanvasBlur;
  87195. private _onCanvasFocus;
  87196. private _onFullscreenChange;
  87197. private _onPointerLockChange;
  87198. private _onVRDisplayPointerRestricted;
  87199. private _onVRDisplayPointerUnrestricted;
  87200. private _onVrDisplayConnect;
  87201. private _onVrDisplayDisconnect;
  87202. private _onVrDisplayPresentChange;
  87203. /**
  87204. * Observable signaled when VR display mode changes
  87205. */
  87206. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  87207. /**
  87208. * Observable signaled when VR request present is complete
  87209. */
  87210. onVRRequestPresentComplete: Observable<boolean>;
  87211. /**
  87212. * Observable signaled when VR request present starts
  87213. */
  87214. onVRRequestPresentStart: Observable<Engine>;
  87215. private _hardwareScalingLevel;
  87216. /** @hidden */
  87217. _caps: EngineCapabilities;
  87218. private _pointerLockRequested;
  87219. private _isStencilEnable;
  87220. private _colorWrite;
  87221. private _loadingScreen;
  87222. /** @hidden */
  87223. _drawCalls: PerfCounter;
  87224. private _glVersion;
  87225. private _glRenderer;
  87226. private _glVendor;
  87227. private _videoTextureSupported;
  87228. private _renderingQueueLaunched;
  87229. private _activeRenderLoops;
  87230. private _deterministicLockstep;
  87231. private _lockstepMaxSteps;
  87232. /**
  87233. * Observable signaled when a context lost event is raised
  87234. */
  87235. onContextLostObservable: Observable<Engine>;
  87236. /**
  87237. * Observable signaled when a context restored event is raised
  87238. */
  87239. onContextRestoredObservable: Observable<Engine>;
  87240. private _onContextLost;
  87241. private _onContextRestored;
  87242. private _contextWasLost;
  87243. /** @hidden */
  87244. _doNotHandleContextLost: boolean;
  87245. /**
  87246. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  87247. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  87248. */
  87249. doNotHandleContextLost: boolean;
  87250. private _performanceMonitor;
  87251. private _fps;
  87252. private _deltaTime;
  87253. /**
  87254. * Turn this value on if you want to pause FPS computation when in background
  87255. */
  87256. disablePerformanceMonitorInBackground: boolean;
  87257. /**
  87258. * Gets the performance monitor attached to this engine
  87259. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  87260. */
  87261. readonly performanceMonitor: PerformanceMonitor;
  87262. /**
  87263. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  87264. */
  87265. disableVertexArrayObjects: boolean;
  87266. /** @hidden */
  87267. protected _depthCullingState: _DepthCullingState;
  87268. /** @hidden */
  87269. protected _stencilState: _StencilState;
  87270. /** @hidden */
  87271. protected _alphaState: _AlphaState;
  87272. /** @hidden */
  87273. protected _alphaMode: number;
  87274. /** @hidden */
  87275. _internalTexturesCache: InternalTexture[];
  87276. /** @hidden */
  87277. protected _activeChannel: number;
  87278. private _currentTextureChannel;
  87279. /** @hidden */
  87280. protected _boundTexturesCache: {
  87281. [key: string]: Nullable<InternalTexture>;
  87282. };
  87283. /** @hidden */
  87284. protected _currentEffect: Nullable<Effect>;
  87285. /** @hidden */
  87286. protected _currentProgram: Nullable<WebGLProgram>;
  87287. private _compiledEffects;
  87288. private _vertexAttribArraysEnabled;
  87289. /** @hidden */
  87290. protected _cachedViewport: Nullable<Viewport>;
  87291. private _cachedVertexArrayObject;
  87292. /** @hidden */
  87293. protected _cachedVertexBuffers: any;
  87294. /** @hidden */
  87295. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  87296. /** @hidden */
  87297. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  87298. /** @hidden */
  87299. _currentRenderTarget: Nullable<InternalTexture>;
  87300. private _uintIndicesCurrentlySet;
  87301. private _currentBoundBuffer;
  87302. /** @hidden */
  87303. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  87304. private _currentBufferPointers;
  87305. private _currentInstanceLocations;
  87306. private _currentInstanceBuffers;
  87307. private _textureUnits;
  87308. /** @hidden */
  87309. _workingCanvas: Nullable<HTMLCanvasElement>;
  87310. /** @hidden */
  87311. _workingContext: Nullable<CanvasRenderingContext2D>;
  87312. private _rescalePostProcess;
  87313. private _dummyFramebuffer;
  87314. private _externalData;
  87315. private _bindedRenderFunction;
  87316. private _vaoRecordInProgress;
  87317. private _mustWipeVertexAttributes;
  87318. private _emptyTexture;
  87319. private _emptyCubeTexture;
  87320. private _emptyTexture3D;
  87321. /** @hidden */
  87322. _frameHandler: number;
  87323. private _nextFreeTextureSlots;
  87324. private _maxSimultaneousTextures;
  87325. private _activeRequests;
  87326. private _texturesSupported;
  87327. /** @hidden */
  87328. _textureFormatInUse: Nullable<string>;
  87329. /**
  87330. * Gets the list of texture formats supported
  87331. */
  87332. readonly texturesSupported: Array<string>;
  87333. /**
  87334. * Gets the list of texture formats in use
  87335. */
  87336. readonly textureFormatInUse: Nullable<string>;
  87337. /**
  87338. * Gets the current viewport
  87339. */
  87340. readonly currentViewport: Nullable<Viewport>;
  87341. /**
  87342. * Gets the default empty texture
  87343. */
  87344. readonly emptyTexture: InternalTexture;
  87345. /**
  87346. * Gets the default empty 3D texture
  87347. */
  87348. readonly emptyTexture3D: InternalTexture;
  87349. /**
  87350. * Gets the default empty cube texture
  87351. */
  87352. readonly emptyCubeTexture: InternalTexture;
  87353. /**
  87354. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  87355. */
  87356. readonly premultipliedAlpha: boolean;
  87357. /**
  87358. * Creates a new engine
  87359. * @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
  87360. * @param antialias defines enable antialiasing (default: false)
  87361. * @param options defines further options to be sent to the getContext() function
  87362. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  87363. */
  87364. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  87365. private _disableTouchAction;
  87366. private _rebuildInternalTextures;
  87367. private _rebuildEffects;
  87368. /**
  87369. * Gets a boolean indicating if all created effects are ready
  87370. * @returns true if all effects are ready
  87371. */
  87372. areAllEffectsReady(): boolean;
  87373. private _rebuildBuffers;
  87374. private _initGLContext;
  87375. /**
  87376. * Gets version of the current webGL context
  87377. */
  87378. readonly webGLVersion: number;
  87379. /**
  87380. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  87381. */
  87382. readonly isStencilEnable: boolean;
  87383. /** @hidden */
  87384. _prepareWorkingCanvas(): void;
  87385. /**
  87386. * Reset the texture cache to empty state
  87387. */
  87388. resetTextureCache(): void;
  87389. /**
  87390. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  87391. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87392. * @returns true if engine is in deterministic lock step mode
  87393. */
  87394. isDeterministicLockStep(): boolean;
  87395. /**
  87396. * Gets the max steps when engine is running in deterministic lock step
  87397. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87398. * @returns the max steps
  87399. */
  87400. getLockstepMaxSteps(): number;
  87401. /**
  87402. * Gets an object containing information about the current webGL context
  87403. * @returns an object containing the vender, the renderer and the version of the current webGL context
  87404. */
  87405. getGlInfo(): {
  87406. vendor: string;
  87407. renderer: string;
  87408. version: string;
  87409. };
  87410. /**
  87411. * Gets current aspect ratio
  87412. * @param camera defines the camera to use to get the aspect ratio
  87413. * @param useScreen defines if screen size must be used (or the current render target if any)
  87414. * @returns a number defining the aspect ratio
  87415. */
  87416. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  87417. /**
  87418. * Gets current screen aspect ratio
  87419. * @returns a number defining the aspect ratio
  87420. */
  87421. getScreenAspectRatio(): number;
  87422. /**
  87423. * Gets the current render width
  87424. * @param useScreen defines if screen size must be used (or the current render target if any)
  87425. * @returns a number defining the current render width
  87426. */
  87427. getRenderWidth(useScreen?: boolean): number;
  87428. /**
  87429. * Gets the current render height
  87430. * @param useScreen defines if screen size must be used (or the current render target if any)
  87431. * @returns a number defining the current render height
  87432. */
  87433. getRenderHeight(useScreen?: boolean): number;
  87434. /**
  87435. * Gets the HTML canvas attached with the current webGL context
  87436. * @returns a HTML canvas
  87437. */
  87438. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  87439. /**
  87440. * Gets the client rect of the HTML canvas attached with the current webGL context
  87441. * @returns a client rectanglee
  87442. */
  87443. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  87444. /**
  87445. * Defines the hardware scaling level.
  87446. * By default the hardware scaling level is computed from the window device ratio.
  87447. * 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.
  87448. * @param level defines the level to use
  87449. */
  87450. setHardwareScalingLevel(level: number): void;
  87451. /**
  87452. * Gets the current hardware scaling level.
  87453. * By default the hardware scaling level is computed from the window device ratio.
  87454. * 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.
  87455. * @returns a number indicating the current hardware scaling level
  87456. */
  87457. getHardwareScalingLevel(): number;
  87458. /**
  87459. * Gets the list of loaded textures
  87460. * @returns an array containing all loaded textures
  87461. */
  87462. getLoadedTexturesCache(): InternalTexture[];
  87463. /**
  87464. * Gets the object containing all engine capabilities
  87465. * @returns the EngineCapabilities object
  87466. */
  87467. getCaps(): EngineCapabilities;
  87468. /**
  87469. * Gets the current depth function
  87470. * @returns a number defining the depth function
  87471. */
  87472. getDepthFunction(): Nullable<number>;
  87473. /**
  87474. * Sets the current depth function
  87475. * @param depthFunc defines the function to use
  87476. */
  87477. setDepthFunction(depthFunc: number): void;
  87478. /**
  87479. * Sets the current depth function to GREATER
  87480. */
  87481. setDepthFunctionToGreater(): void;
  87482. /**
  87483. * Sets the current depth function to GEQUAL
  87484. */
  87485. setDepthFunctionToGreaterOrEqual(): void;
  87486. /**
  87487. * Sets the current depth function to LESS
  87488. */
  87489. setDepthFunctionToLess(): void;
  87490. private _cachedStencilBuffer;
  87491. private _cachedStencilFunction;
  87492. private _cachedStencilMask;
  87493. private _cachedStencilOperationPass;
  87494. private _cachedStencilOperationFail;
  87495. private _cachedStencilOperationDepthFail;
  87496. private _cachedStencilReference;
  87497. /**
  87498. * Caches the the state of the stencil buffer
  87499. */
  87500. cacheStencilState(): void;
  87501. /**
  87502. * Restores the state of the stencil buffer
  87503. */
  87504. restoreStencilState(): void;
  87505. /**
  87506. * Sets the current depth function to LEQUAL
  87507. */
  87508. setDepthFunctionToLessOrEqual(): void;
  87509. /**
  87510. * Gets a boolean indicating if stencil buffer is enabled
  87511. * @returns the current stencil buffer state
  87512. */
  87513. getStencilBuffer(): boolean;
  87514. /**
  87515. * Enable or disable the stencil buffer
  87516. * @param enable defines if the stencil buffer must be enabled or disabled
  87517. */
  87518. setStencilBuffer(enable: boolean): void;
  87519. /**
  87520. * Gets the current stencil mask
  87521. * @returns a number defining the new stencil mask to use
  87522. */
  87523. getStencilMask(): number;
  87524. /**
  87525. * Sets the current stencil mask
  87526. * @param mask defines the new stencil mask to use
  87527. */
  87528. setStencilMask(mask: number): void;
  87529. /**
  87530. * Gets the current stencil function
  87531. * @returns a number defining the stencil function to use
  87532. */
  87533. getStencilFunction(): number;
  87534. /**
  87535. * Gets the current stencil reference value
  87536. * @returns a number defining the stencil reference value to use
  87537. */
  87538. getStencilFunctionReference(): number;
  87539. /**
  87540. * Gets the current stencil mask
  87541. * @returns a number defining the stencil mask to use
  87542. */
  87543. getStencilFunctionMask(): number;
  87544. /**
  87545. * Sets the current stencil function
  87546. * @param stencilFunc defines the new stencil function to use
  87547. */
  87548. setStencilFunction(stencilFunc: number): void;
  87549. /**
  87550. * Sets the current stencil reference
  87551. * @param reference defines the new stencil reference to use
  87552. */
  87553. setStencilFunctionReference(reference: number): void;
  87554. /**
  87555. * Sets the current stencil mask
  87556. * @param mask defines the new stencil mask to use
  87557. */
  87558. setStencilFunctionMask(mask: number): void;
  87559. /**
  87560. * Gets the current stencil operation when stencil fails
  87561. * @returns a number defining stencil operation to use when stencil fails
  87562. */
  87563. getStencilOperationFail(): number;
  87564. /**
  87565. * Gets the current stencil operation when depth fails
  87566. * @returns a number defining stencil operation to use when depth fails
  87567. */
  87568. getStencilOperationDepthFail(): number;
  87569. /**
  87570. * Gets the current stencil operation when stencil passes
  87571. * @returns a number defining stencil operation to use when stencil passes
  87572. */
  87573. getStencilOperationPass(): number;
  87574. /**
  87575. * Sets the stencil operation to use when stencil fails
  87576. * @param operation defines the stencil operation to use when stencil fails
  87577. */
  87578. setStencilOperationFail(operation: number): void;
  87579. /**
  87580. * Sets the stencil operation to use when depth fails
  87581. * @param operation defines the stencil operation to use when depth fails
  87582. */
  87583. setStencilOperationDepthFail(operation: number): void;
  87584. /**
  87585. * Sets the stencil operation to use when stencil passes
  87586. * @param operation defines the stencil operation to use when stencil passes
  87587. */
  87588. setStencilOperationPass(operation: number): void;
  87589. /**
  87590. * Sets a boolean indicating if the dithering state is enabled or disabled
  87591. * @param value defines the dithering state
  87592. */
  87593. setDitheringState(value: boolean): void;
  87594. /**
  87595. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  87596. * @param value defines the rasterizer state
  87597. */
  87598. setRasterizerState(value: boolean): void;
  87599. /**
  87600. * stop executing a render loop function and remove it from the execution array
  87601. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  87602. */
  87603. stopRenderLoop(renderFunction?: () => void): void;
  87604. /** @hidden */
  87605. _renderLoop(): void;
  87606. /**
  87607. * Register and execute a render loop. The engine can have more than one render function
  87608. * @param renderFunction defines the function to continuously execute
  87609. */
  87610. runRenderLoop(renderFunction: () => void): void;
  87611. /**
  87612. * Toggle full screen mode
  87613. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87614. */
  87615. switchFullscreen(requestPointerLock: boolean): void;
  87616. /**
  87617. * Enters full screen mode
  87618. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87619. */
  87620. enterFullscreen(requestPointerLock: boolean): void;
  87621. /**
  87622. * Exits full screen mode
  87623. */
  87624. exitFullscreen(): void;
  87625. /**
  87626. * Clear the current render buffer or the current render target (if any is set up)
  87627. * @param color defines the color to use
  87628. * @param backBuffer defines if the back buffer must be cleared
  87629. * @param depth defines if the depth buffer must be cleared
  87630. * @param stencil defines if the stencil buffer must be cleared
  87631. */
  87632. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  87633. /**
  87634. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  87635. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87636. * @param y defines the y-coordinate of the corner of the clear rectangle
  87637. * @param width defines the width of the clear rectangle
  87638. * @param height defines the height of the clear rectangle
  87639. * @param clearColor defines the clear color
  87640. */
  87641. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  87642. /**
  87643. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  87644. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87645. * @param y defines the y-coordinate of the corner of the clear rectangle
  87646. * @param width defines the width of the clear rectangle
  87647. * @param height defines the height of the clear rectangle
  87648. */
  87649. enableScissor(x: number, y: number, width: number, height: number): void;
  87650. /**
  87651. * Disable previously set scissor test rectangle
  87652. */
  87653. disableScissor(): void;
  87654. private _viewportCached;
  87655. /** @hidden */
  87656. _viewport(x: number, y: number, width: number, height: number): void;
  87657. /**
  87658. * Set the WebGL's viewport
  87659. * @param viewport defines the viewport element to be used
  87660. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  87661. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  87662. */
  87663. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  87664. /**
  87665. * Directly set the WebGL Viewport
  87666. * @param x defines the x coordinate of the viewport (in screen space)
  87667. * @param y defines the y coordinate of the viewport (in screen space)
  87668. * @param width defines the width of the viewport (in screen space)
  87669. * @param height defines the height of the viewport (in screen space)
  87670. * @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
  87671. */
  87672. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  87673. /**
  87674. * Begin a new frame
  87675. */
  87676. beginFrame(): void;
  87677. /**
  87678. * Enf the current frame
  87679. */
  87680. endFrame(): void;
  87681. /**
  87682. * Resize the view according to the canvas' size
  87683. */
  87684. resize(): void;
  87685. /**
  87686. * Force a specific size of the canvas
  87687. * @param width defines the new canvas' width
  87688. * @param height defines the new canvas' height
  87689. */
  87690. setSize(width: number, height: number): void;
  87691. /**
  87692. * Gets a boolean indicating if a webVR device was detected
  87693. * @returns true if a webVR device was detected
  87694. */
  87695. isVRDevicePresent(): boolean;
  87696. /**
  87697. * Gets the current webVR device
  87698. * @returns the current webVR device (or null)
  87699. */
  87700. getVRDevice(): any;
  87701. /**
  87702. * Initializes a webVR display and starts listening to display change events
  87703. * The onVRDisplayChangedObservable will be notified upon these changes
  87704. * @returns The onVRDisplayChangedObservable
  87705. */
  87706. initWebVR(): Observable<IDisplayChangedEventArgs>;
  87707. /**
  87708. * Initializes a webVR display and starts listening to display change events
  87709. * The onVRDisplayChangedObservable will be notified upon these changes
  87710. * @returns A promise containing a VRDisplay and if vr is supported
  87711. */
  87712. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  87713. /**
  87714. * Call this function to switch to webVR mode
  87715. * Will do nothing if webVR is not supported or if there is no webVR device
  87716. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87717. */
  87718. enableVR(): void;
  87719. /**
  87720. * Call this function to leave webVR mode
  87721. * Will do nothing if webVR is not supported or if there is no webVR device
  87722. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87723. */
  87724. disableVR(): void;
  87725. private _onVRFullScreenTriggered;
  87726. private _getVRDisplaysAsync;
  87727. /**
  87728. * Binds the frame buffer to the specified texture.
  87729. * @param texture The texture to render to or null for the default canvas
  87730. * @param faceIndex The face of the texture to render to in case of cube texture
  87731. * @param requiredWidth The width of the target to render to
  87732. * @param requiredHeight The height of the target to render to
  87733. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  87734. * @param depthStencilTexture The depth stencil texture to use to render
  87735. * @param lodLevel defines le lod level to bind to the frame buffer
  87736. */
  87737. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  87738. /** @hidden */
  87739. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  87740. /**
  87741. * Unbind the current render target texture from the webGL context
  87742. * @param texture defines the render target texture to unbind
  87743. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  87744. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  87745. */
  87746. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  87747. /**
  87748. * Force the mipmap generation for the given render target texture
  87749. * @param texture defines the render target texture to use
  87750. */
  87751. generateMipMapsForCubemap(texture: InternalTexture): void;
  87752. /**
  87753. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  87754. */
  87755. flushFramebuffer(): void;
  87756. /**
  87757. * Unbind the current render target and bind the default framebuffer
  87758. */
  87759. restoreDefaultFramebuffer(): void;
  87760. /**
  87761. * Create an uniform buffer
  87762. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87763. * @param elements defines the content of the uniform buffer
  87764. * @returns the webGL uniform buffer
  87765. */
  87766. createUniformBuffer(elements: FloatArray): DataBuffer;
  87767. /**
  87768. * Create a dynamic uniform buffer
  87769. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87770. * @param elements defines the content of the uniform buffer
  87771. * @returns the webGL uniform buffer
  87772. */
  87773. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  87774. /**
  87775. * Update an existing uniform buffer
  87776. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87777. * @param uniformBuffer defines the target uniform buffer
  87778. * @param elements defines the content to update
  87779. * @param offset defines the offset in the uniform buffer where update should start
  87780. * @param count defines the size of the data to update
  87781. */
  87782. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  87783. private _resetVertexBufferBinding;
  87784. /**
  87785. * Creates a vertex buffer
  87786. * @param data the data for the vertex buffer
  87787. * @returns the new WebGL static buffer
  87788. */
  87789. createVertexBuffer(data: DataArray): DataBuffer;
  87790. /**
  87791. * Creates a dynamic vertex buffer
  87792. * @param data the data for the dynamic vertex buffer
  87793. * @returns the new WebGL dynamic buffer
  87794. */
  87795. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  87796. /**
  87797. * Update a dynamic index buffer
  87798. * @param indexBuffer defines the target index buffer
  87799. * @param indices defines the data to update
  87800. * @param offset defines the offset in the target index buffer where update should start
  87801. */
  87802. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  87803. /**
  87804. * Updates a dynamic vertex buffer.
  87805. * @param vertexBuffer the vertex buffer to update
  87806. * @param data the data used to update the vertex buffer
  87807. * @param byteOffset the byte offset of the data
  87808. * @param byteLength the byte length of the data
  87809. */
  87810. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  87811. private _resetIndexBufferBinding;
  87812. /**
  87813. * Creates a new index buffer
  87814. * @param indices defines the content of the index buffer
  87815. * @param updatable defines if the index buffer must be updatable
  87816. * @returns a new webGL buffer
  87817. */
  87818. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  87819. /**
  87820. * Bind a webGL buffer to the webGL context
  87821. * @param buffer defines the buffer to bind
  87822. */
  87823. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  87824. /**
  87825. * Bind an uniform buffer to the current webGL context
  87826. * @param buffer defines the buffer to bind
  87827. */
  87828. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  87829. /**
  87830. * Bind a buffer to the current webGL context at a given location
  87831. * @param buffer defines the buffer to bind
  87832. * @param location defines the index where to bind the buffer
  87833. */
  87834. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  87835. /**
  87836. * Bind a specific block at a given index in a specific shader program
  87837. * @param pipelineContext defines the pipeline context to use
  87838. * @param blockName defines the block name
  87839. * @param index defines the index where to bind the block
  87840. */
  87841. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  87842. private bindIndexBuffer;
  87843. private bindBuffer;
  87844. /**
  87845. * update the bound buffer with the given data
  87846. * @param data defines the data to update
  87847. */
  87848. updateArrayBuffer(data: Float32Array): void;
  87849. private _vertexAttribPointer;
  87850. private _bindIndexBufferWithCache;
  87851. private _bindVertexBuffersAttributes;
  87852. /**
  87853. * Records a vertex array object
  87854. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  87855. * @param vertexBuffers defines the list of vertex buffers to store
  87856. * @param indexBuffer defines the index buffer to store
  87857. * @param effect defines the effect to store
  87858. * @returns the new vertex array object
  87859. */
  87860. recordVertexArrayObject(vertexBuffers: {
  87861. [key: string]: VertexBuffer;
  87862. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  87863. /**
  87864. * Bind a specific vertex array object
  87865. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  87866. * @param vertexArrayObject defines the vertex array object to bind
  87867. * @param indexBuffer defines the index buffer to bind
  87868. */
  87869. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  87870. /**
  87871. * Bind webGl buffers directly to the webGL context
  87872. * @param vertexBuffer defines the vertex buffer to bind
  87873. * @param indexBuffer defines the index buffer to bind
  87874. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  87875. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  87876. * @param effect defines the effect associated with the vertex buffer
  87877. */
  87878. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  87879. private _unbindVertexArrayObject;
  87880. /**
  87881. * Bind a list of vertex buffers to the webGL context
  87882. * @param vertexBuffers defines the list of vertex buffers to bind
  87883. * @param indexBuffer defines the index buffer to bind
  87884. * @param effect defines the effect associated with the vertex buffers
  87885. */
  87886. bindBuffers(vertexBuffers: {
  87887. [key: string]: Nullable<VertexBuffer>;
  87888. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  87889. /**
  87890. * Unbind all instance attributes
  87891. */
  87892. unbindInstanceAttributes(): void;
  87893. /**
  87894. * Release and free the memory of a vertex array object
  87895. * @param vao defines the vertex array object to delete
  87896. */
  87897. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  87898. /** @hidden */
  87899. _releaseBuffer(buffer: DataBuffer): boolean;
  87900. /**
  87901. * Creates a webGL buffer to use with instanciation
  87902. * @param capacity defines the size of the buffer
  87903. * @returns the webGL buffer
  87904. */
  87905. createInstancesBuffer(capacity: number): DataBuffer;
  87906. /**
  87907. * Delete a webGL buffer used with instanciation
  87908. * @param buffer defines the webGL buffer to delete
  87909. */
  87910. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  87911. /**
  87912. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  87913. * @param instancesBuffer defines the webGL buffer to update and bind
  87914. * @param data defines the data to store in the buffer
  87915. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  87916. */
  87917. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  87918. /**
  87919. * Apply all cached states (depth, culling, stencil and alpha)
  87920. */
  87921. applyStates(): void;
  87922. /**
  87923. * Send a draw order
  87924. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  87925. * @param indexStart defines the starting index
  87926. * @param indexCount defines the number of index to draw
  87927. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87928. */
  87929. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  87930. /**
  87931. * Draw a list of points
  87932. * @param verticesStart defines the index of first vertex to draw
  87933. * @param verticesCount defines the count of vertices to draw
  87934. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87935. */
  87936. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87937. /**
  87938. * Draw a list of unindexed primitives
  87939. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  87940. * @param verticesStart defines the index of first vertex to draw
  87941. * @param verticesCount defines the count of vertices to draw
  87942. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87943. */
  87944. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87945. /**
  87946. * Draw a list of indexed primitives
  87947. * @param fillMode defines the primitive to use
  87948. * @param indexStart defines the starting index
  87949. * @param indexCount defines the number of index to draw
  87950. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87951. */
  87952. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  87953. /**
  87954. * Draw a list of unindexed primitives
  87955. * @param fillMode defines the primitive to use
  87956. * @param verticesStart defines the index of first vertex to draw
  87957. * @param verticesCount defines the count of vertices to draw
  87958. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87959. */
  87960. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87961. private _drawMode;
  87962. /** @hidden */
  87963. _releaseEffect(effect: Effect): void;
  87964. /** @hidden */
  87965. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  87966. /**
  87967. * Create a new effect (used to store vertex/fragment shaders)
  87968. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  87969. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  87970. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  87971. * @param samplers defines an array of string used to represent textures
  87972. * @param defines defines the string containing the defines to use to compile the shaders
  87973. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  87974. * @param onCompiled defines a function to call when the effect creation is successful
  87975. * @param onError defines a function to call when the effect creation has failed
  87976. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  87977. * @returns the new Effect
  87978. */
  87979. 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;
  87980. private _compileShader;
  87981. private _compileRawShader;
  87982. /**
  87983. * Directly creates a webGL program
  87984. * @param pipelineContext defines the pipeline context to attach to
  87985. * @param vertexCode defines the vertex shader code to use
  87986. * @param fragmentCode defines the fragment shader code to use
  87987. * @param context defines the webGL context to use (if not set, the current one will be used)
  87988. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  87989. * @returns the new webGL program
  87990. */
  87991. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  87992. /**
  87993. * Creates a webGL program
  87994. * @param pipelineContext defines the pipeline context to attach to
  87995. * @param vertexCode defines the vertex shader code to use
  87996. * @param fragmentCode defines the fragment shader code to use
  87997. * @param defines defines the string containing the defines to use to compile the shaders
  87998. * @param context defines the webGL context to use (if not set, the current one will be used)
  87999. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  88000. * @returns the new webGL program
  88001. */
  88002. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  88003. /**
  88004. * Creates a new pipeline context
  88005. * @returns the new pipeline
  88006. */
  88007. createPipelineContext(): WebGLPipelineContext;
  88008. private _createShaderProgram;
  88009. private _finalizePipelineContext;
  88010. /** @hidden */
  88011. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  88012. /** @hidden */
  88013. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  88014. /** @hidden */
  88015. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  88016. /**
  88017. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  88018. * @param pipelineContext defines the pipeline context to use
  88019. * @param uniformsNames defines the list of uniform names
  88020. * @returns an array of webGL uniform locations
  88021. */
  88022. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  88023. /**
  88024. * Gets the lsit of active attributes for a given webGL program
  88025. * @param pipelineContext defines the pipeline context to use
  88026. * @param attributesNames defines the list of attribute names to get
  88027. * @returns an array of indices indicating the offset of each attribute
  88028. */
  88029. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  88030. /**
  88031. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  88032. * @param effect defines the effect to activate
  88033. */
  88034. enableEffect(effect: Nullable<Effect>): void;
  88035. /**
  88036. * Set the value of an uniform to an array of int32
  88037. * @param uniform defines the webGL uniform location where to store the value
  88038. * @param array defines the array of int32 to store
  88039. */
  88040. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88041. /**
  88042. * Set the value of an uniform to an array of int32 (stored as vec2)
  88043. * @param uniform defines the webGL uniform location where to store the value
  88044. * @param array defines the array of int32 to store
  88045. */
  88046. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88047. /**
  88048. * Set the value of an uniform to an array of int32 (stored as vec3)
  88049. * @param uniform defines the webGL uniform location where to store the value
  88050. * @param array defines the array of int32 to store
  88051. */
  88052. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88053. /**
  88054. * Set the value of an uniform to an array of int32 (stored as vec4)
  88055. * @param uniform defines the webGL uniform location where to store the value
  88056. * @param array defines the array of int32 to store
  88057. */
  88058. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88059. /**
  88060. * Set the value of an uniform to an array of float32
  88061. * @param uniform defines the webGL uniform location where to store the value
  88062. * @param array defines the array of float32 to store
  88063. */
  88064. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88065. /**
  88066. * Set the value of an uniform to an array of float32 (stored as vec2)
  88067. * @param uniform defines the webGL uniform location where to store the value
  88068. * @param array defines the array of float32 to store
  88069. */
  88070. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88071. /**
  88072. * Set the value of an uniform to an array of float32 (stored as vec3)
  88073. * @param uniform defines the webGL uniform location where to store the value
  88074. * @param array defines the array of float32 to store
  88075. */
  88076. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88077. /**
  88078. * Set the value of an uniform to an array of float32 (stored as vec4)
  88079. * @param uniform defines the webGL uniform location where to store the value
  88080. * @param array defines the array of float32 to store
  88081. */
  88082. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88083. /**
  88084. * Set the value of an uniform to an array of number
  88085. * @param uniform defines the webGL uniform location where to store the value
  88086. * @param array defines the array of number to store
  88087. */
  88088. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88089. /**
  88090. * Set the value of an uniform to an array of number (stored as vec2)
  88091. * @param uniform defines the webGL uniform location where to store the value
  88092. * @param array defines the array of number to store
  88093. */
  88094. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88095. /**
  88096. * Set the value of an uniform to an array of number (stored as vec3)
  88097. * @param uniform defines the webGL uniform location where to store the value
  88098. * @param array defines the array of number to store
  88099. */
  88100. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88101. /**
  88102. * Set the value of an uniform to an array of number (stored as vec4)
  88103. * @param uniform defines the webGL uniform location where to store the value
  88104. * @param array defines the array of number to store
  88105. */
  88106. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88107. /**
  88108. * Set the value of an uniform to an array of float32 (stored as matrices)
  88109. * @param uniform defines the webGL uniform location where to store the value
  88110. * @param matrices defines the array of float32 to store
  88111. */
  88112. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  88113. /**
  88114. * Set the value of an uniform to a matrix
  88115. * @param uniform defines the webGL uniform location where to store the value
  88116. * @param matrix defines the matrix to store
  88117. */
  88118. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  88119. /**
  88120. * Set the value of an uniform to a matrix (3x3)
  88121. * @param uniform defines the webGL uniform location where to store the value
  88122. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  88123. */
  88124. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  88125. /**
  88126. * Set the value of an uniform to a matrix (2x2)
  88127. * @param uniform defines the webGL uniform location where to store the value
  88128. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  88129. */
  88130. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  88131. /**
  88132. * Set the value of an uniform to a number (int)
  88133. * @param uniform defines the webGL uniform location where to store the value
  88134. * @param value defines the int number to store
  88135. */
  88136. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  88137. /**
  88138. * Set the value of an uniform to a number (float)
  88139. * @param uniform defines the webGL uniform location where to store the value
  88140. * @param value defines the float number to store
  88141. */
  88142. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  88143. /**
  88144. * Set the value of an uniform to a vec2
  88145. * @param uniform defines the webGL uniform location where to store the value
  88146. * @param x defines the 1st component of the value
  88147. * @param y defines the 2nd component of the value
  88148. */
  88149. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  88150. /**
  88151. * Set the value of an uniform to a vec3
  88152. * @param uniform defines the webGL uniform location where to store the value
  88153. * @param x defines the 1st component of the value
  88154. * @param y defines the 2nd component of the value
  88155. * @param z defines the 3rd component of the value
  88156. */
  88157. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  88158. /**
  88159. * Set the value of an uniform to a boolean
  88160. * @param uniform defines the webGL uniform location where to store the value
  88161. * @param bool defines the boolean to store
  88162. */
  88163. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  88164. /**
  88165. * Set the value of an uniform to a vec4
  88166. * @param uniform defines the webGL uniform location where to store the value
  88167. * @param x defines the 1st component of the value
  88168. * @param y defines the 2nd component of the value
  88169. * @param z defines the 3rd component of the value
  88170. * @param w defines the 4th component of the value
  88171. */
  88172. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  88173. /**
  88174. * Set the value of an uniform to a Color3
  88175. * @param uniform defines the webGL uniform location where to store the value
  88176. * @param color3 defines the color to store
  88177. */
  88178. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  88179. /**
  88180. * Set the value of an uniform to a Color3 and an alpha value
  88181. * @param uniform defines the webGL uniform location where to store the value
  88182. * @param color3 defines the color to store
  88183. * @param alpha defines the alpha component to store
  88184. */
  88185. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  88186. /**
  88187. * Sets a Color4 on a uniform variable
  88188. * @param uniform defines the uniform location
  88189. * @param color4 defines the value to be set
  88190. */
  88191. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  88192. /**
  88193. * Set various states to the webGL context
  88194. * @param culling defines backface culling state
  88195. * @param zOffset defines the value to apply to zOffset (0 by default)
  88196. * @param force defines if states must be applied even if cache is up to date
  88197. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  88198. */
  88199. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  88200. /**
  88201. * Set the z offset to apply to current rendering
  88202. * @param value defines the offset to apply
  88203. */
  88204. setZOffset(value: number): void;
  88205. /**
  88206. * Gets the current value of the zOffset
  88207. * @returns the current zOffset state
  88208. */
  88209. getZOffset(): number;
  88210. /**
  88211. * Enable or disable depth buffering
  88212. * @param enable defines the state to set
  88213. */
  88214. setDepthBuffer(enable: boolean): void;
  88215. /**
  88216. * Gets a boolean indicating if depth writing is enabled
  88217. * @returns the current depth writing state
  88218. */
  88219. getDepthWrite(): boolean;
  88220. /**
  88221. * Enable or disable depth writing
  88222. * @param enable defines the state to set
  88223. */
  88224. setDepthWrite(enable: boolean): void;
  88225. /**
  88226. * Enable or disable color writing
  88227. * @param enable defines the state to set
  88228. */
  88229. setColorWrite(enable: boolean): void;
  88230. /**
  88231. * Gets a boolean indicating if color writing is enabled
  88232. * @returns the current color writing state
  88233. */
  88234. getColorWrite(): boolean;
  88235. /**
  88236. * Sets alpha constants used by some alpha blending modes
  88237. * @param r defines the red component
  88238. * @param g defines the green component
  88239. * @param b defines the blue component
  88240. * @param a defines the alpha component
  88241. */
  88242. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  88243. /**
  88244. * Sets the current alpha mode
  88245. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  88246. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  88247. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88248. */
  88249. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  88250. /**
  88251. * Gets the current alpha mode
  88252. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88253. * @returns the current alpha mode
  88254. */
  88255. getAlphaMode(): number;
  88256. /**
  88257. * Clears the list of texture accessible through engine.
  88258. * This can help preventing texture load conflict due to name collision.
  88259. */
  88260. clearInternalTexturesCache(): void;
  88261. /**
  88262. * Force the entire cache to be cleared
  88263. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  88264. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  88265. */
  88266. wipeCaches(bruteForce?: boolean): void;
  88267. /**
  88268. * Set the compressed texture format to use, based on the formats you have, and the formats
  88269. * supported by the hardware / browser.
  88270. *
  88271. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  88272. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  88273. * to API arguments needed to compressed textures. This puts the burden on the container
  88274. * generator to house the arcane code for determining these for current & future formats.
  88275. *
  88276. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  88277. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  88278. *
  88279. * Note: The result of this call is not taken into account when a texture is base64.
  88280. *
  88281. * @param formatsAvailable defines the list of those format families you have created
  88282. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  88283. *
  88284. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  88285. * @returns The extension selected.
  88286. */
  88287. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  88288. /** @hidden */
  88289. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  88290. min: number;
  88291. mag: number;
  88292. };
  88293. /** @hidden */
  88294. _createTexture(): WebGLTexture;
  88295. /**
  88296. * Usually called from Texture.ts.
  88297. * Passed information to create a WebGLTexture
  88298. * @param urlArg defines a value which contains one of the following:
  88299. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  88300. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  88301. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  88302. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  88303. * @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)
  88304. * @param scene needed for loading to the correct scene
  88305. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  88306. * @param onLoad optional callback to be called upon successful completion
  88307. * @param onError optional callback to be called upon failure
  88308. * @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
  88309. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  88310. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  88311. * @param forcedExtension defines the extension to use to pick the right loader
  88312. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  88313. * @returns a InternalTexture for assignment back into BABYLON.Texture
  88314. */
  88315. 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;
  88316. private _rescaleTexture;
  88317. private _unpackFlipYCached;
  88318. /**
  88319. * In case you are sharing the context with other applications, it might
  88320. * be interested to not cache the unpack flip y state to ensure a consistent
  88321. * value would be set.
  88322. */
  88323. enableUnpackFlipYCached: boolean;
  88324. /** @hidden */
  88325. _unpackFlipY(value: boolean): void;
  88326. /** @hidden */
  88327. _getUnpackAlignement(): number;
  88328. /**
  88329. * Creates a dynamic texture
  88330. * @param width defines the width of the texture
  88331. * @param height defines the height of the texture
  88332. * @param generateMipMaps defines if the engine should generate the mip levels
  88333. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88334. * @returns the dynamic texture inside an InternalTexture
  88335. */
  88336. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  88337. /**
  88338. * Update the sampling mode of a given texture
  88339. * @param samplingMode defines the required sampling mode
  88340. * @param texture defines the texture to update
  88341. */
  88342. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  88343. /**
  88344. * Update the content of a dynamic texture
  88345. * @param texture defines the texture to update
  88346. * @param canvas defines the canvas containing the source
  88347. * @param invertY defines if data must be stored with Y axis inverted
  88348. * @param premulAlpha defines if alpha is stored as premultiplied
  88349. * @param format defines the format of the data
  88350. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  88351. */
  88352. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  88353. /**
  88354. * Update a video texture
  88355. * @param texture defines the texture to update
  88356. * @param video defines the video element to use
  88357. * @param invertY defines if data must be stored with Y axis inverted
  88358. */
  88359. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  88360. /**
  88361. * Updates a depth texture Comparison Mode and Function.
  88362. * If the comparison Function is equal to 0, the mode will be set to none.
  88363. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  88364. * @param texture The texture to set the comparison function for
  88365. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  88366. */
  88367. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  88368. /** @hidden */
  88369. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  88370. width: number;
  88371. height: number;
  88372. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  88373. /**
  88374. * Creates a depth stencil texture.
  88375. * This is only available in WebGL 2 or with the depth texture extension available.
  88376. * @param size The size of face edge in the texture.
  88377. * @param options The options defining the texture.
  88378. * @returns The texture
  88379. */
  88380. createDepthStencilTexture(size: number | {
  88381. width: number;
  88382. height: number;
  88383. }, options: DepthTextureCreationOptions): InternalTexture;
  88384. /**
  88385. * Creates a depth stencil texture.
  88386. * This is only available in WebGL 2 or with the depth texture extension available.
  88387. * @param size The size of face edge in the texture.
  88388. * @param options The options defining the texture.
  88389. * @returns The texture
  88390. */
  88391. private _createDepthStencilTexture;
  88392. /**
  88393. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  88394. * @param renderTarget The render target to set the frame buffer for
  88395. */
  88396. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  88397. /**
  88398. * Creates a new render target texture
  88399. * @param size defines the size of the texture
  88400. * @param options defines the options used to create the texture
  88401. * @returns a new render target texture stored in an InternalTexture
  88402. */
  88403. createRenderTargetTexture(size: number | {
  88404. width: number;
  88405. height: number;
  88406. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  88407. /** @hidden */
  88408. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  88409. /**
  88410. * Updates the sample count of a render target texture
  88411. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  88412. * @param texture defines the texture to update
  88413. * @param samples defines the sample count to set
  88414. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  88415. */
  88416. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  88417. /** @hidden */
  88418. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88419. /** @hidden */
  88420. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88421. /** @hidden */
  88422. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88423. /** @hidden */
  88424. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  88425. /**
  88426. * @hidden
  88427. */
  88428. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88429. private _prepareWebGLTextureContinuation;
  88430. private _prepareWebGLTexture;
  88431. /** @hidden */
  88432. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  88433. /** @hidden */
  88434. _releaseFramebufferObjects(texture: InternalTexture): void;
  88435. /** @hidden */
  88436. _releaseTexture(texture: InternalTexture): void;
  88437. private setProgram;
  88438. private _boundUniforms;
  88439. /**
  88440. * Binds an effect to the webGL context
  88441. * @param effect defines the effect to bind
  88442. */
  88443. bindSamplers(effect: Effect): void;
  88444. private _activateCurrentTexture;
  88445. /** @hidden */
  88446. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  88447. /** @hidden */
  88448. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  88449. /**
  88450. * Sets a texture to the webGL context from a postprocess
  88451. * @param channel defines the channel to use
  88452. * @param postProcess defines the source postprocess
  88453. */
  88454. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  88455. /**
  88456. * Binds the output of the passed in post process to the texture channel specified
  88457. * @param channel The channel the texture should be bound to
  88458. * @param postProcess The post process which's output should be bound
  88459. */
  88460. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  88461. /**
  88462. * Unbind all textures from the webGL context
  88463. */
  88464. unbindAllTextures(): void;
  88465. /**
  88466. * Sets a texture to the according uniform.
  88467. * @param channel The texture channel
  88468. * @param uniform The uniform to set
  88469. * @param texture The texture to apply
  88470. */
  88471. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  88472. /**
  88473. * Sets a depth stencil texture from a render target to the according uniform.
  88474. * @param channel The texture channel
  88475. * @param uniform The uniform to set
  88476. * @param texture The render target texture containing the depth stencil texture to apply
  88477. */
  88478. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  88479. private _bindSamplerUniformToChannel;
  88480. private _getTextureWrapMode;
  88481. private _setTexture;
  88482. /**
  88483. * Sets an array of texture to the webGL context
  88484. * @param channel defines the channel where the texture array must be set
  88485. * @param uniform defines the associated uniform location
  88486. * @param textures defines the array of textures to bind
  88487. */
  88488. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  88489. /** @hidden */
  88490. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  88491. private _setTextureParameterFloat;
  88492. private _setTextureParameterInteger;
  88493. /**
  88494. * Reads pixels from the current frame buffer. Please note that this function can be slow
  88495. * @param x defines the x coordinate of the rectangle where pixels must be read
  88496. * @param y defines the y coordinate of the rectangle where pixels must be read
  88497. * @param width defines the width of the rectangle where pixels must be read
  88498. * @param height defines the height of the rectangle where pixels must be read
  88499. * @returns a Uint8Array containing RGBA colors
  88500. */
  88501. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  88502. /**
  88503. * Add an externaly attached data from its key.
  88504. * This method call will fail and return false, if such key already exists.
  88505. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  88506. * @param key the unique key that identifies the data
  88507. * @param data the data object to associate to the key for this Engine instance
  88508. * @return true if no such key were already present and the data was added successfully, false otherwise
  88509. */
  88510. addExternalData<T>(key: string, data: T): boolean;
  88511. /**
  88512. * Get an externaly attached data from its key
  88513. * @param key the unique key that identifies the data
  88514. * @return the associated data, if present (can be null), or undefined if not present
  88515. */
  88516. getExternalData<T>(key: string): T;
  88517. /**
  88518. * Get an externaly attached data from its key, create it using a factory if it's not already present
  88519. * @param key the unique key that identifies the data
  88520. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  88521. * @return the associated data, can be null if the factory returned null.
  88522. */
  88523. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  88524. /**
  88525. * Remove an externaly attached data from the Engine instance
  88526. * @param key the unique key that identifies the data
  88527. * @return true if the data was successfully removed, false if it doesn't exist
  88528. */
  88529. removeExternalData(key: string): boolean;
  88530. /**
  88531. * Unbind all vertex attributes from the webGL context
  88532. */
  88533. unbindAllAttributes(): void;
  88534. /**
  88535. * 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
  88536. */
  88537. releaseEffects(): void;
  88538. /**
  88539. * Dispose and release all associated resources
  88540. */
  88541. dispose(): void;
  88542. /**
  88543. * Display the loading screen
  88544. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88545. */
  88546. displayLoadingUI(): void;
  88547. /**
  88548. * Hide the loading screen
  88549. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88550. */
  88551. hideLoadingUI(): void;
  88552. /**
  88553. * Gets the current loading screen object
  88554. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88555. */
  88556. /**
  88557. * Sets the current loading screen object
  88558. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88559. */
  88560. loadingScreen: ILoadingScreen;
  88561. /**
  88562. * Sets the current loading screen text
  88563. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88564. */
  88565. loadingUIText: string;
  88566. /**
  88567. * Sets the current loading screen background color
  88568. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88569. */
  88570. loadingUIBackgroundColor: string;
  88571. /**
  88572. * Attach a new callback raised when context lost event is fired
  88573. * @param callback defines the callback to call
  88574. */
  88575. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88576. /**
  88577. * Attach a new callback raised when context restored event is fired
  88578. * @param callback defines the callback to call
  88579. */
  88580. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88581. /**
  88582. * Gets the source code of the vertex shader associated with a specific webGL program
  88583. * @param program defines the program to use
  88584. * @returns a string containing the source code of the vertex shader associated with the program
  88585. */
  88586. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  88587. /**
  88588. * Gets the source code of the fragment shader associated with a specific webGL program
  88589. * @param program defines the program to use
  88590. * @returns a string containing the source code of the fragment shader associated with the program
  88591. */
  88592. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  88593. /**
  88594. * Get the current error code of the webGL context
  88595. * @returns the error code
  88596. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  88597. */
  88598. getError(): number;
  88599. /**
  88600. * Gets the current framerate
  88601. * @returns a number representing the framerate
  88602. */
  88603. getFps(): number;
  88604. /**
  88605. * Gets the time spent between current and previous frame
  88606. * @returns a number representing the delta time in ms
  88607. */
  88608. getDeltaTime(): number;
  88609. private _measureFps;
  88610. /** @hidden */
  88611. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  88612. private _canRenderToFloatFramebuffer;
  88613. private _canRenderToHalfFloatFramebuffer;
  88614. private _canRenderToFramebuffer;
  88615. /** @hidden */
  88616. _getWebGLTextureType(type: number): number;
  88617. /** @hidden */
  88618. _getInternalFormat(format: number): number;
  88619. /** @hidden */
  88620. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  88621. /** @hidden */
  88622. _getRGBAMultiSampleBufferFormat(type: number): number;
  88623. /** @hidden */
  88624. _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;
  88625. /** @hidden */
  88626. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  88627. /**
  88628. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  88629. * @returns true if the engine can be created
  88630. * @ignorenaming
  88631. */
  88632. static isSupported(): boolean;
  88633. }
  88634. }
  88635. declare module BABYLON {
  88636. /**
  88637. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88638. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88639. */
  88640. export class EffectFallbacks {
  88641. private _defines;
  88642. private _currentRank;
  88643. private _maxRank;
  88644. private _mesh;
  88645. /**
  88646. * Removes the fallback from the bound mesh.
  88647. */
  88648. unBindMesh(): void;
  88649. /**
  88650. * Adds a fallback on the specified property.
  88651. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88652. * @param define The name of the define in the shader
  88653. */
  88654. addFallback(rank: number, define: string): void;
  88655. /**
  88656. * Sets the mesh to use CPU skinning when needing to fallback.
  88657. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88658. * @param mesh The mesh to use the fallbacks.
  88659. */
  88660. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88661. /**
  88662. * Checks to see if more fallbacks are still availible.
  88663. */
  88664. readonly isMoreFallbacks: boolean;
  88665. /**
  88666. * Removes the defines that shoould be removed when falling back.
  88667. * @param currentDefines defines the current define statements for the shader.
  88668. * @param effect defines the current effect we try to compile
  88669. * @returns The resulting defines with defines of the current rank removed.
  88670. */
  88671. reduce(currentDefines: string, effect: Effect): string;
  88672. }
  88673. /**
  88674. * Options to be used when creating an effect.
  88675. */
  88676. export class EffectCreationOptions {
  88677. /**
  88678. * Atrributes that will be used in the shader.
  88679. */
  88680. attributes: string[];
  88681. /**
  88682. * Uniform varible names that will be set in the shader.
  88683. */
  88684. uniformsNames: string[];
  88685. /**
  88686. * Uniform buffer varible names that will be set in the shader.
  88687. */
  88688. uniformBuffersNames: string[];
  88689. /**
  88690. * Sampler texture variable names that will be set in the shader.
  88691. */
  88692. samplers: string[];
  88693. /**
  88694. * Define statements that will be set in the shader.
  88695. */
  88696. defines: any;
  88697. /**
  88698. * Possible fallbacks for this effect to improve performance when needed.
  88699. */
  88700. fallbacks: Nullable<EffectFallbacks>;
  88701. /**
  88702. * Callback that will be called when the shader is compiled.
  88703. */
  88704. onCompiled: Nullable<(effect: Effect) => void>;
  88705. /**
  88706. * Callback that will be called if an error occurs during shader compilation.
  88707. */
  88708. onError: Nullable<(effect: Effect, errors: string) => void>;
  88709. /**
  88710. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88711. */
  88712. indexParameters: any;
  88713. /**
  88714. * Max number of lights that can be used in the shader.
  88715. */
  88716. maxSimultaneousLights: number;
  88717. /**
  88718. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  88719. */
  88720. transformFeedbackVaryings: Nullable<string[]>;
  88721. }
  88722. /**
  88723. * Effect containing vertex and fragment shader that can be executed on an object.
  88724. */
  88725. export class Effect implements IDisposable {
  88726. /**
  88727. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  88728. */
  88729. static ShadersRepository: string;
  88730. /**
  88731. * Name of the effect.
  88732. */
  88733. name: any;
  88734. /**
  88735. * String container all the define statements that should be set on the shader.
  88736. */
  88737. defines: string;
  88738. /**
  88739. * Callback that will be called when the shader is compiled.
  88740. */
  88741. onCompiled: Nullable<(effect: Effect) => void>;
  88742. /**
  88743. * Callback that will be called if an error occurs during shader compilation.
  88744. */
  88745. onError: Nullable<(effect: Effect, errors: string) => void>;
  88746. /**
  88747. * Callback that will be called when effect is bound.
  88748. */
  88749. onBind: Nullable<(effect: Effect) => void>;
  88750. /**
  88751. * Unique ID of the effect.
  88752. */
  88753. uniqueId: number;
  88754. /**
  88755. * Observable that will be called when the shader is compiled.
  88756. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  88757. */
  88758. onCompileObservable: Observable<Effect>;
  88759. /**
  88760. * Observable that will be called if an error occurs during shader compilation.
  88761. */
  88762. onErrorObservable: Observable<Effect>;
  88763. /** @hidden */
  88764. _onBindObservable: Nullable<Observable<Effect>>;
  88765. /**
  88766. * Observable that will be called when effect is bound.
  88767. */
  88768. readonly onBindObservable: Observable<Effect>;
  88769. /** @hidden */
  88770. _bonesComputationForcedToCPU: boolean;
  88771. private static _uniqueIdSeed;
  88772. private _engine;
  88773. private _uniformBuffersNames;
  88774. private _uniformsNames;
  88775. private _samplerList;
  88776. private _samplers;
  88777. private _isReady;
  88778. private _compilationError;
  88779. private _attributesNames;
  88780. private _attributes;
  88781. private _uniforms;
  88782. /**
  88783. * Key for the effect.
  88784. * @hidden
  88785. */
  88786. _key: string;
  88787. private _indexParameters;
  88788. private _fallbacks;
  88789. private _vertexSourceCode;
  88790. private _fragmentSourceCode;
  88791. private _vertexSourceCodeOverride;
  88792. private _fragmentSourceCodeOverride;
  88793. private _transformFeedbackVaryings;
  88794. /**
  88795. * Compiled shader to webGL program.
  88796. * @hidden
  88797. */
  88798. _pipelineContext: IPipelineContext;
  88799. private _valueCache;
  88800. private static _baseCache;
  88801. /**
  88802. * Instantiates an effect.
  88803. * An effect can be used to create/manage/execute vertex and fragment shaders.
  88804. * @param baseName Name of the effect.
  88805. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  88806. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  88807. * @param samplers List of sampler variables that will be passed to the shader.
  88808. * @param engine Engine to be used to render the effect
  88809. * @param defines Define statements to be added to the shader.
  88810. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  88811. * @param onCompiled Callback that will be called when the shader is compiled.
  88812. * @param onError Callback that will be called if an error occurs during shader compilation.
  88813. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88814. */
  88815. 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);
  88816. /**
  88817. * Unique key for this effect
  88818. */
  88819. readonly key: string;
  88820. /**
  88821. * If the effect has been compiled and prepared.
  88822. * @returns if the effect is compiled and prepared.
  88823. */
  88824. isReady(): boolean;
  88825. /**
  88826. * The engine the effect was initialized with.
  88827. * @returns the engine.
  88828. */
  88829. getEngine(): Engine;
  88830. /**
  88831. * The pipeline context for this effect
  88832. * @returns the associated pipeline context
  88833. */
  88834. getPipelineContext(): IPipelineContext;
  88835. /**
  88836. * The set of names of attribute variables for the shader.
  88837. * @returns An array of attribute names.
  88838. */
  88839. getAttributesNames(): string[];
  88840. /**
  88841. * Returns the attribute at the given index.
  88842. * @param index The index of the attribute.
  88843. * @returns The location of the attribute.
  88844. */
  88845. getAttributeLocation(index: number): number;
  88846. /**
  88847. * Returns the attribute based on the name of the variable.
  88848. * @param name of the attribute to look up.
  88849. * @returns the attribute location.
  88850. */
  88851. getAttributeLocationByName(name: string): number;
  88852. /**
  88853. * The number of attributes.
  88854. * @returns the numnber of attributes.
  88855. */
  88856. getAttributesCount(): number;
  88857. /**
  88858. * Gets the index of a uniform variable.
  88859. * @param uniformName of the uniform to look up.
  88860. * @returns the index.
  88861. */
  88862. getUniformIndex(uniformName: string): number;
  88863. /**
  88864. * Returns the attribute based on the name of the variable.
  88865. * @param uniformName of the uniform to look up.
  88866. * @returns the location of the uniform.
  88867. */
  88868. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  88869. /**
  88870. * Returns an array of sampler variable names
  88871. * @returns The array of sampler variable neames.
  88872. */
  88873. getSamplers(): string[];
  88874. /**
  88875. * The error from the last compilation.
  88876. * @returns the error string.
  88877. */
  88878. getCompilationError(): string;
  88879. /**
  88880. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  88881. * @param func The callback to be used.
  88882. */
  88883. executeWhenCompiled(func: (effect: Effect) => void): void;
  88884. private _checkIsReady;
  88885. /** @hidden */
  88886. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  88887. /** @hidden */
  88888. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  88889. /** @hidden */
  88890. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  88891. private _processShaderConversion;
  88892. private _processIncludes;
  88893. private _processPrecision;
  88894. /**
  88895. * Recompiles the webGL program
  88896. * @param vertexSourceCode The source code for the vertex shader.
  88897. * @param fragmentSourceCode The source code for the fragment shader.
  88898. * @param onCompiled Callback called when completed.
  88899. * @param onError Callback called on error.
  88900. * @hidden
  88901. */
  88902. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  88903. /**
  88904. * Prepares the effect
  88905. * @hidden
  88906. */
  88907. _prepareEffect(): void;
  88908. /**
  88909. * Checks if the effect is supported. (Must be called after compilation)
  88910. */
  88911. readonly isSupported: boolean;
  88912. /**
  88913. * Binds a texture to the engine to be used as output of the shader.
  88914. * @param channel Name of the output variable.
  88915. * @param texture Texture to bind.
  88916. * @hidden
  88917. */
  88918. _bindTexture(channel: string, texture: InternalTexture): void;
  88919. /**
  88920. * Sets a texture on the engine to be used in the shader.
  88921. * @param channel Name of the sampler variable.
  88922. * @param texture Texture to set.
  88923. */
  88924. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  88925. /**
  88926. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  88927. * @param channel Name of the sampler variable.
  88928. * @param texture Texture to set.
  88929. */
  88930. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  88931. /**
  88932. * Sets an array of textures on the engine to be used in the shader.
  88933. * @param channel Name of the variable.
  88934. * @param textures Textures to set.
  88935. */
  88936. setTextureArray(channel: string, textures: BaseTexture[]): void;
  88937. /**
  88938. * 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)
  88939. * @param channel Name of the sampler variable.
  88940. * @param postProcess Post process to get the input texture from.
  88941. */
  88942. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  88943. /**
  88944. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  88945. * 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)
  88946. * @param channel Name of the sampler variable.
  88947. * @param postProcess Post process to get the output texture from.
  88948. */
  88949. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  88950. /** @hidden */
  88951. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  88952. /** @hidden */
  88953. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  88954. /** @hidden */
  88955. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  88956. /** @hidden */
  88957. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  88958. /**
  88959. * Binds a buffer to a uniform.
  88960. * @param buffer Buffer to bind.
  88961. * @param name Name of the uniform variable to bind to.
  88962. */
  88963. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  88964. /**
  88965. * Binds block to a uniform.
  88966. * @param blockName Name of the block to bind.
  88967. * @param index Index to bind.
  88968. */
  88969. bindUniformBlock(blockName: string, index: number): void;
  88970. /**
  88971. * Sets an interger value on a uniform variable.
  88972. * @param uniformName Name of the variable.
  88973. * @param value Value to be set.
  88974. * @returns this effect.
  88975. */
  88976. setInt(uniformName: string, value: number): Effect;
  88977. /**
  88978. * Sets an int array on a uniform variable.
  88979. * @param uniformName Name of the variable.
  88980. * @param array array to be set.
  88981. * @returns this effect.
  88982. */
  88983. setIntArray(uniformName: string, array: Int32Array): Effect;
  88984. /**
  88985. * 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)
  88986. * @param uniformName Name of the variable.
  88987. * @param array array to be set.
  88988. * @returns this effect.
  88989. */
  88990. setIntArray2(uniformName: string, array: Int32Array): Effect;
  88991. /**
  88992. * 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)
  88993. * @param uniformName Name of the variable.
  88994. * @param array array to be set.
  88995. * @returns this effect.
  88996. */
  88997. setIntArray3(uniformName: string, array: Int32Array): Effect;
  88998. /**
  88999. * 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)
  89000. * @param uniformName Name of the variable.
  89001. * @param array array to be set.
  89002. * @returns this effect.
  89003. */
  89004. setIntArray4(uniformName: string, array: Int32Array): Effect;
  89005. /**
  89006. * Sets an float array on a uniform variable.
  89007. * @param uniformName Name of the variable.
  89008. * @param array array to be set.
  89009. * @returns this effect.
  89010. */
  89011. setFloatArray(uniformName: string, array: Float32Array): Effect;
  89012. /**
  89013. * 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)
  89014. * @param uniformName Name of the variable.
  89015. * @param array array to be set.
  89016. * @returns this effect.
  89017. */
  89018. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  89019. /**
  89020. * 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)
  89021. * @param uniformName Name of the variable.
  89022. * @param array array to be set.
  89023. * @returns this effect.
  89024. */
  89025. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  89026. /**
  89027. * 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)
  89028. * @param uniformName Name of the variable.
  89029. * @param array array to be set.
  89030. * @returns this effect.
  89031. */
  89032. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  89033. /**
  89034. * Sets an array on a uniform variable.
  89035. * @param uniformName Name of the variable.
  89036. * @param array array to be set.
  89037. * @returns this effect.
  89038. */
  89039. setArray(uniformName: string, array: number[]): Effect;
  89040. /**
  89041. * 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)
  89042. * @param uniformName Name of the variable.
  89043. * @param array array to be set.
  89044. * @returns this effect.
  89045. */
  89046. setArray2(uniformName: string, array: number[]): Effect;
  89047. /**
  89048. * 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)
  89049. * @param uniformName Name of the variable.
  89050. * @param array array to be set.
  89051. * @returns this effect.
  89052. */
  89053. setArray3(uniformName: string, array: number[]): Effect;
  89054. /**
  89055. * 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)
  89056. * @param uniformName Name of the variable.
  89057. * @param array array to be set.
  89058. * @returns this effect.
  89059. */
  89060. setArray4(uniformName: string, array: number[]): Effect;
  89061. /**
  89062. * Sets matrices on a uniform variable.
  89063. * @param uniformName Name of the variable.
  89064. * @param matrices matrices to be set.
  89065. * @returns this effect.
  89066. */
  89067. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  89068. /**
  89069. * Sets matrix on a uniform variable.
  89070. * @param uniformName Name of the variable.
  89071. * @param matrix matrix to be set.
  89072. * @returns this effect.
  89073. */
  89074. setMatrix(uniformName: string, matrix: Matrix): Effect;
  89075. /**
  89076. * 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)
  89077. * @param uniformName Name of the variable.
  89078. * @param matrix matrix to be set.
  89079. * @returns this effect.
  89080. */
  89081. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  89082. /**
  89083. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  89084. * @param uniformName Name of the variable.
  89085. * @param matrix matrix to be set.
  89086. * @returns this effect.
  89087. */
  89088. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  89089. /**
  89090. * Sets a float on a uniform variable.
  89091. * @param uniformName Name of the variable.
  89092. * @param value value to be set.
  89093. * @returns this effect.
  89094. */
  89095. setFloat(uniformName: string, value: number): Effect;
  89096. /**
  89097. * Sets a boolean on a uniform variable.
  89098. * @param uniformName Name of the variable.
  89099. * @param bool value to be set.
  89100. * @returns this effect.
  89101. */
  89102. setBool(uniformName: string, bool: boolean): Effect;
  89103. /**
  89104. * Sets a Vector2 on a uniform variable.
  89105. * @param uniformName Name of the variable.
  89106. * @param vector2 vector2 to be set.
  89107. * @returns this effect.
  89108. */
  89109. setVector2(uniformName: string, vector2: Vector2): Effect;
  89110. /**
  89111. * Sets a float2 on a uniform variable.
  89112. * @param uniformName Name of the variable.
  89113. * @param x First float in float2.
  89114. * @param y Second float in float2.
  89115. * @returns this effect.
  89116. */
  89117. setFloat2(uniformName: string, x: number, y: number): Effect;
  89118. /**
  89119. * Sets a Vector3 on a uniform variable.
  89120. * @param uniformName Name of the variable.
  89121. * @param vector3 Value to be set.
  89122. * @returns this effect.
  89123. */
  89124. setVector3(uniformName: string, vector3: Vector3): Effect;
  89125. /**
  89126. * Sets a float3 on a uniform variable.
  89127. * @param uniformName Name of the variable.
  89128. * @param x First float in float3.
  89129. * @param y Second float in float3.
  89130. * @param z Third float in float3.
  89131. * @returns this effect.
  89132. */
  89133. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  89134. /**
  89135. * Sets a Vector4 on a uniform variable.
  89136. * @param uniformName Name of the variable.
  89137. * @param vector4 Value to be set.
  89138. * @returns this effect.
  89139. */
  89140. setVector4(uniformName: string, vector4: Vector4): Effect;
  89141. /**
  89142. * Sets a float4 on a uniform variable.
  89143. * @param uniformName Name of the variable.
  89144. * @param x First float in float4.
  89145. * @param y Second float in float4.
  89146. * @param z Third float in float4.
  89147. * @param w Fourth float in float4.
  89148. * @returns this effect.
  89149. */
  89150. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  89151. /**
  89152. * Sets a Color3 on a uniform variable.
  89153. * @param uniformName Name of the variable.
  89154. * @param color3 Value to be set.
  89155. * @returns this effect.
  89156. */
  89157. setColor3(uniformName: string, color3: Color3): Effect;
  89158. /**
  89159. * Sets a Color4 on a uniform variable.
  89160. * @param uniformName Name of the variable.
  89161. * @param color3 Value to be set.
  89162. * @param alpha Alpha value to be set.
  89163. * @returns this effect.
  89164. */
  89165. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  89166. /**
  89167. * Sets a Color4 on a uniform variable
  89168. * @param uniformName defines the name of the variable
  89169. * @param color4 defines the value to be set
  89170. * @returns this effect.
  89171. */
  89172. setDirectColor4(uniformName: string, color4: Color4): Effect;
  89173. /** Release all associated resources */
  89174. dispose(): void;
  89175. /**
  89176. * This function will add a new shader to the shader store
  89177. * @param name the name of the shader
  89178. * @param pixelShader optional pixel shader content
  89179. * @param vertexShader optional vertex shader content
  89180. */
  89181. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  89182. /**
  89183. * Store of each shader (The can be looked up using effect.key)
  89184. */
  89185. static ShadersStore: {
  89186. [key: string]: string;
  89187. };
  89188. /**
  89189. * Store of each included file for a shader (The can be looked up using effect.key)
  89190. */
  89191. static IncludesShadersStore: {
  89192. [key: string]: string;
  89193. };
  89194. /**
  89195. * Resets the cache of effects.
  89196. */
  89197. static ResetCache(): void;
  89198. }
  89199. }
  89200. declare module BABYLON {
  89201. /**
  89202. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  89203. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  89204. * 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;
  89205. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  89206. */
  89207. export class ColorCurves {
  89208. private _dirty;
  89209. private _tempColor;
  89210. private _globalCurve;
  89211. private _highlightsCurve;
  89212. private _midtonesCurve;
  89213. private _shadowsCurve;
  89214. private _positiveCurve;
  89215. private _negativeCurve;
  89216. private _globalHue;
  89217. private _globalDensity;
  89218. private _globalSaturation;
  89219. private _globalExposure;
  89220. /**
  89221. * Gets the global Hue value.
  89222. * 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).
  89223. */
  89224. /**
  89225. * Sets the global Hue value.
  89226. * 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).
  89227. */
  89228. globalHue: number;
  89229. /**
  89230. * Gets the global Density value.
  89231. * 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.
  89232. * Values less than zero provide a filter of opposite hue.
  89233. */
  89234. /**
  89235. * Sets the global Density value.
  89236. * 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.
  89237. * Values less than zero provide a filter of opposite hue.
  89238. */
  89239. globalDensity: number;
  89240. /**
  89241. * Gets the global Saturation value.
  89242. * 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.
  89243. */
  89244. /**
  89245. * Sets the global Saturation value.
  89246. * 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.
  89247. */
  89248. globalSaturation: number;
  89249. /**
  89250. * Gets the global Exposure value.
  89251. * 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.
  89252. */
  89253. /**
  89254. * Sets the global Exposure value.
  89255. * 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.
  89256. */
  89257. globalExposure: number;
  89258. private _highlightsHue;
  89259. private _highlightsDensity;
  89260. private _highlightsSaturation;
  89261. private _highlightsExposure;
  89262. /**
  89263. * Gets the highlights Hue value.
  89264. * 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).
  89265. */
  89266. /**
  89267. * Sets the highlights Hue value.
  89268. * 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).
  89269. */
  89270. highlightsHue: number;
  89271. /**
  89272. * Gets the highlights Density value.
  89273. * 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.
  89274. * Values less than zero provide a filter of opposite hue.
  89275. */
  89276. /**
  89277. * Sets the highlights Density value.
  89278. * 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.
  89279. * Values less than zero provide a filter of opposite hue.
  89280. */
  89281. highlightsDensity: number;
  89282. /**
  89283. * Gets the highlights Saturation value.
  89284. * 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.
  89285. */
  89286. /**
  89287. * Sets the highlights Saturation value.
  89288. * 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.
  89289. */
  89290. highlightsSaturation: number;
  89291. /**
  89292. * Gets the highlights Exposure value.
  89293. * 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.
  89294. */
  89295. /**
  89296. * Sets the highlights Exposure value.
  89297. * 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.
  89298. */
  89299. highlightsExposure: number;
  89300. private _midtonesHue;
  89301. private _midtonesDensity;
  89302. private _midtonesSaturation;
  89303. private _midtonesExposure;
  89304. /**
  89305. * Gets the midtones Hue value.
  89306. * 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).
  89307. */
  89308. /**
  89309. * Sets the midtones Hue value.
  89310. * 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).
  89311. */
  89312. midtonesHue: number;
  89313. /**
  89314. * Gets the midtones Density value.
  89315. * 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.
  89316. * Values less than zero provide a filter of opposite hue.
  89317. */
  89318. /**
  89319. * Sets the midtones Density value.
  89320. * 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.
  89321. * Values less than zero provide a filter of opposite hue.
  89322. */
  89323. midtonesDensity: number;
  89324. /**
  89325. * Gets the midtones Saturation value.
  89326. * 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.
  89327. */
  89328. /**
  89329. * Sets the midtones Saturation value.
  89330. * 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.
  89331. */
  89332. midtonesSaturation: number;
  89333. /**
  89334. * Gets the midtones Exposure value.
  89335. * 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.
  89336. */
  89337. /**
  89338. * Sets the midtones Exposure value.
  89339. * 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.
  89340. */
  89341. midtonesExposure: number;
  89342. private _shadowsHue;
  89343. private _shadowsDensity;
  89344. private _shadowsSaturation;
  89345. private _shadowsExposure;
  89346. /**
  89347. * Gets the shadows Hue value.
  89348. * 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).
  89349. */
  89350. /**
  89351. * Sets the shadows Hue value.
  89352. * 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).
  89353. */
  89354. shadowsHue: number;
  89355. /**
  89356. * Gets the shadows Density value.
  89357. * 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.
  89358. * Values less than zero provide a filter of opposite hue.
  89359. */
  89360. /**
  89361. * Sets the shadows Density value.
  89362. * 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.
  89363. * Values less than zero provide a filter of opposite hue.
  89364. */
  89365. shadowsDensity: number;
  89366. /**
  89367. * Gets the shadows Saturation value.
  89368. * 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.
  89369. */
  89370. /**
  89371. * Sets the shadows Saturation value.
  89372. * 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.
  89373. */
  89374. shadowsSaturation: number;
  89375. /**
  89376. * Gets the shadows Exposure value.
  89377. * 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.
  89378. */
  89379. /**
  89380. * Sets the shadows Exposure value.
  89381. * 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.
  89382. */
  89383. shadowsExposure: number;
  89384. /**
  89385. * Returns the class name
  89386. * @returns The class name
  89387. */
  89388. getClassName(): string;
  89389. /**
  89390. * Binds the color curves to the shader.
  89391. * @param colorCurves The color curve to bind
  89392. * @param effect The effect to bind to
  89393. * @param positiveUniform The positive uniform shader parameter
  89394. * @param neutralUniform The neutral uniform shader parameter
  89395. * @param negativeUniform The negative uniform shader parameter
  89396. */
  89397. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  89398. /**
  89399. * Prepare the list of uniforms associated with the ColorCurves effects.
  89400. * @param uniformsList The list of uniforms used in the effect
  89401. */
  89402. static PrepareUniforms(uniformsList: string[]): void;
  89403. /**
  89404. * Returns color grading data based on a hue, density, saturation and exposure value.
  89405. * @param filterHue The hue of the color filter.
  89406. * @param filterDensity The density of the color filter.
  89407. * @param saturation The saturation.
  89408. * @param exposure The exposure.
  89409. * @param result The result data container.
  89410. */
  89411. private getColorGradingDataToRef;
  89412. /**
  89413. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  89414. * @param value The input slider value in range [-100,100].
  89415. * @returns Adjusted value.
  89416. */
  89417. private static applyColorGradingSliderNonlinear;
  89418. /**
  89419. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89420. * @param hue The hue (H) input.
  89421. * @param saturation The saturation (S) input.
  89422. * @param brightness The brightness (B) input.
  89423. * @result An RGBA color represented as Vector4.
  89424. */
  89425. private static fromHSBToRef;
  89426. /**
  89427. * Returns a value clamped between min and max
  89428. * @param value The value to clamp
  89429. * @param min The minimum of value
  89430. * @param max The maximum of value
  89431. * @returns The clamped value.
  89432. */
  89433. private static clamp;
  89434. /**
  89435. * Clones the current color curve instance.
  89436. * @return The cloned curves
  89437. */
  89438. clone(): ColorCurves;
  89439. /**
  89440. * Serializes the current color curve instance to a json representation.
  89441. * @return a JSON representation
  89442. */
  89443. serialize(): any;
  89444. /**
  89445. * Parses the color curve from a json representation.
  89446. * @param source the JSON source to parse
  89447. * @return The parsed curves
  89448. */
  89449. static Parse(source: any): ColorCurves;
  89450. }
  89451. }
  89452. declare module BABYLON {
  89453. /**
  89454. * Interface to follow in your material defines to integrate easily the
  89455. * Image proccessing functions.
  89456. * @hidden
  89457. */
  89458. export interface IImageProcessingConfigurationDefines {
  89459. IMAGEPROCESSING: boolean;
  89460. VIGNETTE: boolean;
  89461. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89462. VIGNETTEBLENDMODEOPAQUE: boolean;
  89463. TONEMAPPING: boolean;
  89464. TONEMAPPING_ACES: boolean;
  89465. CONTRAST: boolean;
  89466. EXPOSURE: boolean;
  89467. COLORCURVES: boolean;
  89468. COLORGRADING: boolean;
  89469. COLORGRADING3D: boolean;
  89470. SAMPLER3DGREENDEPTH: boolean;
  89471. SAMPLER3DBGRMAP: boolean;
  89472. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89473. }
  89474. /**
  89475. * @hidden
  89476. */
  89477. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89478. IMAGEPROCESSING: boolean;
  89479. VIGNETTE: boolean;
  89480. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89481. VIGNETTEBLENDMODEOPAQUE: boolean;
  89482. TONEMAPPING: boolean;
  89483. TONEMAPPING_ACES: boolean;
  89484. CONTRAST: boolean;
  89485. COLORCURVES: boolean;
  89486. COLORGRADING: boolean;
  89487. COLORGRADING3D: boolean;
  89488. SAMPLER3DGREENDEPTH: boolean;
  89489. SAMPLER3DBGRMAP: boolean;
  89490. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89491. EXPOSURE: boolean;
  89492. constructor();
  89493. }
  89494. /**
  89495. * This groups together the common properties used for image processing either in direct forward pass
  89496. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89497. * or not.
  89498. */
  89499. export class ImageProcessingConfiguration {
  89500. /**
  89501. * Default tone mapping applied in BabylonJS.
  89502. */
  89503. static readonly TONEMAPPING_STANDARD: number;
  89504. /**
  89505. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89506. * to other engines rendering to increase portability.
  89507. */
  89508. static readonly TONEMAPPING_ACES: number;
  89509. /**
  89510. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89511. */
  89512. colorCurves: Nullable<ColorCurves>;
  89513. private _colorCurvesEnabled;
  89514. /**
  89515. * Gets wether the color curves effect is enabled.
  89516. */
  89517. /**
  89518. * Sets wether the color curves effect is enabled.
  89519. */
  89520. colorCurvesEnabled: boolean;
  89521. private _colorGradingTexture;
  89522. /**
  89523. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89524. */
  89525. /**
  89526. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89527. */
  89528. colorGradingTexture: Nullable<BaseTexture>;
  89529. private _colorGradingEnabled;
  89530. /**
  89531. * Gets wether the color grading effect is enabled.
  89532. */
  89533. /**
  89534. * Sets wether the color grading effect is enabled.
  89535. */
  89536. colorGradingEnabled: boolean;
  89537. private _colorGradingWithGreenDepth;
  89538. /**
  89539. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89540. */
  89541. /**
  89542. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89543. */
  89544. colorGradingWithGreenDepth: boolean;
  89545. private _colorGradingBGR;
  89546. /**
  89547. * Gets wether the color grading texture contains BGR values.
  89548. */
  89549. /**
  89550. * Sets wether the color grading texture contains BGR values.
  89551. */
  89552. colorGradingBGR: boolean;
  89553. /** @hidden */
  89554. _exposure: number;
  89555. /**
  89556. * Gets the Exposure used in the effect.
  89557. */
  89558. /**
  89559. * Sets the Exposure used in the effect.
  89560. */
  89561. exposure: number;
  89562. private _toneMappingEnabled;
  89563. /**
  89564. * Gets wether the tone mapping effect is enabled.
  89565. */
  89566. /**
  89567. * Sets wether the tone mapping effect is enabled.
  89568. */
  89569. toneMappingEnabled: boolean;
  89570. private _toneMappingType;
  89571. /**
  89572. * Gets the type of tone mapping effect.
  89573. */
  89574. /**
  89575. * Sets the type of tone mapping effect used in BabylonJS.
  89576. */
  89577. toneMappingType: number;
  89578. protected _contrast: number;
  89579. /**
  89580. * Gets the contrast used in the effect.
  89581. */
  89582. /**
  89583. * Sets the contrast used in the effect.
  89584. */
  89585. contrast: number;
  89586. /**
  89587. * Vignette stretch size.
  89588. */
  89589. vignetteStretch: number;
  89590. /**
  89591. * Vignette centre X Offset.
  89592. */
  89593. vignetteCentreX: number;
  89594. /**
  89595. * Vignette centre Y Offset.
  89596. */
  89597. vignetteCentreY: number;
  89598. /**
  89599. * Vignette weight or intensity of the vignette effect.
  89600. */
  89601. vignetteWeight: number;
  89602. /**
  89603. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89604. * if vignetteEnabled is set to true.
  89605. */
  89606. vignetteColor: Color4;
  89607. /**
  89608. * Camera field of view used by the Vignette effect.
  89609. */
  89610. vignetteCameraFov: number;
  89611. private _vignetteBlendMode;
  89612. /**
  89613. * Gets the vignette blend mode allowing different kind of effect.
  89614. */
  89615. /**
  89616. * Sets the vignette blend mode allowing different kind of effect.
  89617. */
  89618. vignetteBlendMode: number;
  89619. private _vignetteEnabled;
  89620. /**
  89621. * Gets wether the vignette effect is enabled.
  89622. */
  89623. /**
  89624. * Sets wether the vignette effect is enabled.
  89625. */
  89626. vignetteEnabled: boolean;
  89627. private _applyByPostProcess;
  89628. /**
  89629. * Gets wether the image processing is applied through a post process or not.
  89630. */
  89631. /**
  89632. * Sets wether the image processing is applied through a post process or not.
  89633. */
  89634. applyByPostProcess: boolean;
  89635. private _isEnabled;
  89636. /**
  89637. * Gets wether the image processing is enabled or not.
  89638. */
  89639. /**
  89640. * Sets wether the image processing is enabled or not.
  89641. */
  89642. isEnabled: boolean;
  89643. /**
  89644. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89645. */
  89646. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89647. /**
  89648. * Method called each time the image processing information changes requires to recompile the effect.
  89649. */
  89650. protected _updateParameters(): void;
  89651. /**
  89652. * Gets the current class name.
  89653. * @return "ImageProcessingConfiguration"
  89654. */
  89655. getClassName(): string;
  89656. /**
  89657. * Prepare the list of uniforms associated with the Image Processing effects.
  89658. * @param uniforms The list of uniforms used in the effect
  89659. * @param defines the list of defines currently in use
  89660. */
  89661. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89662. /**
  89663. * Prepare the list of samplers associated with the Image Processing effects.
  89664. * @param samplersList The list of uniforms used in the effect
  89665. * @param defines the list of defines currently in use
  89666. */
  89667. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89668. /**
  89669. * Prepare the list of defines associated to the shader.
  89670. * @param defines the list of defines to complete
  89671. * @param forPostProcess Define if we are currently in post process mode or not
  89672. */
  89673. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89674. /**
  89675. * Returns true if all the image processing information are ready.
  89676. * @returns True if ready, otherwise, false
  89677. */
  89678. isReady(): boolean;
  89679. /**
  89680. * Binds the image processing to the shader.
  89681. * @param effect The effect to bind to
  89682. * @param aspectRatio Define the current aspect ratio of the effect
  89683. */
  89684. bind(effect: Effect, aspectRatio?: number): void;
  89685. /**
  89686. * Clones the current image processing instance.
  89687. * @return The cloned image processing
  89688. */
  89689. clone(): ImageProcessingConfiguration;
  89690. /**
  89691. * Serializes the current image processing instance to a json representation.
  89692. * @return a JSON representation
  89693. */
  89694. serialize(): any;
  89695. /**
  89696. * Parses the image processing from a json representation.
  89697. * @param source the JSON source to parse
  89698. * @return The parsed image processing
  89699. */
  89700. static Parse(source: any): ImageProcessingConfiguration;
  89701. private static _VIGNETTEMODE_MULTIPLY;
  89702. private static _VIGNETTEMODE_OPAQUE;
  89703. /**
  89704. * Used to apply the vignette as a mix with the pixel color.
  89705. */
  89706. static readonly VIGNETTEMODE_MULTIPLY: number;
  89707. /**
  89708. * Used to apply the vignette as a replacement of the pixel color.
  89709. */
  89710. static readonly VIGNETTEMODE_OPAQUE: number;
  89711. }
  89712. }
  89713. declare module BABYLON {
  89714. /**
  89715. * This represents all the required information to add a fresnel effect on a material:
  89716. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  89717. */
  89718. export class FresnelParameters {
  89719. private _isEnabled;
  89720. /**
  89721. * Define if the fresnel effect is enable or not.
  89722. */
  89723. isEnabled: boolean;
  89724. /**
  89725. * Define the color used on edges (grazing angle)
  89726. */
  89727. leftColor: Color3;
  89728. /**
  89729. * Define the color used on center
  89730. */
  89731. rightColor: Color3;
  89732. /**
  89733. * Define bias applied to computed fresnel term
  89734. */
  89735. bias: number;
  89736. /**
  89737. * Defined the power exponent applied to fresnel term
  89738. */
  89739. power: number;
  89740. /**
  89741. * Clones the current fresnel and its valuues
  89742. * @returns a clone fresnel configuration
  89743. */
  89744. clone(): FresnelParameters;
  89745. /**
  89746. * Serializes the current fresnel parameters to a JSON representation.
  89747. * @return the JSON serialization
  89748. */
  89749. serialize(): any;
  89750. /**
  89751. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  89752. * @param parsedFresnelParameters Define the JSON representation
  89753. * @returns the parsed parameters
  89754. */
  89755. static Parse(parsedFresnelParameters: any): FresnelParameters;
  89756. }
  89757. }
  89758. declare module BABYLON {
  89759. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  89760. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89761. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89762. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89763. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89764. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89765. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89766. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89767. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89768. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89769. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89770. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89771. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89772. /**
  89773. * Decorator used to define property that can be serialized as reference to a camera
  89774. * @param sourceName defines the name of the property to decorate
  89775. */
  89776. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89777. /**
  89778. * Class used to help serialization objects
  89779. */
  89780. export class SerializationHelper {
  89781. /** hidden */
  89782. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  89783. /** hidden */
  89784. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  89785. /** hidden */
  89786. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  89787. /** hidden */
  89788. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  89789. /**
  89790. * Appends the serialized animations from the source animations
  89791. * @param source Source containing the animations
  89792. * @param destination Target to store the animations
  89793. */
  89794. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  89795. /**
  89796. * Static function used to serialized a specific entity
  89797. * @param entity defines the entity to serialize
  89798. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  89799. * @returns a JSON compatible object representing the serialization of the entity
  89800. */
  89801. static Serialize<T>(entity: T, serializationObject?: any): any;
  89802. /**
  89803. * Creates a new entity from a serialization data object
  89804. * @param creationFunction defines a function used to instanciated the new entity
  89805. * @param source defines the source serialization data
  89806. * @param scene defines the hosting scene
  89807. * @param rootUrl defines the root url for resources
  89808. * @returns a new entity
  89809. */
  89810. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  89811. /**
  89812. * Clones an object
  89813. * @param creationFunction defines the function used to instanciate the new object
  89814. * @param source defines the source object
  89815. * @returns the cloned object
  89816. */
  89817. static Clone<T>(creationFunction: () => T, source: T): T;
  89818. /**
  89819. * Instanciates a new object based on a source one (some data will be shared between both object)
  89820. * @param creationFunction defines the function used to instanciate the new object
  89821. * @param source defines the source object
  89822. * @returns the new object
  89823. */
  89824. static Instanciate<T>(creationFunction: () => T, source: T): T;
  89825. }
  89826. }
  89827. declare module BABYLON {
  89828. /**
  89829. * This is the base class of all the camera used in the application.
  89830. * @see http://doc.babylonjs.com/features/cameras
  89831. */
  89832. export class Camera extends Node {
  89833. /** @hidden */
  89834. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  89835. /**
  89836. * This is the default projection mode used by the cameras.
  89837. * It helps recreating a feeling of perspective and better appreciate depth.
  89838. * This is the best way to simulate real life cameras.
  89839. */
  89840. static readonly PERSPECTIVE_CAMERA: number;
  89841. /**
  89842. * This helps creating camera with an orthographic mode.
  89843. * 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.
  89844. */
  89845. static readonly ORTHOGRAPHIC_CAMERA: number;
  89846. /**
  89847. * This is the default FOV mode for perspective cameras.
  89848. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  89849. */
  89850. static readonly FOVMODE_VERTICAL_FIXED: number;
  89851. /**
  89852. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  89853. */
  89854. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  89855. /**
  89856. * This specifies ther is no need for a camera rig.
  89857. * Basically only one eye is rendered corresponding to the camera.
  89858. */
  89859. static readonly RIG_MODE_NONE: number;
  89860. /**
  89861. * Simulates a camera Rig with one blue eye and one red eye.
  89862. * This can be use with 3d blue and red glasses.
  89863. */
  89864. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  89865. /**
  89866. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  89867. */
  89868. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  89869. /**
  89870. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  89871. */
  89872. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  89873. /**
  89874. * Defines that both eyes of the camera will be rendered over under each other.
  89875. */
  89876. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  89877. /**
  89878. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  89879. */
  89880. static readonly RIG_MODE_VR: number;
  89881. /**
  89882. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  89883. */
  89884. static readonly RIG_MODE_WEBVR: number;
  89885. /**
  89886. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  89887. */
  89888. static readonly RIG_MODE_CUSTOM: number;
  89889. /**
  89890. * Defines if by default attaching controls should prevent the default javascript event to continue.
  89891. */
  89892. static ForceAttachControlToAlwaysPreventDefault: boolean;
  89893. /**
  89894. * Define the input manager associated with the camera.
  89895. */
  89896. inputs: CameraInputsManager<Camera>;
  89897. /** @hidden */
  89898. _position: Vector3;
  89899. /**
  89900. * Define the current local position of the camera in the scene
  89901. */
  89902. position: Vector3;
  89903. /**
  89904. * The vector the camera should consider as up.
  89905. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  89906. */
  89907. upVector: Vector3;
  89908. /**
  89909. * Define the current limit on the left side for an orthographic camera
  89910. * In scene unit
  89911. */
  89912. orthoLeft: Nullable<number>;
  89913. /**
  89914. * Define the current limit on the right side for an orthographic camera
  89915. * In scene unit
  89916. */
  89917. orthoRight: Nullable<number>;
  89918. /**
  89919. * Define the current limit on the bottom side for an orthographic camera
  89920. * In scene unit
  89921. */
  89922. orthoBottom: Nullable<number>;
  89923. /**
  89924. * Define the current limit on the top side for an orthographic camera
  89925. * In scene unit
  89926. */
  89927. orthoTop: Nullable<number>;
  89928. /**
  89929. * Field Of View is set in Radians. (default is 0.8)
  89930. */
  89931. fov: number;
  89932. /**
  89933. * Define the minimum distance the camera can see from.
  89934. * This is important to note that the depth buffer are not infinite and the closer it starts
  89935. * the more your scene might encounter depth fighting issue.
  89936. */
  89937. minZ: number;
  89938. /**
  89939. * Define the maximum distance the camera can see to.
  89940. * This is important to note that the depth buffer are not infinite and the further it end
  89941. * the more your scene might encounter depth fighting issue.
  89942. */
  89943. maxZ: number;
  89944. /**
  89945. * Define the default inertia of the camera.
  89946. * This helps giving a smooth feeling to the camera movement.
  89947. */
  89948. inertia: number;
  89949. /**
  89950. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  89951. */
  89952. mode: number;
  89953. /**
  89954. * Define wether the camera is intermediate.
  89955. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  89956. */
  89957. isIntermediate: boolean;
  89958. /**
  89959. * Define the viewport of the camera.
  89960. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  89961. */
  89962. viewport: Viewport;
  89963. /**
  89964. * Restricts the camera to viewing objects with the same layerMask.
  89965. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  89966. */
  89967. layerMask: number;
  89968. /**
  89969. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  89970. */
  89971. fovMode: number;
  89972. /**
  89973. * Rig mode of the camera.
  89974. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  89975. * This is normally controlled byt the camera themselves as internal use.
  89976. */
  89977. cameraRigMode: number;
  89978. /**
  89979. * Defines the distance between both "eyes" in case of a RIG
  89980. */
  89981. interaxialDistance: number;
  89982. /**
  89983. * Defines if stereoscopic rendering is done side by side or over under.
  89984. */
  89985. isStereoscopicSideBySide: boolean;
  89986. /**
  89987. * 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
  89988. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  89989. * else in the scene.
  89990. */
  89991. customRenderTargets: RenderTargetTexture[];
  89992. /**
  89993. * When set, the camera will render to this render target instead of the default canvas
  89994. */
  89995. outputRenderTarget: Nullable<RenderTargetTexture>;
  89996. /**
  89997. * Observable triggered when the camera view matrix has changed.
  89998. */
  89999. onViewMatrixChangedObservable: Observable<Camera>;
  90000. /**
  90001. * Observable triggered when the camera Projection matrix has changed.
  90002. */
  90003. onProjectionMatrixChangedObservable: Observable<Camera>;
  90004. /**
  90005. * Observable triggered when the inputs have been processed.
  90006. */
  90007. onAfterCheckInputsObservable: Observable<Camera>;
  90008. /**
  90009. * Observable triggered when reset has been called and applied to the camera.
  90010. */
  90011. onRestoreStateObservable: Observable<Camera>;
  90012. /** @hidden */
  90013. _cameraRigParams: any;
  90014. /** @hidden */
  90015. _rigCameras: Camera[];
  90016. /** @hidden */
  90017. _rigPostProcess: Nullable<PostProcess>;
  90018. protected _webvrViewMatrix: Matrix;
  90019. /** @hidden */
  90020. _skipRendering: boolean;
  90021. /** @hidden */
  90022. _projectionMatrix: Matrix;
  90023. /** @hidden */
  90024. _postProcesses: Nullable<PostProcess>[];
  90025. /** @hidden */
  90026. _activeMeshes: SmartArray<AbstractMesh>;
  90027. protected _globalPosition: Vector3;
  90028. /** hidden */
  90029. _computedViewMatrix: Matrix;
  90030. private _doNotComputeProjectionMatrix;
  90031. private _transformMatrix;
  90032. private _frustumPlanes;
  90033. private _refreshFrustumPlanes;
  90034. private _storedFov;
  90035. private _stateStored;
  90036. /**
  90037. * Instantiates a new camera object.
  90038. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  90039. * @see http://doc.babylonjs.com/features/cameras
  90040. * @param name Defines the name of the camera in the scene
  90041. * @param position Defines the position of the camera
  90042. * @param scene Defines the scene the camera belongs too
  90043. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  90044. */
  90045. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90046. /**
  90047. * Store current camera state (fov, position, etc..)
  90048. * @returns the camera
  90049. */
  90050. storeState(): Camera;
  90051. /**
  90052. * Restores the camera state values if it has been stored. You must call storeState() first
  90053. */
  90054. protected _restoreStateValues(): boolean;
  90055. /**
  90056. * Restored camera state. You must call storeState() first.
  90057. * @returns true if restored and false otherwise
  90058. */
  90059. restoreState(): boolean;
  90060. /**
  90061. * Gets the class name of the camera.
  90062. * @returns the class name
  90063. */
  90064. getClassName(): string;
  90065. /** @hidden */
  90066. readonly _isCamera: boolean;
  90067. /**
  90068. * Gets a string representation of the camera useful for debug purpose.
  90069. * @param fullDetails Defines that a more verboe level of logging is required
  90070. * @returns the string representation
  90071. */
  90072. toString(fullDetails?: boolean): string;
  90073. /**
  90074. * Gets the current world space position of the camera.
  90075. */
  90076. readonly globalPosition: Vector3;
  90077. /**
  90078. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  90079. * @returns the active meshe list
  90080. */
  90081. getActiveMeshes(): SmartArray<AbstractMesh>;
  90082. /**
  90083. * Check wether a mesh is part of the current active mesh list of the camera
  90084. * @param mesh Defines the mesh to check
  90085. * @returns true if active, false otherwise
  90086. */
  90087. isActiveMesh(mesh: Mesh): boolean;
  90088. /**
  90089. * Is this camera ready to be used/rendered
  90090. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  90091. * @return true if the camera is ready
  90092. */
  90093. isReady(completeCheck?: boolean): boolean;
  90094. /** @hidden */
  90095. _initCache(): void;
  90096. /** @hidden */
  90097. _updateCache(ignoreParentClass?: boolean): void;
  90098. /** @hidden */
  90099. _isSynchronized(): boolean;
  90100. /** @hidden */
  90101. _isSynchronizedViewMatrix(): boolean;
  90102. /** @hidden */
  90103. _isSynchronizedProjectionMatrix(): boolean;
  90104. /**
  90105. * Attach the input controls to a specific dom element to get the input from.
  90106. * @param element Defines the element the controls should be listened from
  90107. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90108. */
  90109. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90110. /**
  90111. * Detach the current controls from the specified dom element.
  90112. * @param element Defines the element to stop listening the inputs from
  90113. */
  90114. detachControl(element: HTMLElement): void;
  90115. /**
  90116. * Update the camera state according to the different inputs gathered during the frame.
  90117. */
  90118. update(): void;
  90119. /** @hidden */
  90120. _checkInputs(): void;
  90121. /** @hidden */
  90122. readonly rigCameras: Camera[];
  90123. /**
  90124. * Gets the post process used by the rig cameras
  90125. */
  90126. readonly rigPostProcess: Nullable<PostProcess>;
  90127. /**
  90128. * Internal, gets the first post proces.
  90129. * @returns the first post process to be run on this camera.
  90130. */
  90131. _getFirstPostProcess(): Nullable<PostProcess>;
  90132. private _cascadePostProcessesToRigCams;
  90133. /**
  90134. * Attach a post process to the camera.
  90135. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90136. * @param postProcess The post process to attach to the camera
  90137. * @param insertAt The position of the post process in case several of them are in use in the scene
  90138. * @returns the position the post process has been inserted at
  90139. */
  90140. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  90141. /**
  90142. * Detach a post process to the camera.
  90143. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90144. * @param postProcess The post process to detach from the camera
  90145. */
  90146. detachPostProcess(postProcess: PostProcess): void;
  90147. /**
  90148. * Gets the current world matrix of the camera
  90149. */
  90150. getWorldMatrix(): Matrix;
  90151. /** @hidden */
  90152. _getViewMatrix(): Matrix;
  90153. /**
  90154. * Gets the current view matrix of the camera.
  90155. * @param force forces the camera to recompute the matrix without looking at the cached state
  90156. * @returns the view matrix
  90157. */
  90158. getViewMatrix(force?: boolean): Matrix;
  90159. /**
  90160. * Freeze the projection matrix.
  90161. * It will prevent the cache check of the camera projection compute and can speed up perf
  90162. * if no parameter of the camera are meant to change
  90163. * @param projection Defines manually a projection if necessary
  90164. */
  90165. freezeProjectionMatrix(projection?: Matrix): void;
  90166. /**
  90167. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  90168. */
  90169. unfreezeProjectionMatrix(): void;
  90170. /**
  90171. * Gets the current projection matrix of the camera.
  90172. * @param force forces the camera to recompute the matrix without looking at the cached state
  90173. * @returns the projection matrix
  90174. */
  90175. getProjectionMatrix(force?: boolean): Matrix;
  90176. /**
  90177. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  90178. * @returns a Matrix
  90179. */
  90180. getTransformationMatrix(): Matrix;
  90181. private _updateFrustumPlanes;
  90182. /**
  90183. * Checks if a cullable object (mesh...) is in the camera frustum
  90184. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  90185. * @param target The object to check
  90186. * @returns true if the object is in frustum otherwise false
  90187. */
  90188. isInFrustum(target: ICullable): boolean;
  90189. /**
  90190. * Checks if a cullable object (mesh...) is in the camera frustum
  90191. * Unlike isInFrustum this cheks the full bounding box
  90192. * @param target The object to check
  90193. * @returns true if the object is in frustum otherwise false
  90194. */
  90195. isCompletelyInFrustum(target: ICullable): boolean;
  90196. /**
  90197. * Gets a ray in the forward direction from the camera.
  90198. * @param length Defines the length of the ray to create
  90199. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  90200. * @param origin Defines the start point of the ray which defaults to the camera position
  90201. * @returns the forward ray
  90202. */
  90203. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  90204. /**
  90205. * Releases resources associated with this node.
  90206. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90207. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90208. */
  90209. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90210. /** @hidden */
  90211. _isLeftCamera: boolean;
  90212. /**
  90213. * Gets the left camera of a rig setup in case of Rigged Camera
  90214. */
  90215. readonly isLeftCamera: boolean;
  90216. /** @hidden */
  90217. _isRightCamera: boolean;
  90218. /**
  90219. * Gets the right camera of a rig setup in case of Rigged Camera
  90220. */
  90221. readonly isRightCamera: boolean;
  90222. /**
  90223. * Gets the left camera of a rig setup in case of Rigged Camera
  90224. */
  90225. readonly leftCamera: Nullable<FreeCamera>;
  90226. /**
  90227. * Gets the right camera of a rig setup in case of Rigged Camera
  90228. */
  90229. readonly rightCamera: Nullable<FreeCamera>;
  90230. /**
  90231. * Gets the left camera target of a rig setup in case of Rigged Camera
  90232. * @returns the target position
  90233. */
  90234. getLeftTarget(): Nullable<Vector3>;
  90235. /**
  90236. * Gets the right camera target of a rig setup in case of Rigged Camera
  90237. * @returns the target position
  90238. */
  90239. getRightTarget(): Nullable<Vector3>;
  90240. /**
  90241. * @hidden
  90242. */
  90243. setCameraRigMode(mode: number, rigParams: any): void;
  90244. /** @hidden */
  90245. static _setStereoscopicRigMode(camera: Camera): void;
  90246. /** @hidden */
  90247. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  90248. /** @hidden */
  90249. static _setVRRigMode(camera: Camera, rigParams: any): void;
  90250. /** @hidden */
  90251. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  90252. /** @hidden */
  90253. _getVRProjectionMatrix(): Matrix;
  90254. protected _updateCameraRotationMatrix(): void;
  90255. protected _updateWebVRCameraRotationMatrix(): void;
  90256. /**
  90257. * This function MUST be overwritten by the different WebVR cameras available.
  90258. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90259. * @hidden
  90260. */
  90261. _getWebVRProjectionMatrix(): Matrix;
  90262. /**
  90263. * This function MUST be overwritten by the different WebVR cameras available.
  90264. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90265. * @hidden
  90266. */
  90267. _getWebVRViewMatrix(): Matrix;
  90268. /** @hidden */
  90269. setCameraRigParameter(name: string, value: any): void;
  90270. /**
  90271. * needs to be overridden by children so sub has required properties to be copied
  90272. * @hidden
  90273. */
  90274. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90275. /**
  90276. * May need to be overridden by children
  90277. * @hidden
  90278. */
  90279. _updateRigCameras(): void;
  90280. /** @hidden */
  90281. _setupInputs(): void;
  90282. /**
  90283. * Serialiaze the camera setup to a json represention
  90284. * @returns the JSON representation
  90285. */
  90286. serialize(): any;
  90287. /**
  90288. * Clones the current camera.
  90289. * @param name The cloned camera name
  90290. * @returns the cloned camera
  90291. */
  90292. clone(name: string): Camera;
  90293. /**
  90294. * Gets the direction of the camera relative to a given local axis.
  90295. * @param localAxis Defines the reference axis to provide a relative direction.
  90296. * @return the direction
  90297. */
  90298. getDirection(localAxis: Vector3): Vector3;
  90299. /**
  90300. * Gets the direction of the camera relative to a given local axis into a passed vector.
  90301. * @param localAxis Defines the reference axis to provide a relative direction.
  90302. * @param result Defines the vector to store the result in
  90303. */
  90304. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  90305. /**
  90306. * Gets a camera constructor for a given camera type
  90307. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  90308. * @param name The name of the camera the result will be able to instantiate
  90309. * @param scene The scene the result will construct the camera in
  90310. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  90311. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  90312. * @returns a factory method to construc the camera
  90313. */
  90314. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  90315. /**
  90316. * Compute the world matrix of the camera.
  90317. * @returns the camera workd matrix
  90318. */
  90319. computeWorldMatrix(): Matrix;
  90320. /**
  90321. * Parse a JSON and creates the camera from the parsed information
  90322. * @param parsedCamera The JSON to parse
  90323. * @param scene The scene to instantiate the camera in
  90324. * @returns the newly constructed camera
  90325. */
  90326. static Parse(parsedCamera: any, scene: Scene): Camera;
  90327. }
  90328. }
  90329. declare module BABYLON {
  90330. /**
  90331. * Interface for any object that can request an animation frame
  90332. */
  90333. export interface ICustomAnimationFrameRequester {
  90334. /**
  90335. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  90336. */
  90337. renderFunction?: Function;
  90338. /**
  90339. * Called to request the next frame to render to
  90340. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  90341. */
  90342. requestAnimationFrame: Function;
  90343. /**
  90344. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  90345. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  90346. */
  90347. requestID?: number;
  90348. }
  90349. /**
  90350. * Interface containing an array of animations
  90351. */
  90352. export interface IAnimatable {
  90353. /**
  90354. * Array of animations
  90355. */
  90356. animations: Nullable<Array<Animation>>;
  90357. }
  90358. /** Interface used by value gradients (color, factor, ...) */
  90359. export interface IValueGradient {
  90360. /**
  90361. * Gets or sets the gradient value (between 0 and 1)
  90362. */
  90363. gradient: number;
  90364. }
  90365. /** Class used to store color4 gradient */
  90366. export class ColorGradient implements IValueGradient {
  90367. /**
  90368. * Gets or sets the gradient value (between 0 and 1)
  90369. */
  90370. gradient: number;
  90371. /**
  90372. * Gets or sets first associated color
  90373. */
  90374. color1: Color4;
  90375. /**
  90376. * Gets or sets second associated color
  90377. */
  90378. color2?: Color4;
  90379. /**
  90380. * Will get a color picked randomly between color1 and color2.
  90381. * If color2 is undefined then color1 will be used
  90382. * @param result defines the target Color4 to store the result in
  90383. */
  90384. getColorToRef(result: Color4): void;
  90385. }
  90386. /** Class used to store color 3 gradient */
  90387. export class Color3Gradient implements IValueGradient {
  90388. /**
  90389. * Gets or sets the gradient value (between 0 and 1)
  90390. */
  90391. gradient: number;
  90392. /**
  90393. * Gets or sets the associated color
  90394. */
  90395. color: Color3;
  90396. }
  90397. /** Class used to store factor gradient */
  90398. export class FactorGradient implements IValueGradient {
  90399. /**
  90400. * Gets or sets the gradient value (between 0 and 1)
  90401. */
  90402. gradient: number;
  90403. /**
  90404. * Gets or sets first associated factor
  90405. */
  90406. factor1: number;
  90407. /**
  90408. * Gets or sets second associated factor
  90409. */
  90410. factor2?: number;
  90411. /**
  90412. * Will get a number picked randomly between factor1 and factor2.
  90413. * If factor2 is undefined then factor1 will be used
  90414. * @returns the picked number
  90415. */
  90416. getFactor(): number;
  90417. }
  90418. /**
  90419. * @ignore
  90420. * Application error to support additional information when loading a file
  90421. */
  90422. export class LoadFileError extends Error {
  90423. /** defines the optional web request */
  90424. request?: WebRequest | undefined;
  90425. private static _setPrototypeOf;
  90426. /**
  90427. * Creates a new LoadFileError
  90428. * @param message defines the message of the error
  90429. * @param request defines the optional web request
  90430. */
  90431. constructor(message: string,
  90432. /** defines the optional web request */
  90433. request?: WebRequest | undefined);
  90434. }
  90435. /**
  90436. * Class used to define a retry strategy when error happens while loading assets
  90437. */
  90438. export class RetryStrategy {
  90439. /**
  90440. * Function used to defines an exponential back off strategy
  90441. * @param maxRetries defines the maximum number of retries (3 by default)
  90442. * @param baseInterval defines the interval between retries
  90443. * @returns the strategy function to use
  90444. */
  90445. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  90446. }
  90447. /**
  90448. * File request interface
  90449. */
  90450. export interface IFileRequest {
  90451. /**
  90452. * Raised when the request is complete (success or error).
  90453. */
  90454. onCompleteObservable: Observable<IFileRequest>;
  90455. /**
  90456. * Aborts the request for a file.
  90457. */
  90458. abort: () => void;
  90459. }
  90460. /**
  90461. * Class containing a set of static utilities functions
  90462. */
  90463. export class Tools {
  90464. /**
  90465. * Gets or sets the base URL to use to load assets
  90466. */
  90467. static BaseUrl: string;
  90468. /**
  90469. * Enable/Disable Custom HTTP Request Headers globally.
  90470. * default = false
  90471. * @see CustomRequestHeaders
  90472. */
  90473. static UseCustomRequestHeaders: boolean;
  90474. /**
  90475. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  90476. * i.e. when loading files, where the server/service expects an Authorization header
  90477. */
  90478. static CustomRequestHeaders: {
  90479. [key: string]: string;
  90480. };
  90481. /**
  90482. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  90483. */
  90484. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  90485. /**
  90486. * Default behaviour for cors in the application.
  90487. * It can be a string if the expected behavior is identical in the entire app.
  90488. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  90489. */
  90490. static CorsBehavior: string | ((url: string | string[]) => string);
  90491. /**
  90492. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  90493. * @ignorenaming
  90494. */
  90495. static UseFallbackTexture: boolean;
  90496. /**
  90497. * Use this object to register external classes like custom textures or material
  90498. * to allow the laoders to instantiate them
  90499. */
  90500. static RegisteredExternalClasses: {
  90501. [key: string]: Object;
  90502. };
  90503. /**
  90504. * Texture content used if a texture cannot loaded
  90505. * @ignorenaming
  90506. */
  90507. static fallbackTexture: string;
  90508. /**
  90509. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  90510. * @param u defines the coordinate on X axis
  90511. * @param v defines the coordinate on Y axis
  90512. * @param width defines the width of the source data
  90513. * @param height defines the height of the source data
  90514. * @param pixels defines the source byte array
  90515. * @param color defines the output color
  90516. */
  90517. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  90518. /**
  90519. * Interpolates between a and b via alpha
  90520. * @param a The lower value (returned when alpha = 0)
  90521. * @param b The upper value (returned when alpha = 1)
  90522. * @param alpha The interpolation-factor
  90523. * @return The mixed value
  90524. */
  90525. static Mix(a: number, b: number, alpha: number): number;
  90526. /**
  90527. * Tries to instantiate a new object from a given class name
  90528. * @param className defines the class name to instantiate
  90529. * @returns the new object or null if the system was not able to do the instantiation
  90530. */
  90531. static Instantiate(className: string): any;
  90532. /**
  90533. * Provides a slice function that will work even on IE
  90534. * @param data defines the array to slice
  90535. * @param start defines the start of the data (optional)
  90536. * @param end defines the end of the data (optional)
  90537. * @returns the new sliced array
  90538. */
  90539. static Slice<T>(data: T, start?: number, end?: number): T;
  90540. /**
  90541. * Polyfill for setImmediate
  90542. * @param action defines the action to execute after the current execution block
  90543. */
  90544. static SetImmediate(action: () => void): void;
  90545. /**
  90546. * Function indicating if a number is an exponent of 2
  90547. * @param value defines the value to test
  90548. * @returns true if the value is an exponent of 2
  90549. */
  90550. static IsExponentOfTwo(value: number): boolean;
  90551. private static _tmpFloatArray;
  90552. /**
  90553. * Returns the nearest 32-bit single precision float representation of a Number
  90554. * @param value A Number. If the parameter is of a different type, it will get converted
  90555. * to a number or to NaN if it cannot be converted
  90556. * @returns number
  90557. */
  90558. static FloatRound(value: number): number;
  90559. /**
  90560. * Find the next highest power of two.
  90561. * @param x Number to start search from.
  90562. * @return Next highest power of two.
  90563. */
  90564. static CeilingPOT(x: number): number;
  90565. /**
  90566. * Find the next lowest power of two.
  90567. * @param x Number to start search from.
  90568. * @return Next lowest power of two.
  90569. */
  90570. static FloorPOT(x: number): number;
  90571. /**
  90572. * Find the nearest power of two.
  90573. * @param x Number to start search from.
  90574. * @return Next nearest power of two.
  90575. */
  90576. static NearestPOT(x: number): number;
  90577. /**
  90578. * Get the closest exponent of two
  90579. * @param value defines the value to approximate
  90580. * @param max defines the maximum value to return
  90581. * @param mode defines how to define the closest value
  90582. * @returns closest exponent of two of the given value
  90583. */
  90584. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  90585. /**
  90586. * Extracts the filename from a path
  90587. * @param path defines the path to use
  90588. * @returns the filename
  90589. */
  90590. static GetFilename(path: string): string;
  90591. /**
  90592. * Extracts the "folder" part of a path (everything before the filename).
  90593. * @param uri The URI to extract the info from
  90594. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  90595. * @returns The "folder" part of the path
  90596. */
  90597. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  90598. /**
  90599. * Extracts text content from a DOM element hierarchy
  90600. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  90601. */
  90602. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  90603. /**
  90604. * Convert an angle in radians to degrees
  90605. * @param angle defines the angle to convert
  90606. * @returns the angle in degrees
  90607. */
  90608. static ToDegrees(angle: number): number;
  90609. /**
  90610. * Convert an angle in degrees to radians
  90611. * @param angle defines the angle to convert
  90612. * @returns the angle in radians
  90613. */
  90614. static ToRadians(angle: number): number;
  90615. /**
  90616. * Encode a buffer to a base64 string
  90617. * @param buffer defines the buffer to encode
  90618. * @returns the encoded string
  90619. */
  90620. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  90621. /**
  90622. * Extracts minimum and maximum values from a list of indexed positions
  90623. * @param positions defines the positions to use
  90624. * @param indices defines the indices to the positions
  90625. * @param indexStart defines the start index
  90626. * @param indexCount defines the end index
  90627. * @param bias defines bias value to add to the result
  90628. * @return minimum and maximum values
  90629. */
  90630. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  90631. minimum: Vector3;
  90632. maximum: Vector3;
  90633. };
  90634. /**
  90635. * Extracts minimum and maximum values from a list of positions
  90636. * @param positions defines the positions to use
  90637. * @param start defines the start index in the positions array
  90638. * @param count defines the number of positions to handle
  90639. * @param bias defines bias value to add to the result
  90640. * @param stride defines the stride size to use (distance between two positions in the positions array)
  90641. * @return minimum and maximum values
  90642. */
  90643. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  90644. minimum: Vector3;
  90645. maximum: Vector3;
  90646. };
  90647. /**
  90648. * Returns an array if obj is not an array
  90649. * @param obj defines the object to evaluate as an array
  90650. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  90651. * @returns either obj directly if obj is an array or a new array containing obj
  90652. */
  90653. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  90654. /**
  90655. * Gets the pointer prefix to use
  90656. * @returns "pointer" if touch is enabled. Else returns "mouse"
  90657. */
  90658. static GetPointerPrefix(): string;
  90659. /**
  90660. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  90661. * @param func - the function to be called
  90662. * @param requester - the object that will request the next frame. Falls back to window.
  90663. * @returns frame number
  90664. */
  90665. static QueueNewFrame(func: () => void, requester?: any): number;
  90666. /**
  90667. * Ask the browser to promote the current element to fullscreen rendering mode
  90668. * @param element defines the DOM element to promote
  90669. */
  90670. static RequestFullscreen(element: HTMLElement): void;
  90671. /**
  90672. * Asks the browser to exit fullscreen mode
  90673. */
  90674. static ExitFullscreen(): void;
  90675. /**
  90676. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  90677. * @param url define the url we are trying
  90678. * @param element define the dom element where to configure the cors policy
  90679. */
  90680. static SetCorsBehavior(url: string | string[], element: {
  90681. crossOrigin: string | null;
  90682. }): void;
  90683. /**
  90684. * Removes unwanted characters from an url
  90685. * @param url defines the url to clean
  90686. * @returns the cleaned url
  90687. */
  90688. static CleanUrl(url: string): string;
  90689. /**
  90690. * Gets or sets a function used to pre-process url before using them to load assets
  90691. */
  90692. static PreprocessUrl: (url: string) => string;
  90693. /**
  90694. * Loads an image as an HTMLImageElement.
  90695. * @param input url string, ArrayBuffer, or Blob to load
  90696. * @param onLoad callback called when the image successfully loads
  90697. * @param onError callback called when the image fails to load
  90698. * @param offlineProvider offline provider for caching
  90699. * @returns the HTMLImageElement of the loaded image
  90700. */
  90701. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  90702. /**
  90703. * Loads a file
  90704. * @param url url string, ArrayBuffer, or Blob to load
  90705. * @param onSuccess callback called when the file successfully loads
  90706. * @param onProgress callback called while file is loading (if the server supports this mode)
  90707. * @param offlineProvider defines the offline provider for caching
  90708. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  90709. * @param onError callback called when the file fails to load
  90710. * @returns a file request object
  90711. */
  90712. 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;
  90713. /**
  90714. * Load a script (identified by an url). When the url returns, the
  90715. * content of this file is added into a new script element, attached to the DOM (body element)
  90716. * @param scriptUrl defines the url of the script to laod
  90717. * @param onSuccess defines the callback called when the script is loaded
  90718. * @param onError defines the callback to call if an error occurs
  90719. * @param scriptId defines the id of the script element
  90720. */
  90721. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  90722. /**
  90723. * Load an asynchronous script (identified by an url). When the url returns, the
  90724. * content of this file is added into a new script element, attached to the DOM (body element)
  90725. * @param scriptUrl defines the url of the script to laod
  90726. * @param scriptId defines the id of the script element
  90727. * @returns a promise request object
  90728. */
  90729. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  90730. /**
  90731. * Loads a file from a blob
  90732. * @param fileToLoad defines the blob to use
  90733. * @param callback defines the callback to call when data is loaded
  90734. * @param progressCallback defines the callback to call during loading process
  90735. * @returns a file request object
  90736. */
  90737. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  90738. /**
  90739. * Loads a file
  90740. * @param fileToLoad defines the file to load
  90741. * @param callback defines the callback to call when data is loaded
  90742. * @param progressCallBack defines the callback to call during loading process
  90743. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  90744. * @returns a file request object
  90745. */
  90746. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  90747. /**
  90748. * Creates a data url from a given string content
  90749. * @param content defines the content to convert
  90750. * @returns the new data url link
  90751. */
  90752. static FileAsURL(content: string): string;
  90753. /**
  90754. * Format the given number to a specific decimal format
  90755. * @param value defines the number to format
  90756. * @param decimals defines the number of decimals to use
  90757. * @returns the formatted string
  90758. */
  90759. static Format(value: number, decimals?: number): string;
  90760. /**
  90761. * Checks if a given vector is inside a specific range
  90762. * @param v defines the vector to test
  90763. * @param min defines the minimum range
  90764. * @param max defines the maximum range
  90765. */
  90766. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  90767. /**
  90768. * Tries to copy an object by duplicating every property
  90769. * @param source defines the source object
  90770. * @param destination defines the target object
  90771. * @param doNotCopyList defines a list of properties to avoid
  90772. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  90773. */
  90774. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  90775. /**
  90776. * Gets a boolean indicating if the given object has no own property
  90777. * @param obj defines the object to test
  90778. * @returns true if object has no own property
  90779. */
  90780. static IsEmpty(obj: any): boolean;
  90781. /**
  90782. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  90783. * @param str Source string
  90784. * @param suffix Suffix to search for in the source string
  90785. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  90786. */
  90787. static EndsWith(str: string, suffix: string): boolean;
  90788. /**
  90789. * Function used to register events at window level
  90790. * @param events defines the events to register
  90791. */
  90792. static RegisterTopRootEvents(events: {
  90793. name: string;
  90794. handler: Nullable<(e: FocusEvent) => any>;
  90795. }[]): void;
  90796. /**
  90797. * Function used to unregister events from window level
  90798. * @param events defines the events to unregister
  90799. */
  90800. static UnregisterTopRootEvents(events: {
  90801. name: string;
  90802. handler: Nullable<(e: FocusEvent) => any>;
  90803. }[]): void;
  90804. /**
  90805. * @ignore
  90806. */
  90807. static _ScreenshotCanvas: HTMLCanvasElement;
  90808. /**
  90809. * Dumps the current bound framebuffer
  90810. * @param width defines the rendering width
  90811. * @param height defines the rendering height
  90812. * @param engine defines the hosting engine
  90813. * @param successCallback defines the callback triggered once the data are available
  90814. * @param mimeType defines the mime type of the result
  90815. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  90816. */
  90817. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  90818. /**
  90819. * Converts the canvas data to blob.
  90820. * This acts as a polyfill for browsers not supporting the to blob function.
  90821. * @param canvas Defines the canvas to extract the data from
  90822. * @param successCallback Defines the callback triggered once the data are available
  90823. * @param mimeType Defines the mime type of the result
  90824. */
  90825. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  90826. /**
  90827. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  90828. * @param successCallback defines the callback triggered once the data are available
  90829. * @param mimeType defines the mime type of the result
  90830. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  90831. */
  90832. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  90833. /**
  90834. * Downloads a blob in the browser
  90835. * @param blob defines the blob to download
  90836. * @param fileName defines the name of the downloaded file
  90837. */
  90838. static Download(blob: Blob, fileName: string): void;
  90839. /**
  90840. * Captures a screenshot of the current rendering
  90841. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  90842. * @param engine defines the rendering engine
  90843. * @param camera defines the source camera
  90844. * @param size This parameter can be set to a single number or to an object with the
  90845. * following (optional) properties: precision, width, height. If a single number is passed,
  90846. * it will be used for both width and height. If an object is passed, the screenshot size
  90847. * will be derived from the parameters. The precision property is a multiplier allowing
  90848. * rendering at a higher or lower resolution
  90849. * @param successCallback defines the callback receives a single parameter which contains the
  90850. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  90851. * src parameter of an <img> to display it
  90852. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  90853. * Check your browser for supported MIME types
  90854. */
  90855. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  90856. /**
  90857. * Generates an image screenshot from the specified camera.
  90858. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  90859. * @param engine The engine to use for rendering
  90860. * @param camera The camera to use for rendering
  90861. * @param size This parameter can be set to a single number or to an object with the
  90862. * following (optional) properties: precision, width, height. If a single number is passed,
  90863. * it will be used for both width and height. If an object is passed, the screenshot size
  90864. * will be derived from the parameters. The precision property is a multiplier allowing
  90865. * rendering at a higher or lower resolution
  90866. * @param successCallback The callback receives a single parameter which contains the
  90867. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  90868. * src parameter of an <img> to display it
  90869. * @param mimeType The MIME type of the screenshot image (default: image/png).
  90870. * Check your browser for supported MIME types
  90871. * @param samples Texture samples (default: 1)
  90872. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  90873. * @param fileName A name for for the downloaded file.
  90874. */
  90875. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  90876. /**
  90877. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  90878. * Be aware Math.random() could cause collisions, but:
  90879. * "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"
  90880. * @returns a pseudo random id
  90881. */
  90882. static RandomId(): string;
  90883. /**
  90884. * Test if the given uri is a base64 string
  90885. * @param uri The uri to test
  90886. * @return True if the uri is a base64 string or false otherwise
  90887. */
  90888. static IsBase64(uri: string): boolean;
  90889. /**
  90890. * Decode the given base64 uri.
  90891. * @param uri The uri to decode
  90892. * @return The decoded base64 data.
  90893. */
  90894. static DecodeBase64(uri: string): ArrayBuffer;
  90895. /**
  90896. * Gets the absolute url.
  90897. * @param url the input url
  90898. * @return the absolute url
  90899. */
  90900. static GetAbsoluteUrl(url: string): string;
  90901. /**
  90902. * No log
  90903. */
  90904. static readonly NoneLogLevel: number;
  90905. /**
  90906. * Only message logs
  90907. */
  90908. static readonly MessageLogLevel: number;
  90909. /**
  90910. * Only warning logs
  90911. */
  90912. static readonly WarningLogLevel: number;
  90913. /**
  90914. * Only error logs
  90915. */
  90916. static readonly ErrorLogLevel: number;
  90917. /**
  90918. * All logs
  90919. */
  90920. static readonly AllLogLevel: number;
  90921. /**
  90922. * Gets a value indicating the number of loading errors
  90923. * @ignorenaming
  90924. */
  90925. static readonly errorsCount: number;
  90926. /**
  90927. * Callback called when a new log is added
  90928. */
  90929. static OnNewCacheEntry: (entry: string) => void;
  90930. /**
  90931. * Log a message to the console
  90932. * @param message defines the message to log
  90933. */
  90934. static Log(message: string): void;
  90935. /**
  90936. * Write a warning message to the console
  90937. * @param message defines the message to log
  90938. */
  90939. static Warn(message: string): void;
  90940. /**
  90941. * Write an error message to the console
  90942. * @param message defines the message to log
  90943. */
  90944. static Error(message: string): void;
  90945. /**
  90946. * Gets current log cache (list of logs)
  90947. */
  90948. static readonly LogCache: string;
  90949. /**
  90950. * Clears the log cache
  90951. */
  90952. static ClearLogCache(): void;
  90953. /**
  90954. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  90955. */
  90956. static LogLevels: number;
  90957. /**
  90958. * Checks if the loaded document was accessed via `file:`-Protocol.
  90959. * @returns boolean
  90960. */
  90961. static IsFileURL(): boolean;
  90962. /**
  90963. * Checks if the window object exists
  90964. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  90965. */
  90966. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  90967. /**
  90968. * No performance log
  90969. */
  90970. static readonly PerformanceNoneLogLevel: number;
  90971. /**
  90972. * Use user marks to log performance
  90973. */
  90974. static readonly PerformanceUserMarkLogLevel: number;
  90975. /**
  90976. * Log performance to the console
  90977. */
  90978. static readonly PerformanceConsoleLogLevel: number;
  90979. private static _performance;
  90980. /**
  90981. * Sets the current performance log level
  90982. */
  90983. static PerformanceLogLevel: number;
  90984. private static _StartPerformanceCounterDisabled;
  90985. private static _EndPerformanceCounterDisabled;
  90986. private static _StartUserMark;
  90987. private static _EndUserMark;
  90988. private static _StartPerformanceConsole;
  90989. private static _EndPerformanceConsole;
  90990. /**
  90991. * Starts a performance counter
  90992. */
  90993. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  90994. /**
  90995. * Ends a specific performance coutner
  90996. */
  90997. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  90998. /**
  90999. * Gets either window.performance.now() if supported or Date.now() else
  91000. */
  91001. static readonly Now: number;
  91002. /**
  91003. * This method will return the name of the class used to create the instance of the given object.
  91004. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  91005. * @param object the object to get the class name from
  91006. * @param isType defines if the object is actually a type
  91007. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  91008. */
  91009. static GetClassName(object: any, isType?: boolean): string;
  91010. /**
  91011. * Gets the first element of an array satisfying a given predicate
  91012. * @param array defines the array to browse
  91013. * @param predicate defines the predicate to use
  91014. * @returns null if not found or the element
  91015. */
  91016. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  91017. /**
  91018. * This method will return the name of the full name of the class, including its owning module (if any).
  91019. * 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).
  91020. * @param object the object to get the class name from
  91021. * @param isType defines if the object is actually a type
  91022. * @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.
  91023. * @ignorenaming
  91024. */
  91025. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  91026. /**
  91027. * Returns a promise that resolves after the given amount of time.
  91028. * @param delay Number of milliseconds to delay
  91029. * @returns Promise that resolves after the given amount of time
  91030. */
  91031. static DelayAsync(delay: number): Promise<void>;
  91032. /**
  91033. * Gets the current gradient from an array of IValueGradient
  91034. * @param ratio defines the current ratio to get
  91035. * @param gradients defines the array of IValueGradient
  91036. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91037. */
  91038. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91039. }
  91040. /**
  91041. * This class is used to track a performance counter which is number based.
  91042. * The user has access to many properties which give statistics of different nature.
  91043. *
  91044. * The implementer can track two kinds of Performance Counter: time and count.
  91045. * 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.
  91046. * 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.
  91047. */
  91048. export class PerfCounter {
  91049. /**
  91050. * Gets or sets a global boolean to turn on and off all the counters
  91051. */
  91052. static Enabled: boolean;
  91053. /**
  91054. * Returns the smallest value ever
  91055. */
  91056. readonly min: number;
  91057. /**
  91058. * Returns the biggest value ever
  91059. */
  91060. readonly max: number;
  91061. /**
  91062. * Returns the average value since the performance counter is running
  91063. */
  91064. readonly average: number;
  91065. /**
  91066. * Returns the average value of the last second the counter was monitored
  91067. */
  91068. readonly lastSecAverage: number;
  91069. /**
  91070. * Returns the current value
  91071. */
  91072. readonly current: number;
  91073. /**
  91074. * Gets the accumulated total
  91075. */
  91076. readonly total: number;
  91077. /**
  91078. * Gets the total value count
  91079. */
  91080. readonly count: number;
  91081. /**
  91082. * Creates a new counter
  91083. */
  91084. constructor();
  91085. /**
  91086. * Call this method to start monitoring a new frame.
  91087. * 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.
  91088. */
  91089. fetchNewFrame(): void;
  91090. /**
  91091. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  91092. * @param newCount the count value to add to the monitored count
  91093. * @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.
  91094. */
  91095. addCount(newCount: number, fetchResult: boolean): void;
  91096. /**
  91097. * Start monitoring this performance counter
  91098. */
  91099. beginMonitoring(): void;
  91100. /**
  91101. * Compute the time lapsed since the previous beginMonitoring() call.
  91102. * @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
  91103. */
  91104. endMonitoring(newFrame?: boolean): void;
  91105. private _fetchResult;
  91106. private _startMonitoringTime;
  91107. private _min;
  91108. private _max;
  91109. private _average;
  91110. private _current;
  91111. private _totalValueCount;
  91112. private _totalAccumulated;
  91113. private _lastSecAverage;
  91114. private _lastSecAccumulated;
  91115. private _lastSecTime;
  91116. private _lastSecValueCount;
  91117. }
  91118. /**
  91119. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  91120. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  91121. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  91122. * @param name The name of the class, case should be preserved
  91123. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  91124. */
  91125. export function className(name: string, module?: string): (target: Object) => void;
  91126. /**
  91127. * An implementation of a loop for asynchronous functions.
  91128. */
  91129. export class AsyncLoop {
  91130. /**
  91131. * Defines the number of iterations for the loop
  91132. */
  91133. iterations: number;
  91134. /**
  91135. * Defines the current index of the loop.
  91136. */
  91137. index: number;
  91138. private _done;
  91139. private _fn;
  91140. private _successCallback;
  91141. /**
  91142. * Constructor.
  91143. * @param iterations the number of iterations.
  91144. * @param func the function to run each iteration
  91145. * @param successCallback the callback that will be called upon succesful execution
  91146. * @param offset starting offset.
  91147. */
  91148. constructor(
  91149. /**
  91150. * Defines the number of iterations for the loop
  91151. */
  91152. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  91153. /**
  91154. * Execute the next iteration. Must be called after the last iteration was finished.
  91155. */
  91156. executeNext(): void;
  91157. /**
  91158. * Break the loop and run the success callback.
  91159. */
  91160. breakLoop(): void;
  91161. /**
  91162. * Create and run an async loop.
  91163. * @param iterations the number of iterations.
  91164. * @param fn the function to run each iteration
  91165. * @param successCallback the callback that will be called upon succesful execution
  91166. * @param offset starting offset.
  91167. * @returns the created async loop object
  91168. */
  91169. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  91170. /**
  91171. * A for-loop that will run a given number of iterations synchronous and the rest async.
  91172. * @param iterations total number of iterations
  91173. * @param syncedIterations number of synchronous iterations in each async iteration.
  91174. * @param fn the function to call each iteration.
  91175. * @param callback a success call back that will be called when iterating stops.
  91176. * @param breakFunction a break condition (optional)
  91177. * @param timeout timeout settings for the setTimeout function. default - 0.
  91178. * @returns the created async loop object
  91179. */
  91180. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  91181. }
  91182. }
  91183. declare module BABYLON {
  91184. /** @hidden */
  91185. export interface ICollisionCoordinator {
  91186. createCollider(): Collider;
  91187. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91188. init(scene: Scene): void;
  91189. }
  91190. /** @hidden */
  91191. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  91192. private _scene;
  91193. private _scaledPosition;
  91194. private _scaledVelocity;
  91195. private _finalPosition;
  91196. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91197. createCollider(): Collider;
  91198. init(scene: Scene): void;
  91199. private _collideWithWorld;
  91200. }
  91201. }
  91202. declare module BABYLON {
  91203. /**
  91204. * This class defines the direct association between an animation and a target
  91205. */
  91206. export class TargetedAnimation {
  91207. /**
  91208. * Animation to perform
  91209. */
  91210. animation: Animation;
  91211. /**
  91212. * Target to animate
  91213. */
  91214. target: any;
  91215. }
  91216. /**
  91217. * Use this class to create coordinated animations on multiple targets
  91218. */
  91219. export class AnimationGroup implements IDisposable {
  91220. /** The name of the animation group */
  91221. name: string;
  91222. private _scene;
  91223. private _targetedAnimations;
  91224. private _animatables;
  91225. private _from;
  91226. private _to;
  91227. private _isStarted;
  91228. private _isPaused;
  91229. private _speedRatio;
  91230. /**
  91231. * Gets or sets the unique id of the node
  91232. */
  91233. uniqueId: number;
  91234. /**
  91235. * This observable will notify when one animation have ended
  91236. */
  91237. onAnimationEndObservable: Observable<TargetedAnimation>;
  91238. /**
  91239. * Observer raised when one animation loops
  91240. */
  91241. onAnimationLoopObservable: Observable<TargetedAnimation>;
  91242. /**
  91243. * This observable will notify when all animations have ended.
  91244. */
  91245. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  91246. /**
  91247. * This observable will notify when all animations have paused.
  91248. */
  91249. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  91250. /**
  91251. * This observable will notify when all animations are playing.
  91252. */
  91253. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  91254. /**
  91255. * Gets the first frame
  91256. */
  91257. readonly from: number;
  91258. /**
  91259. * Gets the last frame
  91260. */
  91261. readonly to: number;
  91262. /**
  91263. * Define if the animations are started
  91264. */
  91265. readonly isStarted: boolean;
  91266. /**
  91267. * Gets a value indicating that the current group is playing
  91268. */
  91269. readonly isPlaying: boolean;
  91270. /**
  91271. * Gets or sets the speed ratio to use for all animations
  91272. */
  91273. /**
  91274. * Gets or sets the speed ratio to use for all animations
  91275. */
  91276. speedRatio: number;
  91277. /**
  91278. * Gets the targeted animations for this animation group
  91279. */
  91280. readonly targetedAnimations: Array<TargetedAnimation>;
  91281. /**
  91282. * returning the list of animatables controlled by this animation group.
  91283. */
  91284. readonly animatables: Array<Animatable>;
  91285. /**
  91286. * Instantiates a new Animation Group.
  91287. * This helps managing several animations at once.
  91288. * @see http://doc.babylonjs.com/how_to/group
  91289. * @param name Defines the name of the group
  91290. * @param scene Defines the scene the group belongs to
  91291. */
  91292. constructor(
  91293. /** The name of the animation group */
  91294. name: string, scene?: Nullable<Scene>);
  91295. /**
  91296. * Add an animation (with its target) in the group
  91297. * @param animation defines the animation we want to add
  91298. * @param target defines the target of the animation
  91299. * @returns the TargetedAnimation object
  91300. */
  91301. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  91302. /**
  91303. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  91304. * It can add constant keys at begin or end
  91305. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  91306. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  91307. * @returns the animation group
  91308. */
  91309. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  91310. /**
  91311. * Start all animations on given targets
  91312. * @param loop defines if animations must loop
  91313. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  91314. * @param from defines the from key (optional)
  91315. * @param to defines the to key (optional)
  91316. * @returns the current animation group
  91317. */
  91318. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  91319. /**
  91320. * Pause all animations
  91321. * @returns the animation group
  91322. */
  91323. pause(): AnimationGroup;
  91324. /**
  91325. * Play all animations to initial state
  91326. * This function will start() the animations if they were not started or will restart() them if they were paused
  91327. * @param loop defines if animations must loop
  91328. * @returns the animation group
  91329. */
  91330. play(loop?: boolean): AnimationGroup;
  91331. /**
  91332. * Reset all animations to initial state
  91333. * @returns the animation group
  91334. */
  91335. reset(): AnimationGroup;
  91336. /**
  91337. * Restart animations from key 0
  91338. * @returns the animation group
  91339. */
  91340. restart(): AnimationGroup;
  91341. /**
  91342. * Stop all animations
  91343. * @returns the animation group
  91344. */
  91345. stop(): AnimationGroup;
  91346. /**
  91347. * Set animation weight for all animatables
  91348. * @param weight defines the weight to use
  91349. * @return the animationGroup
  91350. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91351. */
  91352. setWeightForAllAnimatables(weight: number): AnimationGroup;
  91353. /**
  91354. * Synchronize and normalize all animatables with a source animatable
  91355. * @param root defines the root animatable to synchronize with
  91356. * @return the animationGroup
  91357. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91358. */
  91359. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  91360. /**
  91361. * Goes to a specific frame in this animation group
  91362. * @param frame the frame number to go to
  91363. * @return the animationGroup
  91364. */
  91365. goToFrame(frame: number): AnimationGroup;
  91366. /**
  91367. * Dispose all associated resources
  91368. */
  91369. dispose(): void;
  91370. private _checkAnimationGroupEnded;
  91371. /**
  91372. * Clone the current animation group and returns a copy
  91373. * @param newName defines the name of the new group
  91374. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  91375. * @returns the new aniamtion group
  91376. */
  91377. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  91378. /**
  91379. * Returns a new AnimationGroup object parsed from the source provided.
  91380. * @param parsedAnimationGroup defines the source
  91381. * @param scene defines the scene that will receive the animationGroup
  91382. * @returns a new AnimationGroup
  91383. */
  91384. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  91385. /**
  91386. * Returns the string "AnimationGroup"
  91387. * @returns "AnimationGroup"
  91388. */
  91389. getClassName(): string;
  91390. /**
  91391. * Creates a detailled string about the object
  91392. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  91393. * @returns a string representing the object
  91394. */
  91395. toString(fullDetails?: boolean): string;
  91396. }
  91397. }
  91398. declare module BABYLON {
  91399. /**
  91400. * Define an interface for all classes that will hold resources
  91401. */
  91402. export interface IDisposable {
  91403. /**
  91404. * Releases all held resources
  91405. */
  91406. dispose(): void;
  91407. }
  91408. /** Interface defining initialization parameters for Scene class */
  91409. export interface SceneOptions {
  91410. /**
  91411. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  91412. * It will improve performance when the number of geometries becomes important.
  91413. */
  91414. useGeometryUniqueIdsMap?: boolean;
  91415. /**
  91416. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  91417. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91418. */
  91419. useMaterialMeshMap?: boolean;
  91420. /**
  91421. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  91422. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91423. */
  91424. useClonedMeshhMap?: boolean;
  91425. }
  91426. /**
  91427. * Represents a scene to be rendered by the engine.
  91428. * @see http://doc.babylonjs.com/features/scene
  91429. */
  91430. export class Scene extends AbstractScene implements IAnimatable {
  91431. private static _uniqueIdCounter;
  91432. /** The fog is deactivated */
  91433. static readonly FOGMODE_NONE: number;
  91434. /** The fog density is following an exponential function */
  91435. static readonly FOGMODE_EXP: number;
  91436. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  91437. static readonly FOGMODE_EXP2: number;
  91438. /** The fog density is following a linear function. */
  91439. static readonly FOGMODE_LINEAR: number;
  91440. /**
  91441. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  91442. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91443. */
  91444. static MinDeltaTime: number;
  91445. /**
  91446. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  91447. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91448. */
  91449. static MaxDeltaTime: number;
  91450. /**
  91451. * Factory used to create the default material.
  91452. * @param name The name of the material to create
  91453. * @param scene The scene to create the material for
  91454. * @returns The default material
  91455. */
  91456. static DefaultMaterialFactory(scene: Scene): Material;
  91457. /**
  91458. * Factory used to create the a collision coordinator.
  91459. * @returns The collision coordinator
  91460. */
  91461. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  91462. /** @hidden */
  91463. readonly _isScene: boolean;
  91464. /**
  91465. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  91466. */
  91467. autoClear: boolean;
  91468. /**
  91469. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  91470. */
  91471. autoClearDepthAndStencil: boolean;
  91472. /**
  91473. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  91474. */
  91475. clearColor: Color4;
  91476. /**
  91477. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  91478. */
  91479. ambientColor: Color3;
  91480. /**
  91481. * This is use to store the default BRDF lookup for PBR materials in your scene.
  91482. * It should only be one of the following (if not the default embedded one):
  91483. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  91484. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  91485. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  91486. * The material properties need to be setup according to the type of texture in use.
  91487. */
  91488. environmentBRDFTexture: BaseTexture;
  91489. /** @hidden */
  91490. protected _environmentTexture: Nullable<BaseTexture>;
  91491. /**
  91492. * Texture used in all pbr material as the reflection texture.
  91493. * As in the majority of the scene they are the same (exception for multi room and so on),
  91494. * this is easier to reference from here than from all the materials.
  91495. */
  91496. /**
  91497. * Texture used in all pbr material as the reflection texture.
  91498. * As in the majority of the scene they are the same (exception for multi room and so on),
  91499. * this is easier to set here than in all the materials.
  91500. */
  91501. environmentTexture: Nullable<BaseTexture>;
  91502. /** @hidden */
  91503. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  91504. /**
  91505. * Default image processing configuration used either in the rendering
  91506. * Forward main pass or through the imageProcessingPostProcess if present.
  91507. * As in the majority of the scene they are the same (exception for multi camera),
  91508. * this is easier to reference from here than from all the materials and post process.
  91509. *
  91510. * No setter as we it is a shared configuration, you can set the values instead.
  91511. */
  91512. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  91513. private _forceWireframe;
  91514. /**
  91515. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  91516. */
  91517. forceWireframe: boolean;
  91518. private _forcePointsCloud;
  91519. /**
  91520. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  91521. */
  91522. forcePointsCloud: boolean;
  91523. /**
  91524. * Gets or sets the active clipplane 1
  91525. */
  91526. clipPlane: Nullable<Plane>;
  91527. /**
  91528. * Gets or sets the active clipplane 2
  91529. */
  91530. clipPlane2: Nullable<Plane>;
  91531. /**
  91532. * Gets or sets the active clipplane 3
  91533. */
  91534. clipPlane3: Nullable<Plane>;
  91535. /**
  91536. * Gets or sets the active clipplane 4
  91537. */
  91538. clipPlane4: Nullable<Plane>;
  91539. /**
  91540. * Gets or sets a boolean indicating if animations are enabled
  91541. */
  91542. animationsEnabled: boolean;
  91543. private _animationPropertiesOverride;
  91544. /**
  91545. * Gets or sets the animation properties override
  91546. */
  91547. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91548. /**
  91549. * Gets or sets a boolean indicating if a constant deltatime has to be used
  91550. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  91551. */
  91552. useConstantAnimationDeltaTime: boolean;
  91553. /**
  91554. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  91555. * Please note that it requires to run a ray cast through the scene on every frame
  91556. */
  91557. constantlyUpdateMeshUnderPointer: boolean;
  91558. /**
  91559. * Defines the HTML cursor to use when hovering over interactive elements
  91560. */
  91561. hoverCursor: string;
  91562. /**
  91563. * Defines the HTML default cursor to use (empty by default)
  91564. */
  91565. defaultCursor: string;
  91566. /**
  91567. * This is used to call preventDefault() on pointer down
  91568. * in order to block unwanted artifacts like system double clicks
  91569. */
  91570. preventDefaultOnPointerDown: boolean;
  91571. /**
  91572. * This is used to call preventDefault() on pointer up
  91573. * in order to block unwanted artifacts like system double clicks
  91574. */
  91575. preventDefaultOnPointerUp: boolean;
  91576. /**
  91577. * Gets or sets user defined metadata
  91578. */
  91579. metadata: any;
  91580. /**
  91581. * For internal use only. Please do not use.
  91582. */
  91583. reservedDataStore: any;
  91584. /**
  91585. * Gets the name of the plugin used to load this scene (null by default)
  91586. */
  91587. loadingPluginName: string;
  91588. /**
  91589. * Use this array to add regular expressions used to disable offline support for specific urls
  91590. */
  91591. disableOfflineSupportExceptionRules: RegExp[];
  91592. /**
  91593. * An event triggered when the scene is disposed.
  91594. */
  91595. onDisposeObservable: Observable<Scene>;
  91596. private _onDisposeObserver;
  91597. /** Sets a function to be executed when this scene is disposed. */
  91598. onDispose: () => void;
  91599. /**
  91600. * An event triggered before rendering the scene (right after animations and physics)
  91601. */
  91602. onBeforeRenderObservable: Observable<Scene>;
  91603. private _onBeforeRenderObserver;
  91604. /** Sets a function to be executed before rendering this scene */
  91605. beforeRender: Nullable<() => void>;
  91606. /**
  91607. * An event triggered after rendering the scene
  91608. */
  91609. onAfterRenderObservable: Observable<Scene>;
  91610. private _onAfterRenderObserver;
  91611. /** Sets a function to be executed after rendering this scene */
  91612. afterRender: Nullable<() => void>;
  91613. /**
  91614. * An event triggered before animating the scene
  91615. */
  91616. onBeforeAnimationsObservable: Observable<Scene>;
  91617. /**
  91618. * An event triggered after animations processing
  91619. */
  91620. onAfterAnimationsObservable: Observable<Scene>;
  91621. /**
  91622. * An event triggered before draw calls are ready to be sent
  91623. */
  91624. onBeforeDrawPhaseObservable: Observable<Scene>;
  91625. /**
  91626. * An event triggered after draw calls have been sent
  91627. */
  91628. onAfterDrawPhaseObservable: Observable<Scene>;
  91629. /**
  91630. * An event triggered when the scene is ready
  91631. */
  91632. onReadyObservable: Observable<Scene>;
  91633. /**
  91634. * An event triggered before rendering a camera
  91635. */
  91636. onBeforeCameraRenderObservable: Observable<Camera>;
  91637. private _onBeforeCameraRenderObserver;
  91638. /** Sets a function to be executed before rendering a camera*/
  91639. beforeCameraRender: () => void;
  91640. /**
  91641. * An event triggered after rendering a camera
  91642. */
  91643. onAfterCameraRenderObservable: Observable<Camera>;
  91644. private _onAfterCameraRenderObserver;
  91645. /** Sets a function to be executed after rendering a camera*/
  91646. afterCameraRender: () => void;
  91647. /**
  91648. * An event triggered when active meshes evaluation is about to start
  91649. */
  91650. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  91651. /**
  91652. * An event triggered when active meshes evaluation is done
  91653. */
  91654. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  91655. /**
  91656. * An event triggered when particles rendering is about to start
  91657. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  91658. */
  91659. onBeforeParticlesRenderingObservable: Observable<Scene>;
  91660. /**
  91661. * An event triggered when particles rendering is done
  91662. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  91663. */
  91664. onAfterParticlesRenderingObservable: Observable<Scene>;
  91665. /**
  91666. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  91667. */
  91668. onDataLoadedObservable: Observable<Scene>;
  91669. /**
  91670. * An event triggered when a camera is created
  91671. */
  91672. onNewCameraAddedObservable: Observable<Camera>;
  91673. /**
  91674. * An event triggered when a camera is removed
  91675. */
  91676. onCameraRemovedObservable: Observable<Camera>;
  91677. /**
  91678. * An event triggered when a light is created
  91679. */
  91680. onNewLightAddedObservable: Observable<Light>;
  91681. /**
  91682. * An event triggered when a light is removed
  91683. */
  91684. onLightRemovedObservable: Observable<Light>;
  91685. /**
  91686. * An event triggered when a geometry is created
  91687. */
  91688. onNewGeometryAddedObservable: Observable<Geometry>;
  91689. /**
  91690. * An event triggered when a geometry is removed
  91691. */
  91692. onGeometryRemovedObservable: Observable<Geometry>;
  91693. /**
  91694. * An event triggered when a transform node is created
  91695. */
  91696. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  91697. /**
  91698. * An event triggered when a transform node is removed
  91699. */
  91700. onTransformNodeRemovedObservable: Observable<TransformNode>;
  91701. /**
  91702. * An event triggered when a mesh is created
  91703. */
  91704. onNewMeshAddedObservable: Observable<AbstractMesh>;
  91705. /**
  91706. * An event triggered when a mesh is removed
  91707. */
  91708. onMeshRemovedObservable: Observable<AbstractMesh>;
  91709. /**
  91710. * An event triggered when a skeleton is created
  91711. */
  91712. onNewSkeletonAddedObservable: Observable<Skeleton>;
  91713. /**
  91714. * An event triggered when a skeleton is removed
  91715. */
  91716. onSkeletonRemovedObservable: Observable<Skeleton>;
  91717. /**
  91718. * An event triggered when a material is created
  91719. */
  91720. onNewMaterialAddedObservable: Observable<Material>;
  91721. /**
  91722. * An event triggered when a material is removed
  91723. */
  91724. onMaterialRemovedObservable: Observable<Material>;
  91725. /**
  91726. * An event triggered when a texture is created
  91727. */
  91728. onNewTextureAddedObservable: Observable<BaseTexture>;
  91729. /**
  91730. * An event triggered when a texture is removed
  91731. */
  91732. onTextureRemovedObservable: Observable<BaseTexture>;
  91733. /**
  91734. * An event triggered when render targets are about to be rendered
  91735. * Can happen multiple times per frame.
  91736. */
  91737. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  91738. /**
  91739. * An event triggered when render targets were rendered.
  91740. * Can happen multiple times per frame.
  91741. */
  91742. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  91743. /**
  91744. * An event triggered before calculating deterministic simulation step
  91745. */
  91746. onBeforeStepObservable: Observable<Scene>;
  91747. /**
  91748. * An event triggered after calculating deterministic simulation step
  91749. */
  91750. onAfterStepObservable: Observable<Scene>;
  91751. /**
  91752. * An event triggered when the activeCamera property is updated
  91753. */
  91754. onActiveCameraChanged: Observable<Scene>;
  91755. /**
  91756. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  91757. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  91758. * 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)
  91759. */
  91760. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  91761. /**
  91762. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  91763. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  91764. * 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)
  91765. */
  91766. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  91767. /**
  91768. * This Observable will when a mesh has been imported into the scene.
  91769. */
  91770. onMeshImportedObservable: Observable<AbstractMesh>;
  91771. /**
  91772. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  91773. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  91774. */
  91775. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  91776. /** @hidden */
  91777. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  91778. /**
  91779. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  91780. */
  91781. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  91782. /**
  91783. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  91784. */
  91785. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  91786. /**
  91787. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  91788. */
  91789. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  91790. private _onPointerMove;
  91791. private _onPointerDown;
  91792. private _onPointerUp;
  91793. /** Callback called when a pointer move is detected */
  91794. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  91795. /** Callback called when a pointer down is detected */
  91796. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  91797. /** Callback called when a pointer up is detected */
  91798. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  91799. /** Callback called when a pointer pick is detected */
  91800. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  91801. /**
  91802. * 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).
  91803. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  91804. */
  91805. onPrePointerObservable: Observable<PointerInfoPre>;
  91806. /**
  91807. * Observable event triggered each time an input event is received from the rendering canvas
  91808. */
  91809. onPointerObservable: Observable<PointerInfo>;
  91810. /**
  91811. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  91812. */
  91813. readonly unTranslatedPointer: Vector2;
  91814. /** The distance in pixel that you have to move to prevent some events */
  91815. static DragMovementThreshold: number;
  91816. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  91817. static LongPressDelay: number;
  91818. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  91819. static DoubleClickDelay: number;
  91820. /** If you need to check double click without raising a single click at first click, enable this flag */
  91821. static ExclusiveDoubleClickMode: boolean;
  91822. private _initClickEvent;
  91823. private _initActionManager;
  91824. private _delayedSimpleClick;
  91825. private _delayedSimpleClickTimeout;
  91826. private _previousDelayedSimpleClickTimeout;
  91827. private _meshPickProceed;
  91828. private _previousButtonPressed;
  91829. private _currentPickResult;
  91830. private _previousPickResult;
  91831. private _totalPointersPressed;
  91832. private _doubleClickOccured;
  91833. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  91834. cameraToUseForPointers: Nullable<Camera>;
  91835. private _pointerX;
  91836. private _pointerY;
  91837. private _unTranslatedPointerX;
  91838. private _unTranslatedPointerY;
  91839. private _startingPointerPosition;
  91840. private _previousStartingPointerPosition;
  91841. private _startingPointerTime;
  91842. private _previousStartingPointerTime;
  91843. private _pointerCaptures;
  91844. private _timeAccumulator;
  91845. private _currentStepId;
  91846. private _currentInternalStep;
  91847. /** @hidden */
  91848. _mirroredCameraPosition: Nullable<Vector3>;
  91849. /**
  91850. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  91851. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  91852. */
  91853. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  91854. /**
  91855. * Observable event triggered each time an keyboard event is received from the hosting window
  91856. */
  91857. onKeyboardObservable: Observable<KeyboardInfo>;
  91858. private _onKeyDown;
  91859. private _onKeyUp;
  91860. private _onCanvasFocusObserver;
  91861. private _onCanvasBlurObserver;
  91862. private _useRightHandedSystem;
  91863. /**
  91864. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  91865. */
  91866. useRightHandedSystem: boolean;
  91867. /**
  91868. * Sets the step Id used by deterministic lock step
  91869. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91870. * @param newStepId defines the step Id
  91871. */
  91872. setStepId(newStepId: number): void;
  91873. /**
  91874. * Gets the step Id used by deterministic lock step
  91875. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91876. * @returns the step Id
  91877. */
  91878. getStepId(): number;
  91879. /**
  91880. * Gets the internal step used by deterministic lock step
  91881. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91882. * @returns the internal step
  91883. */
  91884. getInternalStep(): number;
  91885. private _fogEnabled;
  91886. /**
  91887. * Gets or sets a boolean indicating if fog is enabled on this scene
  91888. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91889. * (Default is true)
  91890. */
  91891. fogEnabled: boolean;
  91892. private _fogMode;
  91893. /**
  91894. * Gets or sets the fog mode to use
  91895. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91896. * | mode | value |
  91897. * | --- | --- |
  91898. * | FOGMODE_NONE | 0 |
  91899. * | FOGMODE_EXP | 1 |
  91900. * | FOGMODE_EXP2 | 2 |
  91901. * | FOGMODE_LINEAR | 3 |
  91902. */
  91903. fogMode: number;
  91904. /**
  91905. * Gets or sets the fog color to use
  91906. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91907. * (Default is Color3(0.2, 0.2, 0.3))
  91908. */
  91909. fogColor: Color3;
  91910. /**
  91911. * Gets or sets the fog density to use
  91912. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91913. * (Default is 0.1)
  91914. */
  91915. fogDensity: number;
  91916. /**
  91917. * Gets or sets the fog start distance to use
  91918. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91919. * (Default is 0)
  91920. */
  91921. fogStart: number;
  91922. /**
  91923. * Gets or sets the fog end distance to use
  91924. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91925. * (Default is 1000)
  91926. */
  91927. fogEnd: number;
  91928. private _shadowsEnabled;
  91929. /**
  91930. * Gets or sets a boolean indicating if shadows are enabled on this scene
  91931. */
  91932. shadowsEnabled: boolean;
  91933. private _lightsEnabled;
  91934. /**
  91935. * Gets or sets a boolean indicating if lights are enabled on this scene
  91936. */
  91937. lightsEnabled: boolean;
  91938. /** All of the active cameras added to this scene. */
  91939. activeCameras: Camera[];
  91940. /** @hidden */
  91941. _activeCamera: Nullable<Camera>;
  91942. /** Gets or sets the current active camera */
  91943. activeCamera: Nullable<Camera>;
  91944. private _defaultMaterial;
  91945. /** The default material used on meshes when no material is affected */
  91946. /** The default material used on meshes when no material is affected */
  91947. defaultMaterial: Material;
  91948. private _texturesEnabled;
  91949. /**
  91950. * Gets or sets a boolean indicating if textures are enabled on this scene
  91951. */
  91952. texturesEnabled: boolean;
  91953. /**
  91954. * Gets or sets a boolean indicating if particles are enabled on this scene
  91955. */
  91956. particlesEnabled: boolean;
  91957. /**
  91958. * Gets or sets a boolean indicating if sprites are enabled on this scene
  91959. */
  91960. spritesEnabled: boolean;
  91961. private _skeletonsEnabled;
  91962. /**
  91963. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  91964. */
  91965. skeletonsEnabled: boolean;
  91966. /**
  91967. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  91968. */
  91969. lensFlaresEnabled: boolean;
  91970. /**
  91971. * Gets or sets a boolean indicating if collisions are enabled on this scene
  91972. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91973. */
  91974. collisionsEnabled: boolean;
  91975. private _collisionCoordinator;
  91976. /** @hidden */
  91977. readonly collisionCoordinator: ICollisionCoordinator;
  91978. /**
  91979. * Defines the gravity applied to this scene (used only for collisions)
  91980. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91981. */
  91982. gravity: Vector3;
  91983. /**
  91984. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  91985. */
  91986. postProcessesEnabled: boolean;
  91987. /**
  91988. * The list of postprocesses added to the scene
  91989. */
  91990. postProcesses: PostProcess[];
  91991. /**
  91992. * Gets the current postprocess manager
  91993. */
  91994. postProcessManager: PostProcessManager;
  91995. /**
  91996. * Gets or sets a boolean indicating if render targets are enabled on this scene
  91997. */
  91998. renderTargetsEnabled: boolean;
  91999. /**
  92000. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  92001. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  92002. */
  92003. dumpNextRenderTargets: boolean;
  92004. /**
  92005. * The list of user defined render targets added to the scene
  92006. */
  92007. customRenderTargets: RenderTargetTexture[];
  92008. /**
  92009. * Defines if texture loading must be delayed
  92010. * If true, textures will only be loaded when they need to be rendered
  92011. */
  92012. useDelayedTextureLoading: boolean;
  92013. /**
  92014. * Gets the list of meshes imported to the scene through SceneLoader
  92015. */
  92016. importedMeshesFiles: String[];
  92017. /**
  92018. * Gets or sets a boolean indicating if probes are enabled on this scene
  92019. */
  92020. probesEnabled: boolean;
  92021. /**
  92022. * Gets or sets the current offline provider to use to store scene data
  92023. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  92024. */
  92025. offlineProvider: IOfflineProvider;
  92026. /**
  92027. * Gets or sets the action manager associated with the scene
  92028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92029. */
  92030. actionManager: AbstractActionManager;
  92031. private _meshesForIntersections;
  92032. /**
  92033. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  92034. */
  92035. proceduralTexturesEnabled: boolean;
  92036. private _engine;
  92037. private _totalVertices;
  92038. /** @hidden */
  92039. _activeIndices: PerfCounter;
  92040. /** @hidden */
  92041. _activeParticles: PerfCounter;
  92042. /** @hidden */
  92043. _activeBones: PerfCounter;
  92044. private _animationRatio;
  92045. /** @hidden */
  92046. _animationTimeLast: number;
  92047. /** @hidden */
  92048. _animationTime: number;
  92049. /**
  92050. * Gets or sets a general scale for animation speed
  92051. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  92052. */
  92053. animationTimeScale: number;
  92054. /** @hidden */
  92055. _cachedMaterial: Nullable<Material>;
  92056. /** @hidden */
  92057. _cachedEffect: Nullable<Effect>;
  92058. /** @hidden */
  92059. _cachedVisibility: Nullable<number>;
  92060. private _renderId;
  92061. private _frameId;
  92062. private _executeWhenReadyTimeoutId;
  92063. private _intermediateRendering;
  92064. private _viewUpdateFlag;
  92065. private _projectionUpdateFlag;
  92066. /** @hidden */
  92067. _toBeDisposed: Nullable<IDisposable>[];
  92068. private _activeRequests;
  92069. /** @hidden */
  92070. _pendingData: any[];
  92071. private _isDisposed;
  92072. /**
  92073. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  92074. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  92075. */
  92076. dispatchAllSubMeshesOfActiveMeshes: boolean;
  92077. private _activeMeshes;
  92078. private _processedMaterials;
  92079. private _renderTargets;
  92080. /** @hidden */
  92081. _activeParticleSystems: SmartArray<IParticleSystem>;
  92082. private _activeSkeletons;
  92083. private _softwareSkinnedMeshes;
  92084. private _renderingManager;
  92085. /** @hidden */
  92086. _activeAnimatables: Animatable[];
  92087. private _transformMatrix;
  92088. private _sceneUbo;
  92089. /** @hidden */
  92090. _viewMatrix: Matrix;
  92091. private _projectionMatrix;
  92092. private _wheelEventName;
  92093. /** @hidden */
  92094. _forcedViewPosition: Nullable<Vector3>;
  92095. /** @hidden */
  92096. _frustumPlanes: Plane[];
  92097. /**
  92098. * Gets the list of frustum planes (built from the active camera)
  92099. */
  92100. readonly frustumPlanes: Plane[];
  92101. /**
  92102. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  92103. * This is useful if there are more lights that the maximum simulteanous authorized
  92104. */
  92105. requireLightSorting: boolean;
  92106. /** @hidden */
  92107. readonly useMaterialMeshMap: boolean;
  92108. /** @hidden */
  92109. readonly useClonedMeshhMap: boolean;
  92110. private _pointerOverMesh;
  92111. private _pickedDownMesh;
  92112. private _pickedUpMesh;
  92113. private _externalData;
  92114. private _uid;
  92115. /**
  92116. * @hidden
  92117. * Backing store of defined scene components.
  92118. */
  92119. _components: ISceneComponent[];
  92120. /**
  92121. * @hidden
  92122. * Backing store of defined scene components.
  92123. */
  92124. _serializableComponents: ISceneSerializableComponent[];
  92125. /**
  92126. * List of components to register on the next registration step.
  92127. */
  92128. private _transientComponents;
  92129. /**
  92130. * Registers the transient components if needed.
  92131. */
  92132. private _registerTransientComponents;
  92133. /**
  92134. * @hidden
  92135. * Add a component to the scene.
  92136. * Note that the ccomponent could be registered on th next frame if this is called after
  92137. * the register component stage.
  92138. * @param component Defines the component to add to the scene
  92139. */
  92140. _addComponent(component: ISceneComponent): void;
  92141. /**
  92142. * @hidden
  92143. * Gets a component from the scene.
  92144. * @param name defines the name of the component to retrieve
  92145. * @returns the component or null if not present
  92146. */
  92147. _getComponent(name: string): Nullable<ISceneComponent>;
  92148. /**
  92149. * @hidden
  92150. * Defines the actions happening before camera updates.
  92151. */
  92152. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  92153. /**
  92154. * @hidden
  92155. * Defines the actions happening before clear the canvas.
  92156. */
  92157. _beforeClearStage: Stage<SimpleStageAction>;
  92158. /**
  92159. * @hidden
  92160. * Defines the actions when collecting render targets for the frame.
  92161. */
  92162. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92163. /**
  92164. * @hidden
  92165. * Defines the actions happening for one camera in the frame.
  92166. */
  92167. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92168. /**
  92169. * @hidden
  92170. * Defines the actions happening during the per mesh ready checks.
  92171. */
  92172. _isReadyForMeshStage: Stage<MeshStageAction>;
  92173. /**
  92174. * @hidden
  92175. * Defines the actions happening before evaluate active mesh checks.
  92176. */
  92177. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  92178. /**
  92179. * @hidden
  92180. * Defines the actions happening during the evaluate sub mesh checks.
  92181. */
  92182. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  92183. /**
  92184. * @hidden
  92185. * Defines the actions happening during the active mesh stage.
  92186. */
  92187. _activeMeshStage: Stage<ActiveMeshStageAction>;
  92188. /**
  92189. * @hidden
  92190. * Defines the actions happening during the per camera render target step.
  92191. */
  92192. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  92193. /**
  92194. * @hidden
  92195. * Defines the actions happening just before the active camera is drawing.
  92196. */
  92197. _beforeCameraDrawStage: Stage<CameraStageAction>;
  92198. /**
  92199. * @hidden
  92200. * Defines the actions happening just before a render target is drawing.
  92201. */
  92202. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92203. /**
  92204. * @hidden
  92205. * Defines the actions happening just before a rendering group is drawing.
  92206. */
  92207. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92208. /**
  92209. * @hidden
  92210. * Defines the actions happening just before a mesh is drawing.
  92211. */
  92212. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92213. /**
  92214. * @hidden
  92215. * Defines the actions happening just after a mesh has been drawn.
  92216. */
  92217. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92218. /**
  92219. * @hidden
  92220. * Defines the actions happening just after a rendering group has been drawn.
  92221. */
  92222. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92223. /**
  92224. * @hidden
  92225. * Defines the actions happening just after the active camera has been drawn.
  92226. */
  92227. _afterCameraDrawStage: Stage<CameraStageAction>;
  92228. /**
  92229. * @hidden
  92230. * Defines the actions happening just after a render target has been drawn.
  92231. */
  92232. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92233. /**
  92234. * @hidden
  92235. * Defines the actions happening just after rendering all cameras and computing intersections.
  92236. */
  92237. _afterRenderStage: Stage<SimpleStageAction>;
  92238. /**
  92239. * @hidden
  92240. * Defines the actions happening when a pointer move event happens.
  92241. */
  92242. _pointerMoveStage: Stage<PointerMoveStageAction>;
  92243. /**
  92244. * @hidden
  92245. * Defines the actions happening when a pointer down event happens.
  92246. */
  92247. _pointerDownStage: Stage<PointerUpDownStageAction>;
  92248. /**
  92249. * @hidden
  92250. * Defines the actions happening when a pointer up event happens.
  92251. */
  92252. _pointerUpStage: Stage<PointerUpDownStageAction>;
  92253. /**
  92254. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  92255. */
  92256. private geometriesByUniqueId;
  92257. /**
  92258. * Creates a new Scene
  92259. * @param engine defines the engine to use to render this scene
  92260. * @param options defines the scene options
  92261. */
  92262. constructor(engine: Engine, options?: SceneOptions);
  92263. /**
  92264. * Gets a string idenfifying the name of the class
  92265. * @returns "Scene" string
  92266. */
  92267. getClassName(): string;
  92268. private _defaultMeshCandidates;
  92269. /**
  92270. * @hidden
  92271. */
  92272. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  92273. private _defaultSubMeshCandidates;
  92274. /**
  92275. * @hidden
  92276. */
  92277. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  92278. /**
  92279. * Sets the default candidate providers for the scene.
  92280. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  92281. * and getCollidingSubMeshCandidates to their default function
  92282. */
  92283. setDefaultCandidateProviders(): void;
  92284. /**
  92285. * Gets the mesh that is currently under the pointer
  92286. */
  92287. readonly meshUnderPointer: Nullable<AbstractMesh>;
  92288. /**
  92289. * Gets or sets the current on-screen X position of the pointer
  92290. */
  92291. pointerX: number;
  92292. /**
  92293. * Gets or sets the current on-screen Y position of the pointer
  92294. */
  92295. pointerY: number;
  92296. /**
  92297. * Gets the cached material (ie. the latest rendered one)
  92298. * @returns the cached material
  92299. */
  92300. getCachedMaterial(): Nullable<Material>;
  92301. /**
  92302. * Gets the cached effect (ie. the latest rendered one)
  92303. * @returns the cached effect
  92304. */
  92305. getCachedEffect(): Nullable<Effect>;
  92306. /**
  92307. * Gets the cached visibility state (ie. the latest rendered one)
  92308. * @returns the cached visibility state
  92309. */
  92310. getCachedVisibility(): Nullable<number>;
  92311. /**
  92312. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  92313. * @param material defines the current material
  92314. * @param effect defines the current effect
  92315. * @param visibility defines the current visibility state
  92316. * @returns true if one parameter is not cached
  92317. */
  92318. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  92319. /**
  92320. * Gets the engine associated with the scene
  92321. * @returns an Engine
  92322. */
  92323. getEngine(): Engine;
  92324. /**
  92325. * Gets the total number of vertices rendered per frame
  92326. * @returns the total number of vertices rendered per frame
  92327. */
  92328. getTotalVertices(): number;
  92329. /**
  92330. * Gets the performance counter for total vertices
  92331. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92332. */
  92333. readonly totalVerticesPerfCounter: PerfCounter;
  92334. /**
  92335. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  92336. * @returns the total number of active indices rendered per frame
  92337. */
  92338. getActiveIndices(): number;
  92339. /**
  92340. * Gets the performance counter for active indices
  92341. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92342. */
  92343. readonly totalActiveIndicesPerfCounter: PerfCounter;
  92344. /**
  92345. * Gets the total number of active particles rendered per frame
  92346. * @returns the total number of active particles rendered per frame
  92347. */
  92348. getActiveParticles(): number;
  92349. /**
  92350. * Gets the performance counter for active particles
  92351. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92352. */
  92353. readonly activeParticlesPerfCounter: PerfCounter;
  92354. /**
  92355. * Gets the total number of active bones rendered per frame
  92356. * @returns the total number of active bones rendered per frame
  92357. */
  92358. getActiveBones(): number;
  92359. /**
  92360. * Gets the performance counter for active bones
  92361. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92362. */
  92363. readonly activeBonesPerfCounter: PerfCounter;
  92364. /**
  92365. * Gets the array of active meshes
  92366. * @returns an array of AbstractMesh
  92367. */
  92368. getActiveMeshes(): SmartArray<AbstractMesh>;
  92369. /**
  92370. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  92371. * @returns a number
  92372. */
  92373. getAnimationRatio(): number;
  92374. /**
  92375. * Gets an unique Id for the current render phase
  92376. * @returns a number
  92377. */
  92378. getRenderId(): number;
  92379. /**
  92380. * Gets an unique Id for the current frame
  92381. * @returns a number
  92382. */
  92383. getFrameId(): number;
  92384. /** Call this function if you want to manually increment the render Id*/
  92385. incrementRenderId(): void;
  92386. private _updatePointerPosition;
  92387. private _createUbo;
  92388. private _setRayOnPointerInfo;
  92389. /**
  92390. * Use this method to simulate a pointer move on a mesh
  92391. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92392. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92393. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92394. * @returns the current scene
  92395. */
  92396. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92397. private _processPointerMove;
  92398. private _checkPrePointerObservable;
  92399. /**
  92400. * Use this method to simulate a pointer down on a mesh
  92401. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92402. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92403. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92404. * @returns the current scene
  92405. */
  92406. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92407. private _processPointerDown;
  92408. /**
  92409. * Use this method to simulate a pointer up on a mesh
  92410. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92411. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92412. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92413. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  92414. * @returns the current scene
  92415. */
  92416. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  92417. private _processPointerUp;
  92418. /**
  92419. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  92420. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  92421. * @returns true if the pointer was captured
  92422. */
  92423. isPointerCaptured(pointerId?: number): boolean;
  92424. /** @hidden */
  92425. _isPointerSwiping(): boolean;
  92426. /**
  92427. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  92428. * @param attachUp defines if you want to attach events to pointerup
  92429. * @param attachDown defines if you want to attach events to pointerdown
  92430. * @param attachMove defines if you want to attach events to pointermove
  92431. */
  92432. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  92433. /** Detaches all event handlers*/
  92434. detachControl(): void;
  92435. /**
  92436. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  92437. * Delay loaded resources are not taking in account
  92438. * @return true if all required resources are ready
  92439. */
  92440. isReady(): boolean;
  92441. /** Resets all cached information relative to material (including effect and visibility) */
  92442. resetCachedMaterial(): void;
  92443. /**
  92444. * Registers a function to be called before every frame render
  92445. * @param func defines the function to register
  92446. */
  92447. registerBeforeRender(func: () => void): void;
  92448. /**
  92449. * Unregisters a function called before every frame render
  92450. * @param func defines the function to unregister
  92451. */
  92452. unregisterBeforeRender(func: () => void): void;
  92453. /**
  92454. * Registers a function to be called after every frame render
  92455. * @param func defines the function to register
  92456. */
  92457. registerAfterRender(func: () => void): void;
  92458. /**
  92459. * Unregisters a function called after every frame render
  92460. * @param func defines the function to unregister
  92461. */
  92462. unregisterAfterRender(func: () => void): void;
  92463. private _executeOnceBeforeRender;
  92464. /**
  92465. * The provided function will run before render once and will be disposed afterwards.
  92466. * A timeout delay can be provided so that the function will be executed in N ms.
  92467. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  92468. * @param func The function to be executed.
  92469. * @param timeout optional delay in ms
  92470. */
  92471. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  92472. /** @hidden */
  92473. _addPendingData(data: any): void;
  92474. /** @hidden */
  92475. _removePendingData(data: any): void;
  92476. /**
  92477. * Returns the number of items waiting to be loaded
  92478. * @returns the number of items waiting to be loaded
  92479. */
  92480. getWaitingItemsCount(): number;
  92481. /**
  92482. * Returns a boolean indicating if the scene is still loading data
  92483. */
  92484. readonly isLoading: boolean;
  92485. /**
  92486. * Registers a function to be executed when the scene is ready
  92487. * @param {Function} func - the function to be executed
  92488. */
  92489. executeWhenReady(func: () => void): void;
  92490. /**
  92491. * Returns a promise that resolves when the scene is ready
  92492. * @returns A promise that resolves when the scene is ready
  92493. */
  92494. whenReadyAsync(): Promise<void>;
  92495. /** @hidden */
  92496. _checkIsReady(): void;
  92497. /**
  92498. * Gets all animatable attached to the scene
  92499. */
  92500. readonly animatables: Animatable[];
  92501. /**
  92502. * Resets the last animation time frame.
  92503. * Useful to override when animations start running when loading a scene for the first time.
  92504. */
  92505. resetLastAnimationTimeFrame(): void;
  92506. /**
  92507. * Gets the current view matrix
  92508. * @returns a Matrix
  92509. */
  92510. getViewMatrix(): Matrix;
  92511. /**
  92512. * Gets the current projection matrix
  92513. * @returns a Matrix
  92514. */
  92515. getProjectionMatrix(): Matrix;
  92516. /**
  92517. * Gets the current transform matrix
  92518. * @returns a Matrix made of View * Projection
  92519. */
  92520. getTransformMatrix(): Matrix;
  92521. /**
  92522. * Sets the current transform matrix
  92523. * @param viewL defines the View matrix to use
  92524. * @param projectionL defines the Projection matrix to use
  92525. * @param viewR defines the right View matrix to use (if provided)
  92526. * @param projectionR defines the right Projection matrix to use (if provided)
  92527. */
  92528. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  92529. /**
  92530. * Gets the uniform buffer used to store scene data
  92531. * @returns a UniformBuffer
  92532. */
  92533. getSceneUniformBuffer(): UniformBuffer;
  92534. /**
  92535. * Gets an unique (relatively to the current scene) Id
  92536. * @returns an unique number for the scene
  92537. */
  92538. getUniqueId(): number;
  92539. /**
  92540. * Add a mesh to the list of scene's meshes
  92541. * @param newMesh defines the mesh to add
  92542. * @param recursive if all child meshes should also be added to the scene
  92543. */
  92544. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  92545. /**
  92546. * Remove a mesh for the list of scene's meshes
  92547. * @param toRemove defines the mesh to remove
  92548. * @param recursive if all child meshes should also be removed from the scene
  92549. * @returns the index where the mesh was in the mesh list
  92550. */
  92551. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  92552. /**
  92553. * Add a transform node to the list of scene's transform nodes
  92554. * @param newTransformNode defines the transform node to add
  92555. */
  92556. addTransformNode(newTransformNode: TransformNode): void;
  92557. /**
  92558. * Remove a transform node for the list of scene's transform nodes
  92559. * @param toRemove defines the transform node to remove
  92560. * @returns the index where the transform node was in the transform node list
  92561. */
  92562. removeTransformNode(toRemove: TransformNode): number;
  92563. /**
  92564. * Remove a skeleton for the list of scene's skeletons
  92565. * @param toRemove defines the skeleton to remove
  92566. * @returns the index where the skeleton was in the skeleton list
  92567. */
  92568. removeSkeleton(toRemove: Skeleton): number;
  92569. /**
  92570. * Remove a morph target for the list of scene's morph targets
  92571. * @param toRemove defines the morph target to remove
  92572. * @returns the index where the morph target was in the morph target list
  92573. */
  92574. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  92575. /**
  92576. * Remove a light for the list of scene's lights
  92577. * @param toRemove defines the light to remove
  92578. * @returns the index where the light was in the light list
  92579. */
  92580. removeLight(toRemove: Light): number;
  92581. /**
  92582. * Remove a camera for the list of scene's cameras
  92583. * @param toRemove defines the camera to remove
  92584. * @returns the index where the camera was in the camera list
  92585. */
  92586. removeCamera(toRemove: Camera): number;
  92587. /**
  92588. * Remove a particle system for the list of scene's particle systems
  92589. * @param toRemove defines the particle system to remove
  92590. * @returns the index where the particle system was in the particle system list
  92591. */
  92592. removeParticleSystem(toRemove: IParticleSystem): number;
  92593. /**
  92594. * Remove a animation for the list of scene's animations
  92595. * @param toRemove defines the animation to remove
  92596. * @returns the index where the animation was in the animation list
  92597. */
  92598. removeAnimation(toRemove: Animation): number;
  92599. /**
  92600. * Removes the given animation group from this scene.
  92601. * @param toRemove The animation group to remove
  92602. * @returns The index of the removed animation group
  92603. */
  92604. removeAnimationGroup(toRemove: AnimationGroup): number;
  92605. /**
  92606. * Removes the given multi-material from this scene.
  92607. * @param toRemove The multi-material to remove
  92608. * @returns The index of the removed multi-material
  92609. */
  92610. removeMultiMaterial(toRemove: MultiMaterial): number;
  92611. /**
  92612. * Removes the given material from this scene.
  92613. * @param toRemove The material to remove
  92614. * @returns The index of the removed material
  92615. */
  92616. removeMaterial(toRemove: Material): number;
  92617. /**
  92618. * Removes the given action manager from this scene.
  92619. * @param toRemove The action manager to remove
  92620. * @returns The index of the removed action manager
  92621. */
  92622. removeActionManager(toRemove: AbstractActionManager): number;
  92623. /**
  92624. * Removes the given texture from this scene.
  92625. * @param toRemove The texture to remove
  92626. * @returns The index of the removed texture
  92627. */
  92628. removeTexture(toRemove: BaseTexture): number;
  92629. /**
  92630. * Adds the given light to this scene
  92631. * @param newLight The light to add
  92632. */
  92633. addLight(newLight: Light): void;
  92634. /**
  92635. * Sorts the list list based on light priorities
  92636. */
  92637. sortLightsByPriority(): void;
  92638. /**
  92639. * Adds the given camera to this scene
  92640. * @param newCamera The camera to add
  92641. */
  92642. addCamera(newCamera: Camera): void;
  92643. /**
  92644. * Adds the given skeleton to this scene
  92645. * @param newSkeleton The skeleton to add
  92646. */
  92647. addSkeleton(newSkeleton: Skeleton): void;
  92648. /**
  92649. * Adds the given particle system to this scene
  92650. * @param newParticleSystem The particle system to add
  92651. */
  92652. addParticleSystem(newParticleSystem: IParticleSystem): void;
  92653. /**
  92654. * Adds the given animation to this scene
  92655. * @param newAnimation The animation to add
  92656. */
  92657. addAnimation(newAnimation: Animation): void;
  92658. /**
  92659. * Adds the given animation group to this scene.
  92660. * @param newAnimationGroup The animation group to add
  92661. */
  92662. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  92663. /**
  92664. * Adds the given multi-material to this scene
  92665. * @param newMultiMaterial The multi-material to add
  92666. */
  92667. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  92668. /**
  92669. * Adds the given material to this scene
  92670. * @param newMaterial The material to add
  92671. */
  92672. addMaterial(newMaterial: Material): void;
  92673. /**
  92674. * Adds the given morph target to this scene
  92675. * @param newMorphTargetManager The morph target to add
  92676. */
  92677. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  92678. /**
  92679. * Adds the given geometry to this scene
  92680. * @param newGeometry The geometry to add
  92681. */
  92682. addGeometry(newGeometry: Geometry): void;
  92683. /**
  92684. * Adds the given action manager to this scene
  92685. * @param newActionManager The action manager to add
  92686. */
  92687. addActionManager(newActionManager: AbstractActionManager): void;
  92688. /**
  92689. * Adds the given texture to this scene.
  92690. * @param newTexture The texture to add
  92691. */
  92692. addTexture(newTexture: BaseTexture): void;
  92693. /**
  92694. * Switch active camera
  92695. * @param newCamera defines the new active camera
  92696. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  92697. */
  92698. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  92699. /**
  92700. * sets the active camera of the scene using its ID
  92701. * @param id defines the camera's ID
  92702. * @return the new active camera or null if none found.
  92703. */
  92704. setActiveCameraByID(id: string): Nullable<Camera>;
  92705. /**
  92706. * sets the active camera of the scene using its name
  92707. * @param name defines the camera's name
  92708. * @returns the new active camera or null if none found.
  92709. */
  92710. setActiveCameraByName(name: string): Nullable<Camera>;
  92711. /**
  92712. * get an animation group using its name
  92713. * @param name defines the material's name
  92714. * @return the animation group or null if none found.
  92715. */
  92716. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  92717. /**
  92718. * Get a material using its unique id
  92719. * @param uniqueId defines the material's unique id
  92720. * @return the material or null if none found.
  92721. */
  92722. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  92723. /**
  92724. * get a material using its id
  92725. * @param id defines the material's ID
  92726. * @return the material or null if none found.
  92727. */
  92728. getMaterialByID(id: string): Nullable<Material>;
  92729. /**
  92730. * Gets a material using its name
  92731. * @param name defines the material's name
  92732. * @return the material or null if none found.
  92733. */
  92734. getMaterialByName(name: string): Nullable<Material>;
  92735. /**
  92736. * Gets a camera using its id
  92737. * @param id defines the id to look for
  92738. * @returns the camera or null if not found
  92739. */
  92740. getCameraByID(id: string): Nullable<Camera>;
  92741. /**
  92742. * Gets a camera using its unique id
  92743. * @param uniqueId defines the unique id to look for
  92744. * @returns the camera or null if not found
  92745. */
  92746. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  92747. /**
  92748. * Gets a camera using its name
  92749. * @param name defines the camera's name
  92750. * @return the camera or null if none found.
  92751. */
  92752. getCameraByName(name: string): Nullable<Camera>;
  92753. /**
  92754. * Gets a bone using its id
  92755. * @param id defines the bone's id
  92756. * @return the bone or null if not found
  92757. */
  92758. getBoneByID(id: string): Nullable<Bone>;
  92759. /**
  92760. * Gets a bone using its id
  92761. * @param name defines the bone's name
  92762. * @return the bone or null if not found
  92763. */
  92764. getBoneByName(name: string): Nullable<Bone>;
  92765. /**
  92766. * Gets a light node using its name
  92767. * @param name defines the the light's name
  92768. * @return the light or null if none found.
  92769. */
  92770. getLightByName(name: string): Nullable<Light>;
  92771. /**
  92772. * Gets a light node using its id
  92773. * @param id defines the light's id
  92774. * @return the light or null if none found.
  92775. */
  92776. getLightByID(id: string): Nullable<Light>;
  92777. /**
  92778. * Gets a light node using its scene-generated unique ID
  92779. * @param uniqueId defines the light's unique id
  92780. * @return the light or null if none found.
  92781. */
  92782. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  92783. /**
  92784. * Gets a particle system by id
  92785. * @param id defines the particle system id
  92786. * @return the corresponding system or null if none found
  92787. */
  92788. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  92789. /**
  92790. * Gets a geometry using its ID
  92791. * @param id defines the geometry's id
  92792. * @return the geometry or null if none found.
  92793. */
  92794. getGeometryByID(id: string): Nullable<Geometry>;
  92795. private _getGeometryByUniqueID;
  92796. /**
  92797. * Add a new geometry to this scene
  92798. * @param geometry defines the geometry to be added to the scene.
  92799. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  92800. * @return a boolean defining if the geometry was added or not
  92801. */
  92802. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  92803. /**
  92804. * Removes an existing geometry
  92805. * @param geometry defines the geometry to be removed from the scene
  92806. * @return a boolean defining if the geometry was removed or not
  92807. */
  92808. removeGeometry(geometry: Geometry): boolean;
  92809. /**
  92810. * Gets the list of geometries attached to the scene
  92811. * @returns an array of Geometry
  92812. */
  92813. getGeometries(): Geometry[];
  92814. /**
  92815. * Gets the first added mesh found of a given ID
  92816. * @param id defines the id to search for
  92817. * @return the mesh found or null if not found at all
  92818. */
  92819. getMeshByID(id: string): Nullable<AbstractMesh>;
  92820. /**
  92821. * Gets a list of meshes using their id
  92822. * @param id defines the id to search for
  92823. * @returns a list of meshes
  92824. */
  92825. getMeshesByID(id: string): Array<AbstractMesh>;
  92826. /**
  92827. * Gets the first added transform node found of a given ID
  92828. * @param id defines the id to search for
  92829. * @return the found transform node or null if not found at all.
  92830. */
  92831. getTransformNodeByID(id: string): Nullable<TransformNode>;
  92832. /**
  92833. * Gets a transform node with its auto-generated unique id
  92834. * @param uniqueId efines the unique id to search for
  92835. * @return the found transform node or null if not found at all.
  92836. */
  92837. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  92838. /**
  92839. * Gets a list of transform nodes using their id
  92840. * @param id defines the id to search for
  92841. * @returns a list of transform nodes
  92842. */
  92843. getTransformNodesByID(id: string): Array<TransformNode>;
  92844. /**
  92845. * Gets a mesh with its auto-generated unique id
  92846. * @param uniqueId defines the unique id to search for
  92847. * @return the found mesh or null if not found at all.
  92848. */
  92849. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  92850. /**
  92851. * Gets a the last added mesh using a given id
  92852. * @param id defines the id to search for
  92853. * @return the found mesh or null if not found at all.
  92854. */
  92855. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  92856. /**
  92857. * Gets a the last added node (Mesh, Camera, Light) using a given id
  92858. * @param id defines the id to search for
  92859. * @return the found node or null if not found at all
  92860. */
  92861. getLastEntryByID(id: string): Nullable<Node>;
  92862. /**
  92863. * Gets a node (Mesh, Camera, Light) using a given id
  92864. * @param id defines the id to search for
  92865. * @return the found node or null if not found at all
  92866. */
  92867. getNodeByID(id: string): Nullable<Node>;
  92868. /**
  92869. * Gets a node (Mesh, Camera, Light) using a given name
  92870. * @param name defines the name to search for
  92871. * @return the found node or null if not found at all.
  92872. */
  92873. getNodeByName(name: string): Nullable<Node>;
  92874. /**
  92875. * Gets a mesh using a given name
  92876. * @param name defines the name to search for
  92877. * @return the found mesh or null if not found at all.
  92878. */
  92879. getMeshByName(name: string): Nullable<AbstractMesh>;
  92880. /**
  92881. * Gets a transform node using a given name
  92882. * @param name defines the name to search for
  92883. * @return the found transform node or null if not found at all.
  92884. */
  92885. getTransformNodeByName(name: string): Nullable<TransformNode>;
  92886. /**
  92887. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  92888. * @param id defines the id to search for
  92889. * @return the found skeleton or null if not found at all.
  92890. */
  92891. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  92892. /**
  92893. * Gets a skeleton using a given auto generated unique id
  92894. * @param uniqueId defines the unique id to search for
  92895. * @return the found skeleton or null if not found at all.
  92896. */
  92897. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  92898. /**
  92899. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  92900. * @param id defines the id to search for
  92901. * @return the found skeleton or null if not found at all.
  92902. */
  92903. getSkeletonById(id: string): Nullable<Skeleton>;
  92904. /**
  92905. * Gets a skeleton using a given name
  92906. * @param name defines the name to search for
  92907. * @return the found skeleton or null if not found at all.
  92908. */
  92909. getSkeletonByName(name: string): Nullable<Skeleton>;
  92910. /**
  92911. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  92912. * @param id defines the id to search for
  92913. * @return the found morph target manager or null if not found at all.
  92914. */
  92915. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  92916. /**
  92917. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  92918. * @param id defines the id to search for
  92919. * @return the found morph target or null if not found at all.
  92920. */
  92921. getMorphTargetById(id: string): Nullable<MorphTarget>;
  92922. /**
  92923. * Gets a boolean indicating if the given mesh is active
  92924. * @param mesh defines the mesh to look for
  92925. * @returns true if the mesh is in the active list
  92926. */
  92927. isActiveMesh(mesh: AbstractMesh): boolean;
  92928. /**
  92929. * Return a unique id as a string which can serve as an identifier for the scene
  92930. */
  92931. readonly uid: string;
  92932. /**
  92933. * Add an externaly attached data from its key.
  92934. * This method call will fail and return false, if such key already exists.
  92935. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  92936. * @param key the unique key that identifies the data
  92937. * @param data the data object to associate to the key for this Engine instance
  92938. * @return true if no such key were already present and the data was added successfully, false otherwise
  92939. */
  92940. addExternalData<T>(key: string, data: T): boolean;
  92941. /**
  92942. * Get an externaly attached data from its key
  92943. * @param key the unique key that identifies the data
  92944. * @return the associated data, if present (can be null), or undefined if not present
  92945. */
  92946. getExternalData<T>(key: string): Nullable<T>;
  92947. /**
  92948. * Get an externaly attached data from its key, create it using a factory if it's not already present
  92949. * @param key the unique key that identifies the data
  92950. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  92951. * @return the associated data, can be null if the factory returned null.
  92952. */
  92953. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  92954. /**
  92955. * Remove an externaly attached data from the Engine instance
  92956. * @param key the unique key that identifies the data
  92957. * @return true if the data was successfully removed, false if it doesn't exist
  92958. */
  92959. removeExternalData(key: string): boolean;
  92960. private _evaluateSubMesh;
  92961. /**
  92962. * Clear the processed materials smart array preventing retention point in material dispose.
  92963. */
  92964. freeProcessedMaterials(): void;
  92965. private _preventFreeActiveMeshesAndRenderingGroups;
  92966. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  92967. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  92968. * when disposing several meshes in a row or a hierarchy of meshes.
  92969. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  92970. */
  92971. blockfreeActiveMeshesAndRenderingGroups: boolean;
  92972. /**
  92973. * Clear the active meshes smart array preventing retention point in mesh dispose.
  92974. */
  92975. freeActiveMeshes(): void;
  92976. /**
  92977. * Clear the info related to rendering groups preventing retention points during dispose.
  92978. */
  92979. freeRenderingGroups(): void;
  92980. /** @hidden */
  92981. _isInIntermediateRendering(): boolean;
  92982. /**
  92983. * Lambda returning the list of potentially active meshes.
  92984. */
  92985. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  92986. /**
  92987. * Lambda returning the list of potentially active sub meshes.
  92988. */
  92989. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  92990. /**
  92991. * Lambda returning the list of potentially intersecting sub meshes.
  92992. */
  92993. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  92994. /**
  92995. * Lambda returning the list of potentially colliding sub meshes.
  92996. */
  92997. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  92998. private _activeMeshesFrozen;
  92999. /**
  93000. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  93001. * @returns the current scene
  93002. */
  93003. freezeActiveMeshes(): Scene;
  93004. /**
  93005. * Use this function to restart evaluating active meshes on every frame
  93006. * @returns the current scene
  93007. */
  93008. unfreezeActiveMeshes(): Scene;
  93009. private _evaluateActiveMeshes;
  93010. private _activeMesh;
  93011. /**
  93012. * Update the transform matrix to update from the current active camera
  93013. * @param force defines a boolean used to force the update even if cache is up to date
  93014. */
  93015. updateTransformMatrix(force?: boolean): void;
  93016. private _bindFrameBuffer;
  93017. /** @hidden */
  93018. _allowPostProcessClearColor: boolean;
  93019. /** @hidden */
  93020. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  93021. private _processSubCameras;
  93022. private _checkIntersections;
  93023. /** @hidden */
  93024. _advancePhysicsEngineStep(step: number): void;
  93025. /**
  93026. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  93027. */
  93028. getDeterministicFrameTime: () => number;
  93029. /** @hidden */
  93030. _animate(): void;
  93031. /** Execute all animations (for a frame) */
  93032. animate(): void;
  93033. /**
  93034. * Render the scene
  93035. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  93036. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  93037. */
  93038. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  93039. /**
  93040. * Freeze all materials
  93041. * A frozen material will not be updatable but should be faster to render
  93042. */
  93043. freezeMaterials(): void;
  93044. /**
  93045. * Unfreeze all materials
  93046. * A frozen material will not be updatable but should be faster to render
  93047. */
  93048. unfreezeMaterials(): void;
  93049. /**
  93050. * Releases all held ressources
  93051. */
  93052. dispose(): void;
  93053. /**
  93054. * Gets if the scene is already disposed
  93055. */
  93056. readonly isDisposed: boolean;
  93057. /**
  93058. * Call this function to reduce memory footprint of the scene.
  93059. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  93060. */
  93061. clearCachedVertexData(): void;
  93062. /**
  93063. * This function will remove the local cached buffer data from texture.
  93064. * It will save memory but will prevent the texture from being rebuilt
  93065. */
  93066. cleanCachedTextureBuffer(): void;
  93067. /**
  93068. * Get the world extend vectors with an optional filter
  93069. *
  93070. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  93071. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  93072. */
  93073. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  93074. min: Vector3;
  93075. max: Vector3;
  93076. };
  93077. /**
  93078. * Creates a ray that can be used to pick in the scene
  93079. * @param x defines the x coordinate of the origin (on-screen)
  93080. * @param y defines the y coordinate of the origin (on-screen)
  93081. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  93082. * @param camera defines the camera to use for the picking
  93083. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  93084. * @returns a Ray
  93085. */
  93086. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  93087. /**
  93088. * Creates a ray that can be used to pick in the scene
  93089. * @param x defines the x coordinate of the origin (on-screen)
  93090. * @param y defines the y coordinate of the origin (on-screen)
  93091. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  93092. * @param result defines the ray where to store the picking ray
  93093. * @param camera defines the camera to use for the picking
  93094. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  93095. * @returns the current scene
  93096. */
  93097. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  93098. /**
  93099. * Creates a ray that can be used to pick in the scene
  93100. * @param x defines the x coordinate of the origin (on-screen)
  93101. * @param y defines the y coordinate of the origin (on-screen)
  93102. * @param camera defines the camera to use for the picking
  93103. * @returns a Ray
  93104. */
  93105. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  93106. /**
  93107. * Creates a ray that can be used to pick in the scene
  93108. * @param x defines the x coordinate of the origin (on-screen)
  93109. * @param y defines the y coordinate of the origin (on-screen)
  93110. * @param result defines the ray where to store the picking ray
  93111. * @param camera defines the camera to use for the picking
  93112. * @returns the current scene
  93113. */
  93114. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  93115. /** Launch a ray to try to pick a mesh in the scene
  93116. * @param x position on screen
  93117. * @param y position on screen
  93118. * @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
  93119. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  93120. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  93121. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93122. * @returns a PickingInfo
  93123. */
  93124. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  93125. /** Use the given ray to pick a mesh in the scene
  93126. * @param ray The ray to use to pick meshes
  93127. * @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
  93128. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  93129. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93130. * @returns a PickingInfo
  93131. */
  93132. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  93133. /**
  93134. * Launch a ray to try to pick a mesh in the scene
  93135. * @param x X position on screen
  93136. * @param y Y position on screen
  93137. * @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
  93138. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  93139. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93140. * @returns an array of PickingInfo
  93141. */
  93142. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  93143. /**
  93144. * Launch a ray to try to pick a mesh in the scene
  93145. * @param ray Ray to use
  93146. * @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
  93147. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93148. * @returns an array of PickingInfo
  93149. */
  93150. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  93151. /**
  93152. * Force the value of meshUnderPointer
  93153. * @param mesh defines the mesh to use
  93154. */
  93155. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  93156. /**
  93157. * Gets the mesh under the pointer
  93158. * @returns a Mesh or null if no mesh is under the pointer
  93159. */
  93160. getPointerOverMesh(): Nullable<AbstractMesh>;
  93161. /** @hidden */
  93162. _rebuildGeometries(): void;
  93163. /** @hidden */
  93164. _rebuildTextures(): void;
  93165. private _getByTags;
  93166. /**
  93167. * Get a list of meshes by tags
  93168. * @param tagsQuery defines the tags query to use
  93169. * @param forEach defines a predicate used to filter results
  93170. * @returns an array of Mesh
  93171. */
  93172. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  93173. /**
  93174. * Get a list of cameras by tags
  93175. * @param tagsQuery defines the tags query to use
  93176. * @param forEach defines a predicate used to filter results
  93177. * @returns an array of Camera
  93178. */
  93179. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  93180. /**
  93181. * Get a list of lights by tags
  93182. * @param tagsQuery defines the tags query to use
  93183. * @param forEach defines a predicate used to filter results
  93184. * @returns an array of Light
  93185. */
  93186. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  93187. /**
  93188. * Get a list of materials by tags
  93189. * @param tagsQuery defines the tags query to use
  93190. * @param forEach defines a predicate used to filter results
  93191. * @returns an array of Material
  93192. */
  93193. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  93194. /**
  93195. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93196. * This allowed control for front to back rendering or reversly depending of the special needs.
  93197. *
  93198. * @param renderingGroupId The rendering group id corresponding to its index
  93199. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93200. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93201. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93202. */
  93203. 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;
  93204. /**
  93205. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93206. *
  93207. * @param renderingGroupId The rendering group id corresponding to its index
  93208. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93209. * @param depth Automatically clears depth between groups if true and autoClear is true.
  93210. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  93211. */
  93212. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  93213. /**
  93214. * Gets the current auto clear configuration for one rendering group of the rendering
  93215. * manager.
  93216. * @param index the rendering group index to get the information for
  93217. * @returns The auto clear setup for the requested rendering group
  93218. */
  93219. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  93220. private _blockMaterialDirtyMechanism;
  93221. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  93222. blockMaterialDirtyMechanism: boolean;
  93223. /**
  93224. * Will flag all materials as dirty to trigger new shader compilation
  93225. * @param flag defines the flag used to specify which material part must be marked as dirty
  93226. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  93227. */
  93228. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  93229. /** @hidden */
  93230. _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;
  93231. /** @hidden */
  93232. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  93233. }
  93234. }
  93235. declare module BABYLON {
  93236. /**
  93237. * Set of assets to keep when moving a scene into an asset container.
  93238. */
  93239. export class KeepAssets extends AbstractScene {
  93240. }
  93241. /**
  93242. * Container with a set of assets that can be added or removed from a scene.
  93243. */
  93244. export class AssetContainer extends AbstractScene {
  93245. /**
  93246. * The scene the AssetContainer belongs to.
  93247. */
  93248. scene: Scene;
  93249. /**
  93250. * Instantiates an AssetContainer.
  93251. * @param scene The scene the AssetContainer belongs to.
  93252. */
  93253. constructor(scene: Scene);
  93254. /**
  93255. * Adds all the assets from the container to the scene.
  93256. */
  93257. addAllToScene(): void;
  93258. /**
  93259. * Removes all the assets in the container from the scene
  93260. */
  93261. removeAllFromScene(): void;
  93262. /**
  93263. * Disposes all the assets in the container
  93264. */
  93265. dispose(): void;
  93266. private _moveAssets;
  93267. /**
  93268. * Removes all the assets contained in the scene and adds them to the container.
  93269. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  93270. */
  93271. moveAllFromScene(keepAssets?: KeepAssets): void;
  93272. /**
  93273. * 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.
  93274. * @returns the root mesh
  93275. */
  93276. createRootMesh(): Mesh;
  93277. }
  93278. }
  93279. declare module BABYLON {
  93280. /**
  93281. * Defines how the parser contract is defined.
  93282. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  93283. */
  93284. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  93285. /**
  93286. * Defines how the individual parser contract is defined.
  93287. * These parser can parse an individual asset
  93288. */
  93289. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  93290. /**
  93291. * Base class of the scene acting as a container for the different elements composing a scene.
  93292. * This class is dynamically extended by the different components of the scene increasing
  93293. * flexibility and reducing coupling
  93294. */
  93295. export abstract class AbstractScene {
  93296. /**
  93297. * Stores the list of available parsers in the application.
  93298. */
  93299. private static _BabylonFileParsers;
  93300. /**
  93301. * Stores the list of available individual parsers in the application.
  93302. */
  93303. private static _IndividualBabylonFileParsers;
  93304. /**
  93305. * Adds a parser in the list of available ones
  93306. * @param name Defines the name of the parser
  93307. * @param parser Defines the parser to add
  93308. */
  93309. static AddParser(name: string, parser: BabylonFileParser): void;
  93310. /**
  93311. * Gets a general parser from the list of avaialble ones
  93312. * @param name Defines the name of the parser
  93313. * @returns the requested parser or null
  93314. */
  93315. static GetParser(name: string): Nullable<BabylonFileParser>;
  93316. /**
  93317. * Adds n individual parser in the list of available ones
  93318. * @param name Defines the name of the parser
  93319. * @param parser Defines the parser to add
  93320. */
  93321. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  93322. /**
  93323. * Gets an individual parser from the list of avaialble ones
  93324. * @param name Defines the name of the parser
  93325. * @returns the requested parser or null
  93326. */
  93327. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  93328. /**
  93329. * Parser json data and populate both a scene and its associated container object
  93330. * @param jsonData Defines the data to parse
  93331. * @param scene Defines the scene to parse the data for
  93332. * @param container Defines the container attached to the parsing sequence
  93333. * @param rootUrl Defines the root url of the data
  93334. */
  93335. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  93336. /**
  93337. * Gets the list of root nodes (ie. nodes with no parent)
  93338. */
  93339. rootNodes: Node[];
  93340. /** All of the cameras added to this scene
  93341. * @see http://doc.babylonjs.com/babylon101/cameras
  93342. */
  93343. cameras: Camera[];
  93344. /**
  93345. * All of the lights added to this scene
  93346. * @see http://doc.babylonjs.com/babylon101/lights
  93347. */
  93348. lights: Light[];
  93349. /**
  93350. * All of the (abstract) meshes added to this scene
  93351. */
  93352. meshes: AbstractMesh[];
  93353. /**
  93354. * The list of skeletons added to the scene
  93355. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93356. */
  93357. skeletons: Skeleton[];
  93358. /**
  93359. * All of the particle systems added to this scene
  93360. * @see http://doc.babylonjs.com/babylon101/particles
  93361. */
  93362. particleSystems: IParticleSystem[];
  93363. /**
  93364. * Gets a list of Animations associated with the scene
  93365. */
  93366. animations: Animation[];
  93367. /**
  93368. * All of the animation groups added to this scene
  93369. * @see http://doc.babylonjs.com/how_to/group
  93370. */
  93371. animationGroups: AnimationGroup[];
  93372. /**
  93373. * All of the multi-materials added to this scene
  93374. * @see http://doc.babylonjs.com/how_to/multi_materials
  93375. */
  93376. multiMaterials: MultiMaterial[];
  93377. /**
  93378. * All of the materials added to this scene
  93379. * In the context of a Scene, it is not supposed to be modified manually.
  93380. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  93381. * Note also that the order of the Material wihin the array is not significant and might change.
  93382. * @see http://doc.babylonjs.com/babylon101/materials
  93383. */
  93384. materials: Material[];
  93385. /**
  93386. * The list of morph target managers added to the scene
  93387. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  93388. */
  93389. morphTargetManagers: MorphTargetManager[];
  93390. /**
  93391. * The list of geometries used in the scene.
  93392. */
  93393. geometries: Geometry[];
  93394. /**
  93395. * All of the tranform nodes added to this scene
  93396. * In the context of a Scene, it is not supposed to be modified manually.
  93397. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  93398. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  93399. * @see http://doc.babylonjs.com/how_to/transformnode
  93400. */
  93401. transformNodes: TransformNode[];
  93402. /**
  93403. * ActionManagers available on the scene.
  93404. */
  93405. actionManagers: AbstractActionManager[];
  93406. /**
  93407. * Textures to keep.
  93408. */
  93409. textures: BaseTexture[];
  93410. /**
  93411. * Environment texture for the scene
  93412. */
  93413. environmentTexture: Nullable<BaseTexture>;
  93414. }
  93415. }
  93416. declare module BABYLON {
  93417. /**
  93418. * Defines a sound that can be played in the application.
  93419. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  93420. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93421. */
  93422. export class Sound {
  93423. /**
  93424. * The name of the sound in the scene.
  93425. */
  93426. name: string;
  93427. /**
  93428. * Does the sound autoplay once loaded.
  93429. */
  93430. autoplay: boolean;
  93431. /**
  93432. * Does the sound loop after it finishes playing once.
  93433. */
  93434. loop: boolean;
  93435. /**
  93436. * Does the sound use a custom attenuation curve to simulate the falloff
  93437. * happening when the source gets further away from the camera.
  93438. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93439. */
  93440. useCustomAttenuation: boolean;
  93441. /**
  93442. * The sound track id this sound belongs to.
  93443. */
  93444. soundTrackId: number;
  93445. /**
  93446. * Is this sound currently played.
  93447. */
  93448. isPlaying: boolean;
  93449. /**
  93450. * Is this sound currently paused.
  93451. */
  93452. isPaused: boolean;
  93453. /**
  93454. * Does this sound enables spatial sound.
  93455. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93456. */
  93457. spatialSound: boolean;
  93458. /**
  93459. * Define the reference distance the sound should be heard perfectly.
  93460. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93461. */
  93462. refDistance: number;
  93463. /**
  93464. * Define the roll off factor of spatial sounds.
  93465. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93466. */
  93467. rolloffFactor: number;
  93468. /**
  93469. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  93470. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93471. */
  93472. maxDistance: number;
  93473. /**
  93474. * Define the distance attenuation model the sound will follow.
  93475. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93476. */
  93477. distanceModel: string;
  93478. /**
  93479. * @hidden
  93480. * Back Compat
  93481. **/
  93482. onended: () => any;
  93483. /**
  93484. * Observable event when the current playing sound finishes.
  93485. */
  93486. onEndedObservable: Observable<Sound>;
  93487. private _panningModel;
  93488. private _playbackRate;
  93489. private _streaming;
  93490. private _startTime;
  93491. private _startOffset;
  93492. private _position;
  93493. /** @hidden */
  93494. _positionInEmitterSpace: boolean;
  93495. private _localDirection;
  93496. private _volume;
  93497. private _isReadyToPlay;
  93498. private _isDirectional;
  93499. private _readyToPlayCallback;
  93500. private _audioBuffer;
  93501. private _soundSource;
  93502. private _streamingSource;
  93503. private _soundPanner;
  93504. private _soundGain;
  93505. private _inputAudioNode;
  93506. private _outputAudioNode;
  93507. private _coneInnerAngle;
  93508. private _coneOuterAngle;
  93509. private _coneOuterGain;
  93510. private _scene;
  93511. private _connectedTransformNode;
  93512. private _customAttenuationFunction;
  93513. private _registerFunc;
  93514. private _isOutputConnected;
  93515. private _htmlAudioElement;
  93516. private _urlType;
  93517. /** @hidden */
  93518. static _SceneComponentInitialization: (scene: Scene) => void;
  93519. /**
  93520. * Create a sound and attach it to a scene
  93521. * @param name Name of your sound
  93522. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  93523. * @param scene defines the scene the sound belongs to
  93524. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  93525. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  93526. */
  93527. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  93528. /**
  93529. * Release the sound and its associated resources
  93530. */
  93531. dispose(): void;
  93532. /**
  93533. * Gets if the sounds is ready to be played or not.
  93534. * @returns true if ready, otherwise false
  93535. */
  93536. isReady(): boolean;
  93537. private _soundLoaded;
  93538. /**
  93539. * Sets the data of the sound from an audiobuffer
  93540. * @param audioBuffer The audioBuffer containing the data
  93541. */
  93542. setAudioBuffer(audioBuffer: AudioBuffer): void;
  93543. /**
  93544. * Updates the current sounds options such as maxdistance, loop...
  93545. * @param options A JSON object containing values named as the object properties
  93546. */
  93547. updateOptions(options: any): void;
  93548. private _createSpatialParameters;
  93549. private _updateSpatialParameters;
  93550. /**
  93551. * Switch the panning model to HRTF:
  93552. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93553. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93554. */
  93555. switchPanningModelToHRTF(): void;
  93556. /**
  93557. * Switch the panning model to Equal Power:
  93558. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93559. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93560. */
  93561. switchPanningModelToEqualPower(): void;
  93562. private _switchPanningModel;
  93563. /**
  93564. * Connect this sound to a sound track audio node like gain...
  93565. * @param soundTrackAudioNode the sound track audio node to connect to
  93566. */
  93567. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  93568. /**
  93569. * Transform this sound into a directional source
  93570. * @param coneInnerAngle Size of the inner cone in degree
  93571. * @param coneOuterAngle Size of the outer cone in degree
  93572. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  93573. */
  93574. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  93575. /**
  93576. * Gets or sets the inner angle for the directional cone.
  93577. */
  93578. /**
  93579. * Gets or sets the inner angle for the directional cone.
  93580. */
  93581. directionalConeInnerAngle: number;
  93582. /**
  93583. * Gets or sets the outer angle for the directional cone.
  93584. */
  93585. /**
  93586. * Gets or sets the outer angle for the directional cone.
  93587. */
  93588. directionalConeOuterAngle: number;
  93589. /**
  93590. * Sets the position of the emitter if spatial sound is enabled
  93591. * @param newPosition Defines the new posisiton
  93592. */
  93593. setPosition(newPosition: Vector3): void;
  93594. /**
  93595. * Sets the local direction of the emitter if spatial sound is enabled
  93596. * @param newLocalDirection Defines the new local direction
  93597. */
  93598. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  93599. private _updateDirection;
  93600. /** @hidden */
  93601. updateDistanceFromListener(): void;
  93602. /**
  93603. * Sets a new custom attenuation function for the sound.
  93604. * @param callback Defines the function used for the attenuation
  93605. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93606. */
  93607. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  93608. /**
  93609. * Play the sound
  93610. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  93611. * @param offset (optional) Start the sound setting it at a specific time
  93612. */
  93613. play(time?: number, offset?: number): void;
  93614. private _onended;
  93615. /**
  93616. * Stop the sound
  93617. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  93618. */
  93619. stop(time?: number): void;
  93620. /**
  93621. * Put the sound in pause
  93622. */
  93623. pause(): void;
  93624. /**
  93625. * Sets a dedicated volume for this sounds
  93626. * @param newVolume Define the new volume of the sound
  93627. * @param time Define in how long the sound should be at this value
  93628. */
  93629. setVolume(newVolume: number, time?: number): void;
  93630. /**
  93631. * Set the sound play back rate
  93632. * @param newPlaybackRate Define the playback rate the sound should be played at
  93633. */
  93634. setPlaybackRate(newPlaybackRate: number): void;
  93635. /**
  93636. * Gets the volume of the sound.
  93637. * @returns the volume of the sound
  93638. */
  93639. getVolume(): number;
  93640. /**
  93641. * Attach the sound to a dedicated mesh
  93642. * @param transformNode The transform node to connect the sound with
  93643. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  93644. */
  93645. attachToMesh(transformNode: TransformNode): void;
  93646. /**
  93647. * Detach the sound from the previously attached mesh
  93648. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  93649. */
  93650. detachFromMesh(): void;
  93651. private _onRegisterAfterWorldMatrixUpdate;
  93652. /**
  93653. * Clone the current sound in the scene.
  93654. * @returns the new sound clone
  93655. */
  93656. clone(): Nullable<Sound>;
  93657. /**
  93658. * Gets the current underlying audio buffer containing the data
  93659. * @returns the audio buffer
  93660. */
  93661. getAudioBuffer(): Nullable<AudioBuffer>;
  93662. /**
  93663. * Serializes the Sound in a JSON representation
  93664. * @returns the JSON representation of the sound
  93665. */
  93666. serialize(): any;
  93667. /**
  93668. * Parse a JSON representation of a sound to innstantiate in a given scene
  93669. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  93670. * @param scene Define the scene the new parsed sound should be created in
  93671. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  93672. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  93673. * @returns the newly parsed sound
  93674. */
  93675. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  93676. }
  93677. }
  93678. declare module BABYLON {
  93679. /**
  93680. * This defines an action helpful to play a defined sound on a triggered action.
  93681. */
  93682. export class PlaySoundAction extends Action {
  93683. private _sound;
  93684. /**
  93685. * Instantiate the action
  93686. * @param triggerOptions defines the trigger options
  93687. * @param sound defines the sound to play
  93688. * @param condition defines the trigger related conditions
  93689. */
  93690. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  93691. /** @hidden */
  93692. _prepare(): void;
  93693. /**
  93694. * Execute the action and play the sound.
  93695. */
  93696. execute(): void;
  93697. /**
  93698. * Serializes the actions and its related information.
  93699. * @param parent defines the object to serialize in
  93700. * @returns the serialized object
  93701. */
  93702. serialize(parent: any): any;
  93703. }
  93704. /**
  93705. * This defines an action helpful to stop a defined sound on a triggered action.
  93706. */
  93707. export class StopSoundAction extends Action {
  93708. private _sound;
  93709. /**
  93710. * Instantiate the action
  93711. * @param triggerOptions defines the trigger options
  93712. * @param sound defines the sound to stop
  93713. * @param condition defines the trigger related conditions
  93714. */
  93715. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  93716. /** @hidden */
  93717. _prepare(): void;
  93718. /**
  93719. * Execute the action and stop the sound.
  93720. */
  93721. execute(): void;
  93722. /**
  93723. * Serializes the actions and its related information.
  93724. * @param parent defines the object to serialize in
  93725. * @returns the serialized object
  93726. */
  93727. serialize(parent: any): any;
  93728. }
  93729. }
  93730. declare module BABYLON {
  93731. /**
  93732. * This defines an action responsible to change the value of a property
  93733. * by interpolating between its current value and the newly set one once triggered.
  93734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93735. */
  93736. export class InterpolateValueAction extends Action {
  93737. /**
  93738. * Defines the path of the property where the value should be interpolated
  93739. */
  93740. propertyPath: string;
  93741. /**
  93742. * Defines the target value at the end of the interpolation.
  93743. */
  93744. value: any;
  93745. /**
  93746. * Defines the time it will take for the property to interpolate to the value.
  93747. */
  93748. duration: number;
  93749. /**
  93750. * Defines if the other scene animations should be stopped when the action has been triggered
  93751. */
  93752. stopOtherAnimations?: boolean;
  93753. /**
  93754. * Defines a callback raised once the interpolation animation has been done.
  93755. */
  93756. onInterpolationDone?: () => void;
  93757. /**
  93758. * Observable triggered once the interpolation animation has been done.
  93759. */
  93760. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  93761. private _target;
  93762. private _effectiveTarget;
  93763. private _property;
  93764. /**
  93765. * Instantiate the action
  93766. * @param triggerOptions defines the trigger options
  93767. * @param target defines the object containing the value to interpolate
  93768. * @param propertyPath defines the path to the property in the target object
  93769. * @param value defines the target value at the end of the interpolation
  93770. * @param duration deines the time it will take for the property to interpolate to the value.
  93771. * @param condition defines the trigger related conditions
  93772. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  93773. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  93774. */
  93775. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  93776. /** @hidden */
  93777. _prepare(): void;
  93778. /**
  93779. * Execute the action starts the value interpolation.
  93780. */
  93781. execute(): void;
  93782. /**
  93783. * Serializes the actions and its related information.
  93784. * @param parent defines the object to serialize in
  93785. * @returns the serialized object
  93786. */
  93787. serialize(parent: any): any;
  93788. }
  93789. }
  93790. declare module BABYLON {
  93791. /**
  93792. * Options allowed during the creation of a sound track.
  93793. */
  93794. export interface ISoundTrackOptions {
  93795. /**
  93796. * The volume the sound track should take during creation
  93797. */
  93798. volume?: number;
  93799. /**
  93800. * Define if the sound track is the main sound track of the scene
  93801. */
  93802. mainTrack?: boolean;
  93803. }
  93804. /**
  93805. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  93806. * It will be also used in a future release to apply effects on a specific track.
  93807. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  93808. */
  93809. export class SoundTrack {
  93810. /**
  93811. * The unique identifier of the sound track in the scene.
  93812. */
  93813. id: number;
  93814. /**
  93815. * The list of sounds included in the sound track.
  93816. */
  93817. soundCollection: Array<Sound>;
  93818. private _outputAudioNode;
  93819. private _scene;
  93820. private _isMainTrack;
  93821. private _connectedAnalyser;
  93822. private _options;
  93823. private _isInitialized;
  93824. /**
  93825. * Creates a new sound track.
  93826. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  93827. * @param scene Define the scene the sound track belongs to
  93828. * @param options
  93829. */
  93830. constructor(scene: Scene, options?: ISoundTrackOptions);
  93831. private _initializeSoundTrackAudioGraph;
  93832. /**
  93833. * Release the sound track and its associated resources
  93834. */
  93835. dispose(): void;
  93836. /**
  93837. * Adds a sound to this sound track
  93838. * @param sound define the cound to add
  93839. * @ignoreNaming
  93840. */
  93841. AddSound(sound: Sound): void;
  93842. /**
  93843. * Removes a sound to this sound track
  93844. * @param sound define the cound to remove
  93845. * @ignoreNaming
  93846. */
  93847. RemoveSound(sound: Sound): void;
  93848. /**
  93849. * Set a global volume for the full sound track.
  93850. * @param newVolume Define the new volume of the sound track
  93851. */
  93852. setVolume(newVolume: number): void;
  93853. /**
  93854. * Switch the panning model to HRTF:
  93855. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93857. */
  93858. switchPanningModelToHRTF(): void;
  93859. /**
  93860. * Switch the panning model to Equal Power:
  93861. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93862. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93863. */
  93864. switchPanningModelToEqualPower(): void;
  93865. /**
  93866. * Connect the sound track to an audio analyser allowing some amazing
  93867. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  93868. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  93869. * @param analyser The analyser to connect to the engine
  93870. */
  93871. connectToAnalyser(analyser: Analyser): void;
  93872. }
  93873. }
  93874. declare module BABYLON {
  93875. interface AbstractScene {
  93876. /**
  93877. * The list of sounds used in the scene.
  93878. */
  93879. sounds: Nullable<Array<Sound>>;
  93880. }
  93881. interface Scene {
  93882. /**
  93883. * @hidden
  93884. * Backing field
  93885. */
  93886. _mainSoundTrack: SoundTrack;
  93887. /**
  93888. * The main sound track played by the scene.
  93889. * It cotains your primary collection of sounds.
  93890. */
  93891. mainSoundTrack: SoundTrack;
  93892. /**
  93893. * The list of sound tracks added to the scene
  93894. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93895. */
  93896. soundTracks: Nullable<Array<SoundTrack>>;
  93897. /**
  93898. * Gets a sound using a given name
  93899. * @param name defines the name to search for
  93900. * @return the found sound or null if not found at all.
  93901. */
  93902. getSoundByName(name: string): Nullable<Sound>;
  93903. /**
  93904. * Gets or sets if audio support is enabled
  93905. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93906. */
  93907. audioEnabled: boolean;
  93908. /**
  93909. * Gets or sets if audio will be output to headphones
  93910. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93911. */
  93912. headphone: boolean;
  93913. }
  93914. /**
  93915. * Defines the sound scene component responsible to manage any sounds
  93916. * in a given scene.
  93917. */
  93918. export class AudioSceneComponent implements ISceneSerializableComponent {
  93919. /**
  93920. * The component name helpfull to identify the component in the list of scene components.
  93921. */
  93922. readonly name: string;
  93923. /**
  93924. * The scene the component belongs to.
  93925. */
  93926. scene: Scene;
  93927. private _audioEnabled;
  93928. /**
  93929. * Gets whether audio is enabled or not.
  93930. * Please use related enable/disable method to switch state.
  93931. */
  93932. readonly audioEnabled: boolean;
  93933. private _headphone;
  93934. /**
  93935. * Gets whether audio is outputing to headphone or not.
  93936. * Please use the according Switch methods to change output.
  93937. */
  93938. readonly headphone: boolean;
  93939. /**
  93940. * Creates a new instance of the component for the given scene
  93941. * @param scene Defines the scene to register the component in
  93942. */
  93943. constructor(scene: Scene);
  93944. /**
  93945. * Registers the component in a given scene
  93946. */
  93947. register(): void;
  93948. /**
  93949. * Rebuilds the elements related to this component in case of
  93950. * context lost for instance.
  93951. */
  93952. rebuild(): void;
  93953. /**
  93954. * Serializes the component data to the specified json object
  93955. * @param serializationObject The object to serialize to
  93956. */
  93957. serialize(serializationObject: any): void;
  93958. /**
  93959. * Adds all the element from the container to the scene
  93960. * @param container the container holding the elements
  93961. */
  93962. addFromContainer(container: AbstractScene): void;
  93963. /**
  93964. * Removes all the elements in the container from the scene
  93965. * @param container contains the elements to remove
  93966. * @param dispose if the removed element should be disposed (default: false)
  93967. */
  93968. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  93969. /**
  93970. * Disposes the component and the associated ressources.
  93971. */
  93972. dispose(): void;
  93973. /**
  93974. * Disables audio in the associated scene.
  93975. */
  93976. disableAudio(): void;
  93977. /**
  93978. * Enables audio in the associated scene.
  93979. */
  93980. enableAudio(): void;
  93981. /**
  93982. * Switch audio to headphone output.
  93983. */
  93984. switchAudioModeForHeadphones(): void;
  93985. /**
  93986. * Switch audio to normal speakers.
  93987. */
  93988. switchAudioModeForNormalSpeakers(): void;
  93989. private _afterRender;
  93990. }
  93991. }
  93992. declare module BABYLON {
  93993. /**
  93994. * Wraps one or more Sound objects and selects one with random weight for playback.
  93995. */
  93996. export class WeightedSound {
  93997. /** When true a Sound will be selected and played when the current playing Sound completes. */
  93998. loop: boolean;
  93999. private _coneInnerAngle;
  94000. private _coneOuterAngle;
  94001. private _volume;
  94002. /** A Sound is currently playing. */
  94003. isPlaying: boolean;
  94004. /** A Sound is currently paused. */
  94005. isPaused: boolean;
  94006. private _sounds;
  94007. private _weights;
  94008. private _currentIndex?;
  94009. /**
  94010. * Creates a new WeightedSound from the list of sounds given.
  94011. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  94012. * @param sounds Array of Sounds that will be selected from.
  94013. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  94014. */
  94015. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  94016. /**
  94017. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  94018. */
  94019. /**
  94020. * The size of cone in degress for a directional sound in which there will be no attenuation.
  94021. */
  94022. directionalConeInnerAngle: number;
  94023. /**
  94024. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  94025. * Listener angles between innerAngle and outerAngle will falloff linearly.
  94026. */
  94027. /**
  94028. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  94029. * Listener angles between innerAngle and outerAngle will falloff linearly.
  94030. */
  94031. directionalConeOuterAngle: number;
  94032. /**
  94033. * Playback volume.
  94034. */
  94035. /**
  94036. * Playback volume.
  94037. */
  94038. volume: number;
  94039. private _onended;
  94040. /**
  94041. * Suspend playback
  94042. */
  94043. pause(): void;
  94044. /**
  94045. * Stop playback
  94046. */
  94047. stop(): void;
  94048. /**
  94049. * Start playback.
  94050. * @param startOffset Position the clip head at a specific time in seconds.
  94051. */
  94052. play(startOffset?: number): void;
  94053. }
  94054. }
  94055. declare module BABYLON {
  94056. /**
  94057. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  94058. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94059. */
  94060. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  94061. /**
  94062. * Gets the name of the behavior.
  94063. */
  94064. readonly name: string;
  94065. /**
  94066. * The easing function used by animations
  94067. */
  94068. static EasingFunction: BackEase;
  94069. /**
  94070. * The easing mode used by animations
  94071. */
  94072. static EasingMode: number;
  94073. /**
  94074. * The duration of the animation, in milliseconds
  94075. */
  94076. transitionDuration: number;
  94077. /**
  94078. * Length of the distance animated by the transition when lower radius is reached
  94079. */
  94080. lowerRadiusTransitionRange: number;
  94081. /**
  94082. * Length of the distance animated by the transition when upper radius is reached
  94083. */
  94084. upperRadiusTransitionRange: number;
  94085. private _autoTransitionRange;
  94086. /**
  94087. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  94088. */
  94089. /**
  94090. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  94091. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  94092. */
  94093. autoTransitionRange: boolean;
  94094. private _attachedCamera;
  94095. private _onAfterCheckInputsObserver;
  94096. private _onMeshTargetChangedObserver;
  94097. /**
  94098. * Initializes the behavior.
  94099. */
  94100. init(): void;
  94101. /**
  94102. * Attaches the behavior to its arc rotate camera.
  94103. * @param camera Defines the camera to attach the behavior to
  94104. */
  94105. attach(camera: ArcRotateCamera): void;
  94106. /**
  94107. * Detaches the behavior from its current arc rotate camera.
  94108. */
  94109. detach(): void;
  94110. private _radiusIsAnimating;
  94111. private _radiusBounceTransition;
  94112. private _animatables;
  94113. private _cachedWheelPrecision;
  94114. /**
  94115. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  94116. * @param radiusLimit The limit to check against.
  94117. * @return Bool to indicate if at limit.
  94118. */
  94119. private _isRadiusAtLimit;
  94120. /**
  94121. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  94122. * @param radiusDelta The delta by which to animate to. Can be negative.
  94123. */
  94124. private _applyBoundRadiusAnimation;
  94125. /**
  94126. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  94127. */
  94128. protected _clearAnimationLocks(): void;
  94129. /**
  94130. * Stops and removes all animations that have been applied to the camera
  94131. */
  94132. stopAllAnimations(): void;
  94133. }
  94134. }
  94135. declare module BABYLON {
  94136. /**
  94137. * 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.
  94138. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94139. */
  94140. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  94141. /**
  94142. * Gets the name of the behavior.
  94143. */
  94144. readonly name: string;
  94145. private _mode;
  94146. private _radiusScale;
  94147. private _positionScale;
  94148. private _defaultElevation;
  94149. private _elevationReturnTime;
  94150. private _elevationReturnWaitTime;
  94151. private _zoomStopsAnimation;
  94152. private _framingTime;
  94153. /**
  94154. * The easing function used by animations
  94155. */
  94156. static EasingFunction: ExponentialEase;
  94157. /**
  94158. * The easing mode used by animations
  94159. */
  94160. static EasingMode: number;
  94161. /**
  94162. * Sets the current mode used by the behavior
  94163. */
  94164. /**
  94165. * Gets current mode used by the behavior.
  94166. */
  94167. mode: number;
  94168. /**
  94169. * Sets the scale applied to the radius (1 by default)
  94170. */
  94171. /**
  94172. * Gets the scale applied to the radius
  94173. */
  94174. radiusScale: number;
  94175. /**
  94176. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94177. */
  94178. /**
  94179. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94180. */
  94181. positionScale: number;
  94182. /**
  94183. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  94184. * behaviour is triggered, in radians.
  94185. */
  94186. /**
  94187. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  94188. * behaviour is triggered, in radians.
  94189. */
  94190. defaultElevation: number;
  94191. /**
  94192. * Sets the time (in milliseconds) taken to return to the default beta position.
  94193. * Negative value indicates camera should not return to default.
  94194. */
  94195. /**
  94196. * Gets the time (in milliseconds) taken to return to the default beta position.
  94197. * Negative value indicates camera should not return to default.
  94198. */
  94199. elevationReturnTime: number;
  94200. /**
  94201. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94202. */
  94203. /**
  94204. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94205. */
  94206. elevationReturnWaitTime: number;
  94207. /**
  94208. * Sets the flag that indicates if user zooming should stop animation.
  94209. */
  94210. /**
  94211. * Gets the flag that indicates if user zooming should stop animation.
  94212. */
  94213. zoomStopsAnimation: boolean;
  94214. /**
  94215. * Sets the transition time when framing the mesh, in milliseconds
  94216. */
  94217. /**
  94218. * Gets the transition time when framing the mesh, in milliseconds
  94219. */
  94220. framingTime: number;
  94221. /**
  94222. * Define if the behavior should automatically change the configured
  94223. * camera limits and sensibilities.
  94224. */
  94225. autoCorrectCameraLimitsAndSensibility: boolean;
  94226. private _onPrePointerObservableObserver;
  94227. private _onAfterCheckInputsObserver;
  94228. private _onMeshTargetChangedObserver;
  94229. private _attachedCamera;
  94230. private _isPointerDown;
  94231. private _lastInteractionTime;
  94232. /**
  94233. * Initializes the behavior.
  94234. */
  94235. init(): void;
  94236. /**
  94237. * Attaches the behavior to its arc rotate camera.
  94238. * @param camera Defines the camera to attach the behavior to
  94239. */
  94240. attach(camera: ArcRotateCamera): void;
  94241. /**
  94242. * Detaches the behavior from its current arc rotate camera.
  94243. */
  94244. detach(): void;
  94245. private _animatables;
  94246. private _betaIsAnimating;
  94247. private _betaTransition;
  94248. private _radiusTransition;
  94249. private _vectorTransition;
  94250. /**
  94251. * Targets the given mesh and updates zoom level accordingly.
  94252. * @param mesh The mesh to target.
  94253. * @param radius Optional. If a cached radius position already exists, overrides default.
  94254. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94255. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94256. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94257. */
  94258. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94259. /**
  94260. * Targets the given mesh with its children and updates zoom level accordingly.
  94261. * @param mesh The mesh to target.
  94262. * @param radius Optional. If a cached radius position already exists, overrides default.
  94263. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94264. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94265. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94266. */
  94267. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94268. /**
  94269. * Targets the given meshes with their children and updates zoom level accordingly.
  94270. * @param meshes The mesh to target.
  94271. * @param radius Optional. If a cached radius position already exists, overrides default.
  94272. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94273. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94274. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94275. */
  94276. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94277. /**
  94278. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  94279. * @param minimumWorld Determines the smaller position of the bounding box extend
  94280. * @param maximumWorld Determines the bigger position of the bounding box extend
  94281. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94282. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94283. */
  94284. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94285. /**
  94286. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  94287. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  94288. * frustum width.
  94289. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  94290. * to fully enclose the mesh in the viewing frustum.
  94291. */
  94292. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  94293. /**
  94294. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  94295. * is automatically returned to its default position (expected to be above ground plane).
  94296. */
  94297. private _maintainCameraAboveGround;
  94298. /**
  94299. * Returns the frustum slope based on the canvas ratio and camera FOV
  94300. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  94301. */
  94302. private _getFrustumSlope;
  94303. /**
  94304. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  94305. */
  94306. private _clearAnimationLocks;
  94307. /**
  94308. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  94309. */
  94310. private _applyUserInteraction;
  94311. /**
  94312. * Stops and removes all animations that have been applied to the camera
  94313. */
  94314. stopAllAnimations(): void;
  94315. /**
  94316. * Gets a value indicating if the user is moving the camera
  94317. */
  94318. readonly isUserIsMoving: boolean;
  94319. /**
  94320. * The camera can move all the way towards the mesh.
  94321. */
  94322. static IgnoreBoundsSizeMode: number;
  94323. /**
  94324. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  94325. */
  94326. static FitFrustumSidesMode: number;
  94327. }
  94328. }
  94329. declare module BABYLON {
  94330. /**
  94331. * Base class for Camera Pointer Inputs.
  94332. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  94333. * for example usage.
  94334. */
  94335. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  94336. /**
  94337. * Defines the camera the input is attached to.
  94338. */
  94339. abstract camera: Camera;
  94340. /**
  94341. * Whether keyboard modifier keys are pressed at time of last mouse event.
  94342. */
  94343. protected _altKey: boolean;
  94344. protected _ctrlKey: boolean;
  94345. protected _metaKey: boolean;
  94346. protected _shiftKey: boolean;
  94347. /**
  94348. * Which mouse buttons were pressed at time of last mouse event.
  94349. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  94350. */
  94351. protected _buttonsPressed: number;
  94352. /**
  94353. * Defines the buttons associated with the input to handle camera move.
  94354. */
  94355. buttons: number[];
  94356. /**
  94357. * Attach the input controls to a specific dom element to get the input from.
  94358. * @param element Defines the element the controls should be listened from
  94359. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94360. */
  94361. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94362. /**
  94363. * Detach the current controls from the specified dom element.
  94364. * @param element Defines the element to stop listening the inputs from
  94365. */
  94366. detachControl(element: Nullable<HTMLElement>): void;
  94367. /**
  94368. * Gets the class name of the current input.
  94369. * @returns the class name
  94370. */
  94371. getClassName(): string;
  94372. /**
  94373. * Get the friendly name associated with the input class.
  94374. * @returns the input friendly name
  94375. */
  94376. getSimpleName(): string;
  94377. /**
  94378. * Called on pointer POINTERDOUBLETAP event.
  94379. * Override this method to provide functionality on POINTERDOUBLETAP event.
  94380. */
  94381. protected onDoubleTap(type: string): void;
  94382. /**
  94383. * Called on pointer POINTERMOVE event if only a single touch is active.
  94384. * Override this method to provide functionality.
  94385. */
  94386. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94387. /**
  94388. * Called on pointer POINTERMOVE event if multiple touches are active.
  94389. * Override this method to provide functionality.
  94390. */
  94391. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94392. /**
  94393. * Called on JS contextmenu event.
  94394. * Override this method to provide functionality.
  94395. */
  94396. protected onContextMenu(evt: PointerEvent): void;
  94397. /**
  94398. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94399. * press.
  94400. * Override this method to provide functionality.
  94401. */
  94402. protected onButtonDown(evt: PointerEvent): void;
  94403. /**
  94404. * Called each time a new POINTERUP event occurs. Ie, for each button
  94405. * release.
  94406. * Override this method to provide functionality.
  94407. */
  94408. protected onButtonUp(evt: PointerEvent): void;
  94409. /**
  94410. * Called when window becomes inactive.
  94411. * Override this method to provide functionality.
  94412. */
  94413. protected onLostFocus(): void;
  94414. private _pointerInput;
  94415. private _observer;
  94416. private _onLostFocus;
  94417. private pointA;
  94418. private pointB;
  94419. }
  94420. }
  94421. declare module BABYLON {
  94422. /**
  94423. * Manage the pointers inputs to control an arc rotate camera.
  94424. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94425. */
  94426. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  94427. /**
  94428. * Defines the camera the input is attached to.
  94429. */
  94430. camera: ArcRotateCamera;
  94431. /**
  94432. * Gets the class name of the current input.
  94433. * @returns the class name
  94434. */
  94435. getClassName(): string;
  94436. /**
  94437. * Defines the buttons associated with the input to handle camera move.
  94438. */
  94439. buttons: number[];
  94440. /**
  94441. * Defines the pointer angular sensibility along the X axis or how fast is
  94442. * the camera rotating.
  94443. */
  94444. angularSensibilityX: number;
  94445. /**
  94446. * Defines the pointer angular sensibility along the Y axis or how fast is
  94447. * the camera rotating.
  94448. */
  94449. angularSensibilityY: number;
  94450. /**
  94451. * Defines the pointer pinch precision or how fast is the camera zooming.
  94452. */
  94453. pinchPrecision: number;
  94454. /**
  94455. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  94456. * from 0.
  94457. * It defines the percentage of current camera.radius to use as delta when
  94458. * pinch zoom is used.
  94459. */
  94460. pinchDeltaPercentage: number;
  94461. /**
  94462. * Defines the pointer panning sensibility or how fast is the camera moving.
  94463. */
  94464. panningSensibility: number;
  94465. /**
  94466. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  94467. */
  94468. multiTouchPanning: boolean;
  94469. /**
  94470. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  94471. * zoom (pinch) through multitouch.
  94472. */
  94473. multiTouchPanAndZoom: boolean;
  94474. /**
  94475. * Revers pinch action direction.
  94476. */
  94477. pinchInwards: boolean;
  94478. private _isPanClick;
  94479. private _twoFingerActivityCount;
  94480. private _isPinching;
  94481. /**
  94482. * Called on pointer POINTERMOVE event if only a single touch is active.
  94483. */
  94484. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94485. /**
  94486. * Called on pointer POINTERDOUBLETAP event.
  94487. */
  94488. protected onDoubleTap(type: string): void;
  94489. /**
  94490. * Called on pointer POINTERMOVE event if multiple touches are active.
  94491. */
  94492. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94493. /**
  94494. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94495. * press.
  94496. */
  94497. protected onButtonDown(evt: PointerEvent): void;
  94498. /**
  94499. * Called each time a new POINTERUP event occurs. Ie, for each button
  94500. * release.
  94501. */
  94502. protected onButtonUp(evt: PointerEvent): void;
  94503. /**
  94504. * Called when window becomes inactive.
  94505. */
  94506. protected onLostFocus(): void;
  94507. }
  94508. }
  94509. declare module BABYLON {
  94510. /**
  94511. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  94512. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94513. */
  94514. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  94515. /**
  94516. * Defines the camera the input is attached to.
  94517. */
  94518. camera: ArcRotateCamera;
  94519. /**
  94520. * Defines the list of key codes associated with the up action (increase alpha)
  94521. */
  94522. keysUp: number[];
  94523. /**
  94524. * Defines the list of key codes associated with the down action (decrease alpha)
  94525. */
  94526. keysDown: number[];
  94527. /**
  94528. * Defines the list of key codes associated with the left action (increase beta)
  94529. */
  94530. keysLeft: number[];
  94531. /**
  94532. * Defines the list of key codes associated with the right action (decrease beta)
  94533. */
  94534. keysRight: number[];
  94535. /**
  94536. * Defines the list of key codes associated with the reset action.
  94537. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  94538. */
  94539. keysReset: number[];
  94540. /**
  94541. * Defines the panning sensibility of the inputs.
  94542. * (How fast is the camera paning)
  94543. */
  94544. panningSensibility: number;
  94545. /**
  94546. * Defines the zooming sensibility of the inputs.
  94547. * (How fast is the camera zooming)
  94548. */
  94549. zoomingSensibility: number;
  94550. /**
  94551. * Defines wether maintaining the alt key down switch the movement mode from
  94552. * orientation to zoom.
  94553. */
  94554. useAltToZoom: boolean;
  94555. /**
  94556. * Rotation speed of the camera
  94557. */
  94558. angularSpeed: number;
  94559. private _keys;
  94560. private _ctrlPressed;
  94561. private _altPressed;
  94562. private _onCanvasBlurObserver;
  94563. private _onKeyboardObserver;
  94564. private _engine;
  94565. private _scene;
  94566. /**
  94567. * Attach the input controls to a specific dom element to get the input from.
  94568. * @param element Defines the element the controls should be listened from
  94569. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94570. */
  94571. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94572. /**
  94573. * Detach the current controls from the specified dom element.
  94574. * @param element Defines the element to stop listening the inputs from
  94575. */
  94576. detachControl(element: Nullable<HTMLElement>): void;
  94577. /**
  94578. * Update the current camera state depending on the inputs that have been used this frame.
  94579. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94580. */
  94581. checkInputs(): void;
  94582. /**
  94583. * Gets the class name of the current intput.
  94584. * @returns the class name
  94585. */
  94586. getClassName(): string;
  94587. /**
  94588. * Get the friendly name associated with the input class.
  94589. * @returns the input friendly name
  94590. */
  94591. getSimpleName(): string;
  94592. }
  94593. }
  94594. declare module BABYLON {
  94595. /**
  94596. * Manage the mouse wheel inputs to control an arc rotate camera.
  94597. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94598. */
  94599. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  94600. /**
  94601. * Defines the camera the input is attached to.
  94602. */
  94603. camera: ArcRotateCamera;
  94604. /**
  94605. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94606. */
  94607. wheelPrecision: number;
  94608. /**
  94609. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  94610. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  94611. */
  94612. wheelDeltaPercentage: number;
  94613. private _wheel;
  94614. private _observer;
  94615. /**
  94616. * Attach the input controls to a specific dom element to get the input from.
  94617. * @param element Defines the element the controls should be listened from
  94618. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94619. */
  94620. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94621. /**
  94622. * Detach the current controls from the specified dom element.
  94623. * @param element Defines the element to stop listening the inputs from
  94624. */
  94625. detachControl(element: Nullable<HTMLElement>): void;
  94626. /**
  94627. * Gets the class name of the current intput.
  94628. * @returns the class name
  94629. */
  94630. getClassName(): string;
  94631. /**
  94632. * Get the friendly name associated with the input class.
  94633. * @returns the input friendly name
  94634. */
  94635. getSimpleName(): string;
  94636. }
  94637. }
  94638. declare module BABYLON {
  94639. /**
  94640. * Default Inputs manager for the ArcRotateCamera.
  94641. * It groups all the default supported inputs for ease of use.
  94642. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94643. */
  94644. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  94645. /**
  94646. * Instantiates a new ArcRotateCameraInputsManager.
  94647. * @param camera Defines the camera the inputs belong to
  94648. */
  94649. constructor(camera: ArcRotateCamera);
  94650. /**
  94651. * Add mouse wheel input support to the input manager.
  94652. * @returns the current input manager
  94653. */
  94654. addMouseWheel(): ArcRotateCameraInputsManager;
  94655. /**
  94656. * Add pointers input support to the input manager.
  94657. * @returns the current input manager
  94658. */
  94659. addPointers(): ArcRotateCameraInputsManager;
  94660. /**
  94661. * Add keyboard input support to the input manager.
  94662. * @returns the current input manager
  94663. */
  94664. addKeyboard(): ArcRotateCameraInputsManager;
  94665. }
  94666. }
  94667. declare module BABYLON {
  94668. /**
  94669. * This represents an orbital type of camera.
  94670. *
  94671. * 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.
  94672. * 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.
  94673. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  94674. */
  94675. export class ArcRotateCamera extends TargetCamera {
  94676. /**
  94677. * Defines the rotation angle of the camera along the longitudinal axis.
  94678. */
  94679. alpha: number;
  94680. /**
  94681. * Defines the rotation angle of the camera along the latitudinal axis.
  94682. */
  94683. beta: number;
  94684. /**
  94685. * Defines the radius of the camera from it s target point.
  94686. */
  94687. radius: number;
  94688. protected _target: Vector3;
  94689. protected _targetHost: Nullable<AbstractMesh>;
  94690. /**
  94691. * Defines the target point of the camera.
  94692. * The camera looks towards it form the radius distance.
  94693. */
  94694. target: Vector3;
  94695. /**
  94696. * Define the current local position of the camera in the scene
  94697. */
  94698. position: Vector3;
  94699. protected _upVector: Vector3;
  94700. protected _upToYMatrix: Matrix;
  94701. protected _YToUpMatrix: Matrix;
  94702. /**
  94703. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  94704. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  94705. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  94706. */
  94707. upVector: Vector3;
  94708. /**
  94709. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  94710. */
  94711. setMatUp(): void;
  94712. /**
  94713. * Current inertia value on the longitudinal axis.
  94714. * The bigger this number the longer it will take for the camera to stop.
  94715. */
  94716. inertialAlphaOffset: number;
  94717. /**
  94718. * Current inertia value on the latitudinal axis.
  94719. * The bigger this number the longer it will take for the camera to stop.
  94720. */
  94721. inertialBetaOffset: number;
  94722. /**
  94723. * Current inertia value on the radius axis.
  94724. * The bigger this number the longer it will take for the camera to stop.
  94725. */
  94726. inertialRadiusOffset: number;
  94727. /**
  94728. * Minimum allowed angle on the longitudinal axis.
  94729. * This can help limiting how the Camera is able to move in the scene.
  94730. */
  94731. lowerAlphaLimit: Nullable<number>;
  94732. /**
  94733. * Maximum allowed angle on the longitudinal axis.
  94734. * This can help limiting how the Camera is able to move in the scene.
  94735. */
  94736. upperAlphaLimit: Nullable<number>;
  94737. /**
  94738. * Minimum allowed angle on the latitudinal axis.
  94739. * This can help limiting how the Camera is able to move in the scene.
  94740. */
  94741. lowerBetaLimit: number;
  94742. /**
  94743. * Maximum allowed angle on the latitudinal axis.
  94744. * This can help limiting how the Camera is able to move in the scene.
  94745. */
  94746. upperBetaLimit: number;
  94747. /**
  94748. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  94749. * This can help limiting how the Camera is able to move in the scene.
  94750. */
  94751. lowerRadiusLimit: Nullable<number>;
  94752. /**
  94753. * Maximum allowed distance of the camera to the target (The camera can not get further).
  94754. * This can help limiting how the Camera is able to move in the scene.
  94755. */
  94756. upperRadiusLimit: Nullable<number>;
  94757. /**
  94758. * Defines the current inertia value used during panning of the camera along the X axis.
  94759. */
  94760. inertialPanningX: number;
  94761. /**
  94762. * Defines the current inertia value used during panning of the camera along the Y axis.
  94763. */
  94764. inertialPanningY: number;
  94765. /**
  94766. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  94767. * Basically if your fingers moves away from more than this distance you will be considered
  94768. * in pinch mode.
  94769. */
  94770. pinchToPanMaxDistance: number;
  94771. /**
  94772. * Defines the maximum distance the camera can pan.
  94773. * This could help keeping the cammera always in your scene.
  94774. */
  94775. panningDistanceLimit: Nullable<number>;
  94776. /**
  94777. * Defines the target of the camera before paning.
  94778. */
  94779. panningOriginTarget: Vector3;
  94780. /**
  94781. * Defines the value of the inertia used during panning.
  94782. * 0 would mean stop inertia and one would mean no decelleration at all.
  94783. */
  94784. panningInertia: number;
  94785. /**
  94786. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  94787. */
  94788. angularSensibilityX: number;
  94789. /**
  94790. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  94791. */
  94792. angularSensibilityY: number;
  94793. /**
  94794. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  94795. */
  94796. pinchPrecision: number;
  94797. /**
  94798. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  94799. * It will be used instead of pinchDeltaPrecision if different from 0.
  94800. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  94801. */
  94802. pinchDeltaPercentage: number;
  94803. /**
  94804. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  94805. */
  94806. panningSensibility: number;
  94807. /**
  94808. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  94809. */
  94810. keysUp: number[];
  94811. /**
  94812. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  94813. */
  94814. keysDown: number[];
  94815. /**
  94816. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  94817. */
  94818. keysLeft: number[];
  94819. /**
  94820. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  94821. */
  94822. keysRight: number[];
  94823. /**
  94824. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94825. */
  94826. wheelPrecision: number;
  94827. /**
  94828. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  94829. * It will be used instead of pinchDeltaPrecision if different from 0.
  94830. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  94831. */
  94832. wheelDeltaPercentage: number;
  94833. /**
  94834. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  94835. */
  94836. zoomOnFactor: number;
  94837. /**
  94838. * Defines a screen offset for the camera position.
  94839. */
  94840. targetScreenOffset: Vector2;
  94841. /**
  94842. * Allows the camera to be completely reversed.
  94843. * If false the camera can not arrive upside down.
  94844. */
  94845. allowUpsideDown: boolean;
  94846. /**
  94847. * Define if double tap/click is used to restore the previously saved state of the camera.
  94848. */
  94849. useInputToRestoreState: boolean;
  94850. /** @hidden */
  94851. _viewMatrix: Matrix;
  94852. /** @hidden */
  94853. _useCtrlForPanning: boolean;
  94854. /** @hidden */
  94855. _panningMouseButton: number;
  94856. /**
  94857. * Defines the input associated to the camera.
  94858. */
  94859. inputs: ArcRotateCameraInputsManager;
  94860. /** @hidden */
  94861. _reset: () => void;
  94862. /**
  94863. * Defines the allowed panning axis.
  94864. */
  94865. panningAxis: Vector3;
  94866. protected _localDirection: Vector3;
  94867. protected _transformedDirection: Vector3;
  94868. private _bouncingBehavior;
  94869. /**
  94870. * Gets the bouncing behavior of the camera if it has been enabled.
  94871. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94872. */
  94873. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  94874. /**
  94875. * Defines if the bouncing behavior of the camera is enabled on the camera.
  94876. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94877. */
  94878. useBouncingBehavior: boolean;
  94879. private _framingBehavior;
  94880. /**
  94881. * Gets the framing behavior of the camera if it has been enabled.
  94882. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94883. */
  94884. readonly framingBehavior: Nullable<FramingBehavior>;
  94885. /**
  94886. * Defines if the framing behavior of the camera is enabled on the camera.
  94887. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94888. */
  94889. useFramingBehavior: boolean;
  94890. private _autoRotationBehavior;
  94891. /**
  94892. * Gets the auto rotation behavior of the camera if it has been enabled.
  94893. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94894. */
  94895. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  94896. /**
  94897. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  94898. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94899. */
  94900. useAutoRotationBehavior: boolean;
  94901. /**
  94902. * Observable triggered when the mesh target has been changed on the camera.
  94903. */
  94904. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  94905. /**
  94906. * Event raised when the camera is colliding with a mesh.
  94907. */
  94908. onCollide: (collidedMesh: AbstractMesh) => void;
  94909. /**
  94910. * Defines whether the camera should check collision with the objects oh the scene.
  94911. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  94912. */
  94913. checkCollisions: boolean;
  94914. /**
  94915. * Defines the collision radius of the camera.
  94916. * This simulates a sphere around the camera.
  94917. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  94918. */
  94919. collisionRadius: Vector3;
  94920. protected _collider: Collider;
  94921. protected _previousPosition: Vector3;
  94922. protected _collisionVelocity: Vector3;
  94923. protected _newPosition: Vector3;
  94924. protected _previousAlpha: number;
  94925. protected _previousBeta: number;
  94926. protected _previousRadius: number;
  94927. protected _collisionTriggered: boolean;
  94928. protected _targetBoundingCenter: Nullable<Vector3>;
  94929. private _computationVector;
  94930. /**
  94931. * Instantiates a new ArcRotateCamera in a given scene
  94932. * @param name Defines the name of the camera
  94933. * @param alpha Defines the camera rotation along the logitudinal axis
  94934. * @param beta Defines the camera rotation along the latitudinal axis
  94935. * @param radius Defines the camera distance from its target
  94936. * @param target Defines the camera target
  94937. * @param scene Defines the scene the camera belongs to
  94938. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  94939. */
  94940. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94941. /** @hidden */
  94942. _initCache(): void;
  94943. /** @hidden */
  94944. _updateCache(ignoreParentClass?: boolean): void;
  94945. protected _getTargetPosition(): Vector3;
  94946. private _storedAlpha;
  94947. private _storedBeta;
  94948. private _storedRadius;
  94949. private _storedTarget;
  94950. /**
  94951. * Stores the current state of the camera (alpha, beta, radius and target)
  94952. * @returns the camera itself
  94953. */
  94954. storeState(): Camera;
  94955. /**
  94956. * @hidden
  94957. * Restored camera state. You must call storeState() first
  94958. */
  94959. _restoreStateValues(): boolean;
  94960. /** @hidden */
  94961. _isSynchronizedViewMatrix(): boolean;
  94962. /**
  94963. * Attached controls to the current camera.
  94964. * @param element Defines the element the controls should be listened from
  94965. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94966. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  94967. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  94968. */
  94969. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  94970. /**
  94971. * Detach the current controls from the camera.
  94972. * The camera will stop reacting to inputs.
  94973. * @param element Defines the element to stop listening the inputs from
  94974. */
  94975. detachControl(element: HTMLElement): void;
  94976. /** @hidden */
  94977. _checkInputs(): void;
  94978. protected _checkLimits(): void;
  94979. /**
  94980. * Rebuilds angles (alpha, beta) and radius from the give position and target
  94981. */
  94982. rebuildAnglesAndRadius(): void;
  94983. /**
  94984. * Use a position to define the current camera related information like aplha, beta and radius
  94985. * @param position Defines the position to set the camera at
  94986. */
  94987. setPosition(position: Vector3): void;
  94988. /**
  94989. * Defines the target the camera should look at.
  94990. * This will automatically adapt alpha beta and radius to fit within the new target.
  94991. * @param target Defines the new target as a Vector or a mesh
  94992. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  94993. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  94994. */
  94995. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  94996. /** @hidden */
  94997. _getViewMatrix(): Matrix;
  94998. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  94999. /**
  95000. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  95001. * @param meshes Defines the mesh to zoom on
  95002. * @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)
  95003. */
  95004. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  95005. /**
  95006. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  95007. * The target will be changed but the radius
  95008. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  95009. * @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)
  95010. */
  95011. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  95012. min: Vector3;
  95013. max: Vector3;
  95014. distance: number;
  95015. }, doNotUpdateMaxZ?: boolean): void;
  95016. /**
  95017. * @override
  95018. * Override Camera.createRigCamera
  95019. */
  95020. createRigCamera(name: string, cameraIndex: number): Camera;
  95021. /**
  95022. * @hidden
  95023. * @override
  95024. * Override Camera._updateRigCameras
  95025. */
  95026. _updateRigCameras(): void;
  95027. /**
  95028. * Destroy the camera and release the current resources hold by it.
  95029. */
  95030. dispose(): void;
  95031. /**
  95032. * Gets the current object class name.
  95033. * @return the class name
  95034. */
  95035. getClassName(): string;
  95036. }
  95037. }
  95038. declare module BABYLON {
  95039. /**
  95040. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  95041. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95042. */
  95043. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  95044. /**
  95045. * Gets the name of the behavior.
  95046. */
  95047. readonly name: string;
  95048. private _zoomStopsAnimation;
  95049. private _idleRotationSpeed;
  95050. private _idleRotationWaitTime;
  95051. private _idleRotationSpinupTime;
  95052. /**
  95053. * Sets the flag that indicates if user zooming should stop animation.
  95054. */
  95055. /**
  95056. * Gets the flag that indicates if user zooming should stop animation.
  95057. */
  95058. zoomStopsAnimation: boolean;
  95059. /**
  95060. * Sets the default speed at which the camera rotates around the model.
  95061. */
  95062. /**
  95063. * Gets the default speed at which the camera rotates around the model.
  95064. */
  95065. idleRotationSpeed: number;
  95066. /**
  95067. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  95068. */
  95069. /**
  95070. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  95071. */
  95072. idleRotationWaitTime: number;
  95073. /**
  95074. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  95075. */
  95076. /**
  95077. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  95078. */
  95079. idleRotationSpinupTime: number;
  95080. /**
  95081. * Gets a value indicating if the camera is currently rotating because of this behavior
  95082. */
  95083. readonly rotationInProgress: boolean;
  95084. private _onPrePointerObservableObserver;
  95085. private _onAfterCheckInputsObserver;
  95086. private _attachedCamera;
  95087. private _isPointerDown;
  95088. private _lastFrameTime;
  95089. private _lastInteractionTime;
  95090. private _cameraRotationSpeed;
  95091. /**
  95092. * Initializes the behavior.
  95093. */
  95094. init(): void;
  95095. /**
  95096. * Attaches the behavior to its arc rotate camera.
  95097. * @param camera Defines the camera to attach the behavior to
  95098. */
  95099. attach(camera: ArcRotateCamera): void;
  95100. /**
  95101. * Detaches the behavior from its current arc rotate camera.
  95102. */
  95103. detach(): void;
  95104. /**
  95105. * Returns true if user is scrolling.
  95106. * @return true if user is scrolling.
  95107. */
  95108. private _userIsZooming;
  95109. private _lastFrameRadius;
  95110. private _shouldAnimationStopForInteraction;
  95111. /**
  95112. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  95113. */
  95114. private _applyUserInteraction;
  95115. private _userIsMoving;
  95116. }
  95117. }
  95118. declare module BABYLON {
  95119. /**
  95120. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  95121. */
  95122. export class AttachToBoxBehavior implements Behavior<Mesh> {
  95123. private ui;
  95124. /**
  95125. * The name of the behavior
  95126. */
  95127. name: string;
  95128. /**
  95129. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  95130. */
  95131. distanceAwayFromFace: number;
  95132. /**
  95133. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  95134. */
  95135. distanceAwayFromBottomOfFace: number;
  95136. private _faceVectors;
  95137. private _target;
  95138. private _scene;
  95139. private _onRenderObserver;
  95140. private _tmpMatrix;
  95141. private _tmpVector;
  95142. /**
  95143. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  95144. * @param ui The transform node that should be attched to the mesh
  95145. */
  95146. constructor(ui: TransformNode);
  95147. /**
  95148. * Initializes the behavior
  95149. */
  95150. init(): void;
  95151. private _closestFace;
  95152. private _zeroVector;
  95153. private _lookAtTmpMatrix;
  95154. private _lookAtToRef;
  95155. /**
  95156. * Attaches the AttachToBoxBehavior to the passed in mesh
  95157. * @param target The mesh that the specified node will be attached to
  95158. */
  95159. attach(target: Mesh): void;
  95160. /**
  95161. * Detaches the behavior from the mesh
  95162. */
  95163. detach(): void;
  95164. }
  95165. }
  95166. declare module BABYLON {
  95167. /**
  95168. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  95169. */
  95170. export class FadeInOutBehavior implements Behavior<Mesh> {
  95171. /**
  95172. * Time in milliseconds to delay before fading in (Default: 0)
  95173. */
  95174. delay: number;
  95175. /**
  95176. * Time in milliseconds for the mesh to fade in (Default: 300)
  95177. */
  95178. fadeInTime: number;
  95179. private _millisecondsPerFrame;
  95180. private _hovered;
  95181. private _hoverValue;
  95182. private _ownerNode;
  95183. /**
  95184. * Instatiates the FadeInOutBehavior
  95185. */
  95186. constructor();
  95187. /**
  95188. * The name of the behavior
  95189. */
  95190. readonly name: string;
  95191. /**
  95192. * Initializes the behavior
  95193. */
  95194. init(): void;
  95195. /**
  95196. * Attaches the fade behavior on the passed in mesh
  95197. * @param ownerNode The mesh that will be faded in/out once attached
  95198. */
  95199. attach(ownerNode: Mesh): void;
  95200. /**
  95201. * Detaches the behavior from the mesh
  95202. */
  95203. detach(): void;
  95204. /**
  95205. * Triggers the mesh to begin fading in or out
  95206. * @param value if the object should fade in or out (true to fade in)
  95207. */
  95208. fadeIn(value: boolean): void;
  95209. private _update;
  95210. private _setAllVisibility;
  95211. }
  95212. }
  95213. declare module BABYLON {
  95214. /**
  95215. * Class containing a set of static utilities functions for managing Pivots
  95216. * @hidden
  95217. */
  95218. export class PivotTools {
  95219. private static _PivotCached;
  95220. private static _OldPivotPoint;
  95221. private static _PivotTranslation;
  95222. private static _PivotTmpVector;
  95223. /** @hidden */
  95224. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  95225. /** @hidden */
  95226. static _RestorePivotPoint(mesh: AbstractMesh): void;
  95227. }
  95228. }
  95229. declare module BABYLON {
  95230. /**
  95231. * Class containing static functions to help procedurally build meshes
  95232. */
  95233. export class PlaneBuilder {
  95234. /**
  95235. * Creates a plane mesh
  95236. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  95237. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  95238. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  95239. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95240. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  95241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95242. * @param name defines the name of the mesh
  95243. * @param options defines the options used to create the mesh
  95244. * @param scene defines the hosting scene
  95245. * @returns the plane mesh
  95246. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  95247. */
  95248. static CreatePlane(name: string, options: {
  95249. size?: number;
  95250. width?: number;
  95251. height?: number;
  95252. sideOrientation?: number;
  95253. frontUVs?: Vector4;
  95254. backUVs?: Vector4;
  95255. updatable?: boolean;
  95256. sourcePlane?: Plane;
  95257. }, scene?: Nullable<Scene>): Mesh;
  95258. }
  95259. }
  95260. declare module BABYLON {
  95261. /**
  95262. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  95263. */
  95264. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  95265. private static _AnyMouseID;
  95266. private _attachedNode;
  95267. private _dragPlane;
  95268. private _scene;
  95269. private _pointerObserver;
  95270. private _beforeRenderObserver;
  95271. private static _planeScene;
  95272. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  95273. /**
  95274. * 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)
  95275. */
  95276. maxDragAngle: number;
  95277. /**
  95278. * @hidden
  95279. */
  95280. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  95281. /**
  95282. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95283. */
  95284. currentDraggingPointerID: number;
  95285. /**
  95286. * The last position where the pointer hit the drag plane in world space
  95287. */
  95288. lastDragPosition: Vector3;
  95289. /**
  95290. * If the behavior is currently in a dragging state
  95291. */
  95292. dragging: boolean;
  95293. /**
  95294. * 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)
  95295. */
  95296. dragDeltaRatio: number;
  95297. /**
  95298. * If the drag plane orientation should be updated during the dragging (Default: true)
  95299. */
  95300. updateDragPlane: boolean;
  95301. private _debugMode;
  95302. private _moving;
  95303. /**
  95304. * Fires each time the attached mesh is dragged with the pointer
  95305. * * delta between last drag position and current drag position in world space
  95306. * * dragDistance along the drag axis
  95307. * * dragPlaneNormal normal of the current drag plane used during the drag
  95308. * * dragPlanePoint in world space where the drag intersects the drag plane
  95309. */
  95310. onDragObservable: Observable<{
  95311. delta: Vector3;
  95312. dragPlanePoint: Vector3;
  95313. dragPlaneNormal: Vector3;
  95314. dragDistance: number;
  95315. pointerId: number;
  95316. }>;
  95317. /**
  95318. * Fires each time a drag begins (eg. mouse down on mesh)
  95319. */
  95320. onDragStartObservable: Observable<{
  95321. dragPlanePoint: Vector3;
  95322. pointerId: number;
  95323. }>;
  95324. /**
  95325. * Fires each time a drag ends (eg. mouse release after drag)
  95326. */
  95327. onDragEndObservable: Observable<{
  95328. dragPlanePoint: Vector3;
  95329. pointerId: number;
  95330. }>;
  95331. /**
  95332. * If the attached mesh should be moved when dragged
  95333. */
  95334. moveAttached: boolean;
  95335. /**
  95336. * If the drag behavior will react to drag events (Default: true)
  95337. */
  95338. enabled: boolean;
  95339. /**
  95340. * If camera controls should be detached during the drag
  95341. */
  95342. detachCameraControls: boolean;
  95343. /**
  95344. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  95345. */
  95346. useObjectOrienationForDragging: boolean;
  95347. private _options;
  95348. /**
  95349. * Creates a pointer drag behavior that can be attached to a mesh
  95350. * @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)
  95351. */
  95352. constructor(options?: {
  95353. dragAxis?: Vector3;
  95354. dragPlaneNormal?: Vector3;
  95355. });
  95356. /**
  95357. * Predicate to determine if it is valid to move the object to a new position when it is moved
  95358. */
  95359. validateDrag: (targetPosition: Vector3) => boolean;
  95360. /**
  95361. * The name of the behavior
  95362. */
  95363. readonly name: string;
  95364. /**
  95365. * Initializes the behavior
  95366. */
  95367. init(): void;
  95368. private _tmpVector;
  95369. private _alternatePickedPoint;
  95370. private _worldDragAxis;
  95371. private _targetPosition;
  95372. private _attachedElement;
  95373. /**
  95374. * Attaches the drag behavior the passed in mesh
  95375. * @param ownerNode The mesh that will be dragged around once attached
  95376. */
  95377. attach(ownerNode: AbstractMesh): void;
  95378. /**
  95379. * Force relase the drag action by code.
  95380. */
  95381. releaseDrag(): void;
  95382. private _startDragRay;
  95383. private _lastPointerRay;
  95384. /**
  95385. * Simulates the start of a pointer drag event on the behavior
  95386. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  95387. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  95388. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  95389. */
  95390. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  95391. private _startDrag;
  95392. private _dragDelta;
  95393. private _moveDrag;
  95394. private _pickWithRayOnDragPlane;
  95395. private _pointA;
  95396. private _pointB;
  95397. private _pointC;
  95398. private _lineA;
  95399. private _lineB;
  95400. private _localAxis;
  95401. private _lookAt;
  95402. private _updateDragPlanePosition;
  95403. /**
  95404. * Detaches the behavior from the mesh
  95405. */
  95406. detach(): void;
  95407. }
  95408. }
  95409. declare module BABYLON {
  95410. /**
  95411. * A behavior that when attached to a mesh will allow the mesh to be scaled
  95412. */
  95413. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  95414. private _dragBehaviorA;
  95415. private _dragBehaviorB;
  95416. private _startDistance;
  95417. private _initialScale;
  95418. private _targetScale;
  95419. private _ownerNode;
  95420. private _sceneRenderObserver;
  95421. /**
  95422. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  95423. */
  95424. constructor();
  95425. /**
  95426. * The name of the behavior
  95427. */
  95428. readonly name: string;
  95429. /**
  95430. * Initializes the behavior
  95431. */
  95432. init(): void;
  95433. private _getCurrentDistance;
  95434. /**
  95435. * Attaches the scale behavior the passed in mesh
  95436. * @param ownerNode The mesh that will be scaled around once attached
  95437. */
  95438. attach(ownerNode: Mesh): void;
  95439. /**
  95440. * Detaches the behavior from the mesh
  95441. */
  95442. detach(): void;
  95443. }
  95444. }
  95445. declare module BABYLON {
  95446. /**
  95447. * 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
  95448. */
  95449. export class SixDofDragBehavior implements Behavior<Mesh> {
  95450. private static _virtualScene;
  95451. private _ownerNode;
  95452. private _sceneRenderObserver;
  95453. private _scene;
  95454. private _targetPosition;
  95455. private _virtualOriginMesh;
  95456. private _virtualDragMesh;
  95457. private _pointerObserver;
  95458. private _moving;
  95459. private _startingOrientation;
  95460. /**
  95461. * 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)
  95462. */
  95463. private zDragFactor;
  95464. /**
  95465. * If the object should rotate to face the drag origin
  95466. */
  95467. rotateDraggedObject: boolean;
  95468. /**
  95469. * If the behavior is currently in a dragging state
  95470. */
  95471. dragging: boolean;
  95472. /**
  95473. * 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)
  95474. */
  95475. dragDeltaRatio: number;
  95476. /**
  95477. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95478. */
  95479. currentDraggingPointerID: number;
  95480. /**
  95481. * If camera controls should be detached during the drag
  95482. */
  95483. detachCameraControls: boolean;
  95484. /**
  95485. * Fires each time a drag starts
  95486. */
  95487. onDragStartObservable: Observable<{}>;
  95488. /**
  95489. * Fires each time a drag ends (eg. mouse release after drag)
  95490. */
  95491. onDragEndObservable: Observable<{}>;
  95492. /**
  95493. * 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
  95494. */
  95495. constructor();
  95496. /**
  95497. * The name of the behavior
  95498. */
  95499. readonly name: string;
  95500. /**
  95501. * Initializes the behavior
  95502. */
  95503. init(): void;
  95504. /**
  95505. * Attaches the scale behavior the passed in mesh
  95506. * @param ownerNode The mesh that will be scaled around once attached
  95507. */
  95508. attach(ownerNode: Mesh): void;
  95509. /**
  95510. * Detaches the behavior from the mesh
  95511. */
  95512. detach(): void;
  95513. }
  95514. }
  95515. declare module BABYLON {
  95516. /**
  95517. * Class used to apply inverse kinematics to bones
  95518. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  95519. */
  95520. export class BoneIKController {
  95521. private static _tmpVecs;
  95522. private static _tmpQuat;
  95523. private static _tmpMats;
  95524. /**
  95525. * Gets or sets the target mesh
  95526. */
  95527. targetMesh: AbstractMesh;
  95528. /** Gets or sets the mesh used as pole */
  95529. poleTargetMesh: AbstractMesh;
  95530. /**
  95531. * Gets or sets the bone used as pole
  95532. */
  95533. poleTargetBone: Nullable<Bone>;
  95534. /**
  95535. * Gets or sets the target position
  95536. */
  95537. targetPosition: Vector3;
  95538. /**
  95539. * Gets or sets the pole target position
  95540. */
  95541. poleTargetPosition: Vector3;
  95542. /**
  95543. * Gets or sets the pole target local offset
  95544. */
  95545. poleTargetLocalOffset: Vector3;
  95546. /**
  95547. * Gets or sets the pole angle
  95548. */
  95549. poleAngle: number;
  95550. /**
  95551. * Gets or sets the mesh associated with the controller
  95552. */
  95553. mesh: AbstractMesh;
  95554. /**
  95555. * 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)
  95556. */
  95557. slerpAmount: number;
  95558. private _bone1Quat;
  95559. private _bone1Mat;
  95560. private _bone2Ang;
  95561. private _bone1;
  95562. private _bone2;
  95563. private _bone1Length;
  95564. private _bone2Length;
  95565. private _maxAngle;
  95566. private _maxReach;
  95567. private _rightHandedSystem;
  95568. private _bendAxis;
  95569. private _slerping;
  95570. private _adjustRoll;
  95571. /**
  95572. * Gets or sets maximum allowed angle
  95573. */
  95574. maxAngle: number;
  95575. /**
  95576. * Creates a new BoneIKController
  95577. * @param mesh defines the mesh to control
  95578. * @param bone defines the bone to control
  95579. * @param options defines options to set up the controller
  95580. */
  95581. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  95582. targetMesh?: AbstractMesh;
  95583. poleTargetMesh?: AbstractMesh;
  95584. poleTargetBone?: Bone;
  95585. poleTargetLocalOffset?: Vector3;
  95586. poleAngle?: number;
  95587. bendAxis?: Vector3;
  95588. maxAngle?: number;
  95589. slerpAmount?: number;
  95590. });
  95591. private _setMaxAngle;
  95592. /**
  95593. * Force the controller to update the bones
  95594. */
  95595. update(): void;
  95596. }
  95597. }
  95598. declare module BABYLON {
  95599. /**
  95600. * Class used to make a bone look toward a point in space
  95601. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  95602. */
  95603. export class BoneLookController {
  95604. private static _tmpVecs;
  95605. private static _tmpQuat;
  95606. private static _tmpMats;
  95607. /**
  95608. * The target Vector3 that the bone will look at
  95609. */
  95610. target: Vector3;
  95611. /**
  95612. * The mesh that the bone is attached to
  95613. */
  95614. mesh: AbstractMesh;
  95615. /**
  95616. * The bone that will be looking to the target
  95617. */
  95618. bone: Bone;
  95619. /**
  95620. * The up axis of the coordinate system that is used when the bone is rotated
  95621. */
  95622. upAxis: Vector3;
  95623. /**
  95624. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  95625. */
  95626. upAxisSpace: Space;
  95627. /**
  95628. * Used to make an adjustment to the yaw of the bone
  95629. */
  95630. adjustYaw: number;
  95631. /**
  95632. * Used to make an adjustment to the pitch of the bone
  95633. */
  95634. adjustPitch: number;
  95635. /**
  95636. * Used to make an adjustment to the roll of the bone
  95637. */
  95638. adjustRoll: number;
  95639. /**
  95640. * 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)
  95641. */
  95642. slerpAmount: number;
  95643. private _minYaw;
  95644. private _maxYaw;
  95645. private _minPitch;
  95646. private _maxPitch;
  95647. private _minYawSin;
  95648. private _minYawCos;
  95649. private _maxYawSin;
  95650. private _maxYawCos;
  95651. private _midYawConstraint;
  95652. private _minPitchTan;
  95653. private _maxPitchTan;
  95654. private _boneQuat;
  95655. private _slerping;
  95656. private _transformYawPitch;
  95657. private _transformYawPitchInv;
  95658. private _firstFrameSkipped;
  95659. private _yawRange;
  95660. private _fowardAxis;
  95661. /**
  95662. * Gets or sets the minimum yaw angle that the bone can look to
  95663. */
  95664. minYaw: number;
  95665. /**
  95666. * Gets or sets the maximum yaw angle that the bone can look to
  95667. */
  95668. maxYaw: number;
  95669. /**
  95670. * Gets or sets the minimum pitch angle that the bone can look to
  95671. */
  95672. minPitch: number;
  95673. /**
  95674. * Gets or sets the maximum pitch angle that the bone can look to
  95675. */
  95676. maxPitch: number;
  95677. /**
  95678. * Create a BoneLookController
  95679. * @param mesh the mesh that the bone belongs to
  95680. * @param bone the bone that will be looking to the target
  95681. * @param target the target Vector3 to look at
  95682. * @param options optional settings:
  95683. * * maxYaw: the maximum angle the bone will yaw to
  95684. * * minYaw: the minimum angle the bone will yaw to
  95685. * * maxPitch: the maximum angle the bone will pitch to
  95686. * * minPitch: the minimum angle the bone will yaw to
  95687. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  95688. * * upAxis: the up axis of the coordinate system
  95689. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  95690. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  95691. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  95692. * * adjustYaw: used to make an adjustment to the yaw of the bone
  95693. * * adjustPitch: used to make an adjustment to the pitch of the bone
  95694. * * adjustRoll: used to make an adjustment to the roll of the bone
  95695. **/
  95696. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  95697. maxYaw?: number;
  95698. minYaw?: number;
  95699. maxPitch?: number;
  95700. minPitch?: number;
  95701. slerpAmount?: number;
  95702. upAxis?: Vector3;
  95703. upAxisSpace?: Space;
  95704. yawAxis?: Vector3;
  95705. pitchAxis?: Vector3;
  95706. adjustYaw?: number;
  95707. adjustPitch?: number;
  95708. adjustRoll?: number;
  95709. });
  95710. /**
  95711. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  95712. */
  95713. update(): void;
  95714. private _getAngleDiff;
  95715. private _getAngleBetween;
  95716. private _isAngleBetween;
  95717. }
  95718. }
  95719. declare module BABYLON {
  95720. /**
  95721. * Manage the gamepad inputs to control an arc rotate camera.
  95722. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95723. */
  95724. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  95725. /**
  95726. * Defines the camera the input is attached to.
  95727. */
  95728. camera: ArcRotateCamera;
  95729. /**
  95730. * Defines the gamepad the input is gathering event from.
  95731. */
  95732. gamepad: Nullable<Gamepad>;
  95733. /**
  95734. * Defines the gamepad rotation sensiblity.
  95735. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  95736. */
  95737. gamepadRotationSensibility: number;
  95738. /**
  95739. * Defines the gamepad move sensiblity.
  95740. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  95741. */
  95742. gamepadMoveSensibility: number;
  95743. private _onGamepadConnectedObserver;
  95744. private _onGamepadDisconnectedObserver;
  95745. /**
  95746. * Attach the input controls to a specific dom element to get the input from.
  95747. * @param element Defines the element the controls should be listened from
  95748. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95749. */
  95750. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95751. /**
  95752. * Detach the current controls from the specified dom element.
  95753. * @param element Defines the element to stop listening the inputs from
  95754. */
  95755. detachControl(element: Nullable<HTMLElement>): void;
  95756. /**
  95757. * Update the current camera state depending on the inputs that have been used this frame.
  95758. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95759. */
  95760. checkInputs(): void;
  95761. /**
  95762. * Gets the class name of the current intput.
  95763. * @returns the class name
  95764. */
  95765. getClassName(): string;
  95766. /**
  95767. * Get the friendly name associated with the input class.
  95768. * @returns the input friendly name
  95769. */
  95770. getSimpleName(): string;
  95771. }
  95772. }
  95773. declare module BABYLON {
  95774. interface ArcRotateCameraInputsManager {
  95775. /**
  95776. * Add orientation input support to the input manager.
  95777. * @returns the current input manager
  95778. */
  95779. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  95780. }
  95781. /**
  95782. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  95783. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95784. */
  95785. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  95786. /**
  95787. * Defines the camera the input is attached to.
  95788. */
  95789. camera: ArcRotateCamera;
  95790. /**
  95791. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  95792. */
  95793. alphaCorrection: number;
  95794. /**
  95795. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  95796. */
  95797. gammaCorrection: number;
  95798. private _alpha;
  95799. private _gamma;
  95800. private _dirty;
  95801. private _deviceOrientationHandler;
  95802. /**
  95803. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  95804. */
  95805. constructor();
  95806. /**
  95807. * Attach the input controls to a specific dom element to get the input from.
  95808. * @param element Defines the element the controls should be listened from
  95809. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95810. */
  95811. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95812. /** @hidden */
  95813. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  95814. /**
  95815. * Update the current camera state depending on the inputs that have been used this frame.
  95816. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95817. */
  95818. checkInputs(): void;
  95819. /**
  95820. * Detach the current controls from the specified dom element.
  95821. * @param element Defines the element to stop listening the inputs from
  95822. */
  95823. detachControl(element: Nullable<HTMLElement>): void;
  95824. /**
  95825. * Gets the class name of the current intput.
  95826. * @returns the class name
  95827. */
  95828. getClassName(): string;
  95829. /**
  95830. * Get the friendly name associated with the input class.
  95831. * @returns the input friendly name
  95832. */
  95833. getSimpleName(): string;
  95834. }
  95835. }
  95836. declare module BABYLON {
  95837. /**
  95838. * Listen to mouse events to control the camera.
  95839. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95840. */
  95841. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  95842. /**
  95843. * Defines the camera the input is attached to.
  95844. */
  95845. camera: FlyCamera;
  95846. /**
  95847. * Defines if touch is enabled. (Default is true.)
  95848. */
  95849. touchEnabled: boolean;
  95850. /**
  95851. * Defines the buttons associated with the input to handle camera rotation.
  95852. */
  95853. buttons: number[];
  95854. /**
  95855. * Assign buttons for Yaw control.
  95856. */
  95857. buttonsYaw: number[];
  95858. /**
  95859. * Assign buttons for Pitch control.
  95860. */
  95861. buttonsPitch: number[];
  95862. /**
  95863. * Assign buttons for Roll control.
  95864. */
  95865. buttonsRoll: number[];
  95866. /**
  95867. * Detect if any button is being pressed while mouse is moved.
  95868. * -1 = Mouse locked.
  95869. * 0 = Left button.
  95870. * 1 = Middle Button.
  95871. * 2 = Right Button.
  95872. */
  95873. activeButton: number;
  95874. /**
  95875. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  95876. * Higher values reduce its sensitivity.
  95877. */
  95878. angularSensibility: number;
  95879. private _mousemoveCallback;
  95880. private _observer;
  95881. private _rollObserver;
  95882. private previousPosition;
  95883. private noPreventDefault;
  95884. private element;
  95885. /**
  95886. * Listen to mouse events to control the camera.
  95887. * @param touchEnabled Define if touch is enabled. (Default is true.)
  95888. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95889. */
  95890. constructor(touchEnabled?: boolean);
  95891. /**
  95892. * Attach the mouse control to the HTML DOM element.
  95893. * @param element Defines the element that listens to the input events.
  95894. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  95895. */
  95896. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95897. /**
  95898. * Detach the current controls from the specified dom element.
  95899. * @param element Defines the element to stop listening the inputs from
  95900. */
  95901. detachControl(element: Nullable<HTMLElement>): void;
  95902. /**
  95903. * Gets the class name of the current input.
  95904. * @returns the class name.
  95905. */
  95906. getClassName(): string;
  95907. /**
  95908. * Get the friendly name associated with the input class.
  95909. * @returns the input's friendly name.
  95910. */
  95911. getSimpleName(): string;
  95912. private _pointerInput;
  95913. private _onMouseMove;
  95914. /**
  95915. * Rotate camera by mouse offset.
  95916. */
  95917. private rotateCamera;
  95918. }
  95919. }
  95920. declare module BABYLON {
  95921. /**
  95922. * Default Inputs manager for the FlyCamera.
  95923. * It groups all the default supported inputs for ease of use.
  95924. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95925. */
  95926. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  95927. /**
  95928. * Instantiates a new FlyCameraInputsManager.
  95929. * @param camera Defines the camera the inputs belong to.
  95930. */
  95931. constructor(camera: FlyCamera);
  95932. /**
  95933. * Add keyboard input support to the input manager.
  95934. * @returns the new FlyCameraKeyboardMoveInput().
  95935. */
  95936. addKeyboard(): FlyCameraInputsManager;
  95937. /**
  95938. * Add mouse input support to the input manager.
  95939. * @param touchEnabled Enable touch screen support.
  95940. * @returns the new FlyCameraMouseInput().
  95941. */
  95942. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  95943. }
  95944. }
  95945. declare module BABYLON {
  95946. /**
  95947. * This is a flying camera, designed for 3D movement and rotation in all directions,
  95948. * such as in a 3D Space Shooter or a Flight Simulator.
  95949. */
  95950. export class FlyCamera extends TargetCamera {
  95951. /**
  95952. * Define the collision ellipsoid of the camera.
  95953. * This is helpful for simulating a camera body, like a player's body.
  95954. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95955. */
  95956. ellipsoid: Vector3;
  95957. /**
  95958. * Define an offset for the position of the ellipsoid around the camera.
  95959. * This can be helpful if the camera is attached away from the player's body center,
  95960. * such as at its head.
  95961. */
  95962. ellipsoidOffset: Vector3;
  95963. /**
  95964. * Enable or disable collisions of the camera with the rest of the scene objects.
  95965. */
  95966. checkCollisions: boolean;
  95967. /**
  95968. * Enable or disable gravity on the camera.
  95969. */
  95970. applyGravity: boolean;
  95971. /**
  95972. * Define the current direction the camera is moving to.
  95973. */
  95974. cameraDirection: Vector3;
  95975. /**
  95976. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  95977. * This overrides and empties cameraRotation.
  95978. */
  95979. rotationQuaternion: Quaternion;
  95980. /**
  95981. * Track Roll to maintain the wanted Rolling when looking around.
  95982. */
  95983. _trackRoll: number;
  95984. /**
  95985. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  95986. */
  95987. rollCorrect: number;
  95988. /**
  95989. * Mimic a banked turn, Rolling the camera when Yawing.
  95990. * It's recommended to use rollCorrect = 10 for faster banking correction.
  95991. */
  95992. bankedTurn: boolean;
  95993. /**
  95994. * Limit in radians for how much Roll banking will add. (Default: 90°)
  95995. */
  95996. bankedTurnLimit: number;
  95997. /**
  95998. * Value of 0 disables the banked Roll.
  95999. * Value of 1 is equal to the Yaw angle in radians.
  96000. */
  96001. bankedTurnMultiplier: number;
  96002. /**
  96003. * The inputs manager loads all the input sources, such as keyboard and mouse.
  96004. */
  96005. inputs: FlyCameraInputsManager;
  96006. /**
  96007. * Gets the input sensibility for mouse input.
  96008. * Higher values reduce sensitivity.
  96009. */
  96010. /**
  96011. * Sets the input sensibility for a mouse input.
  96012. * Higher values reduce sensitivity.
  96013. */
  96014. angularSensibility: number;
  96015. /**
  96016. * Get the keys for camera movement forward.
  96017. */
  96018. /**
  96019. * Set the keys for camera movement forward.
  96020. */
  96021. keysForward: number[];
  96022. /**
  96023. * Get the keys for camera movement backward.
  96024. */
  96025. keysBackward: number[];
  96026. /**
  96027. * Get the keys for camera movement up.
  96028. */
  96029. /**
  96030. * Set the keys for camera movement up.
  96031. */
  96032. keysUp: number[];
  96033. /**
  96034. * Get the keys for camera movement down.
  96035. */
  96036. /**
  96037. * Set the keys for camera movement down.
  96038. */
  96039. keysDown: number[];
  96040. /**
  96041. * Get the keys for camera movement left.
  96042. */
  96043. /**
  96044. * Set the keys for camera movement left.
  96045. */
  96046. keysLeft: number[];
  96047. /**
  96048. * Set the keys for camera movement right.
  96049. */
  96050. /**
  96051. * Set the keys for camera movement right.
  96052. */
  96053. keysRight: number[];
  96054. /**
  96055. * Event raised when the camera collides with a mesh in the scene.
  96056. */
  96057. onCollide: (collidedMesh: AbstractMesh) => void;
  96058. private _collider;
  96059. private _needMoveForGravity;
  96060. private _oldPosition;
  96061. private _diffPosition;
  96062. private _newPosition;
  96063. /** @hidden */
  96064. _localDirection: Vector3;
  96065. /** @hidden */
  96066. _transformedDirection: Vector3;
  96067. /**
  96068. * Instantiates a FlyCamera.
  96069. * This is a flying camera, designed for 3D movement and rotation in all directions,
  96070. * such as in a 3D Space Shooter or a Flight Simulator.
  96071. * @param name Define the name of the camera in the scene.
  96072. * @param position Define the starting position of the camera in the scene.
  96073. * @param scene Define the scene the camera belongs to.
  96074. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  96075. */
  96076. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96077. /**
  96078. * Attach a control to the HTML DOM element.
  96079. * @param element Defines the element that listens to the input events.
  96080. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  96081. */
  96082. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96083. /**
  96084. * Detach a control from the HTML DOM element.
  96085. * The camera will stop reacting to that input.
  96086. * @param element Defines the element that listens to the input events.
  96087. */
  96088. detachControl(element: HTMLElement): void;
  96089. private _collisionMask;
  96090. /**
  96091. * Get the mask that the camera ignores in collision events.
  96092. */
  96093. /**
  96094. * Set the mask that the camera ignores in collision events.
  96095. */
  96096. collisionMask: number;
  96097. /** @hidden */
  96098. _collideWithWorld(displacement: Vector3): void;
  96099. /** @hidden */
  96100. private _onCollisionPositionChange;
  96101. /** @hidden */
  96102. _checkInputs(): void;
  96103. /** @hidden */
  96104. _decideIfNeedsToMove(): boolean;
  96105. /** @hidden */
  96106. _updatePosition(): void;
  96107. /**
  96108. * Restore the Roll to its target value at the rate specified.
  96109. * @param rate - Higher means slower restoring.
  96110. * @hidden
  96111. */
  96112. restoreRoll(rate: number): void;
  96113. /**
  96114. * Destroy the camera and release the current resources held by it.
  96115. */
  96116. dispose(): void;
  96117. /**
  96118. * Get the current object class name.
  96119. * @returns the class name.
  96120. */
  96121. getClassName(): string;
  96122. }
  96123. }
  96124. declare module BABYLON {
  96125. /**
  96126. * Listen to keyboard events to control the camera.
  96127. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96128. */
  96129. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  96130. /**
  96131. * Defines the camera the input is attached to.
  96132. */
  96133. camera: FlyCamera;
  96134. /**
  96135. * The list of keyboard keys used to control the forward move of the camera.
  96136. */
  96137. keysForward: number[];
  96138. /**
  96139. * The list of keyboard keys used to control the backward move of the camera.
  96140. */
  96141. keysBackward: number[];
  96142. /**
  96143. * The list of keyboard keys used to control the forward move of the camera.
  96144. */
  96145. keysUp: number[];
  96146. /**
  96147. * The list of keyboard keys used to control the backward move of the camera.
  96148. */
  96149. keysDown: number[];
  96150. /**
  96151. * The list of keyboard keys used to control the right strafe move of the camera.
  96152. */
  96153. keysRight: number[];
  96154. /**
  96155. * The list of keyboard keys used to control the left strafe move of the camera.
  96156. */
  96157. keysLeft: number[];
  96158. private _keys;
  96159. private _onCanvasBlurObserver;
  96160. private _onKeyboardObserver;
  96161. private _engine;
  96162. private _scene;
  96163. /**
  96164. * Attach the input controls to a specific dom element to get the input from.
  96165. * @param element Defines the element the controls should be listened from
  96166. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96167. */
  96168. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96169. /**
  96170. * Detach the current controls from the specified dom element.
  96171. * @param element Defines the element to stop listening the inputs from
  96172. */
  96173. detachControl(element: Nullable<HTMLElement>): void;
  96174. /**
  96175. * Gets the class name of the current intput.
  96176. * @returns the class name
  96177. */
  96178. getClassName(): string;
  96179. /** @hidden */
  96180. _onLostFocus(e: FocusEvent): void;
  96181. /**
  96182. * Get the friendly name associated with the input class.
  96183. * @returns the input friendly name
  96184. */
  96185. getSimpleName(): string;
  96186. /**
  96187. * Update the current camera state depending on the inputs that have been used this frame.
  96188. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96189. */
  96190. checkInputs(): void;
  96191. }
  96192. }
  96193. declare module BABYLON {
  96194. /**
  96195. * Manage the mouse wheel inputs to control a follow camera.
  96196. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96197. */
  96198. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  96199. /**
  96200. * Defines the camera the input is attached to.
  96201. */
  96202. camera: FollowCamera;
  96203. /**
  96204. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  96205. */
  96206. axisControlRadius: boolean;
  96207. /**
  96208. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  96209. */
  96210. axisControlHeight: boolean;
  96211. /**
  96212. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  96213. */
  96214. axisControlRotation: boolean;
  96215. /**
  96216. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  96217. * relation to mouseWheel events.
  96218. */
  96219. wheelPrecision: number;
  96220. /**
  96221. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  96222. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  96223. */
  96224. wheelDeltaPercentage: number;
  96225. private _wheel;
  96226. private _observer;
  96227. /**
  96228. * Attach the input controls to a specific dom element to get the input from.
  96229. * @param element Defines the element the controls should be listened from
  96230. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96231. */
  96232. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96233. /**
  96234. * Detach the current controls from the specified dom element.
  96235. * @param element Defines the element to stop listening the inputs from
  96236. */
  96237. detachControl(element: Nullable<HTMLElement>): void;
  96238. /**
  96239. * Gets the class name of the current intput.
  96240. * @returns the class name
  96241. */
  96242. getClassName(): string;
  96243. /**
  96244. * Get the friendly name associated with the input class.
  96245. * @returns the input friendly name
  96246. */
  96247. getSimpleName(): string;
  96248. }
  96249. }
  96250. declare module BABYLON {
  96251. /**
  96252. * Manage the pointers inputs to control an follow camera.
  96253. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96254. */
  96255. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  96256. /**
  96257. * Defines the camera the input is attached to.
  96258. */
  96259. camera: FollowCamera;
  96260. /**
  96261. * Gets the class name of the current input.
  96262. * @returns the class name
  96263. */
  96264. getClassName(): string;
  96265. /**
  96266. * Defines the pointer angular sensibility along the X axis or how fast is
  96267. * the camera rotating.
  96268. * A negative number will reverse the axis direction.
  96269. */
  96270. angularSensibilityX: number;
  96271. /**
  96272. * Defines the pointer angular sensibility along the Y axis or how fast is
  96273. * the camera rotating.
  96274. * A negative number will reverse the axis direction.
  96275. */
  96276. angularSensibilityY: number;
  96277. /**
  96278. * Defines the pointer pinch precision or how fast is the camera zooming.
  96279. * A negative number will reverse the axis direction.
  96280. */
  96281. pinchPrecision: number;
  96282. /**
  96283. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  96284. * from 0.
  96285. * It defines the percentage of current camera.radius to use as delta when
  96286. * pinch zoom is used.
  96287. */
  96288. pinchDeltaPercentage: number;
  96289. /**
  96290. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  96291. */
  96292. axisXControlRadius: boolean;
  96293. /**
  96294. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  96295. */
  96296. axisXControlHeight: boolean;
  96297. /**
  96298. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  96299. */
  96300. axisXControlRotation: boolean;
  96301. /**
  96302. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  96303. */
  96304. axisYControlRadius: boolean;
  96305. /**
  96306. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  96307. */
  96308. axisYControlHeight: boolean;
  96309. /**
  96310. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  96311. */
  96312. axisYControlRotation: boolean;
  96313. /**
  96314. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  96315. */
  96316. axisPinchControlRadius: boolean;
  96317. /**
  96318. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  96319. */
  96320. axisPinchControlHeight: boolean;
  96321. /**
  96322. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  96323. */
  96324. axisPinchControlRotation: boolean;
  96325. /**
  96326. * Log error messages if basic misconfiguration has occurred.
  96327. */
  96328. warningEnable: boolean;
  96329. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  96330. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  96331. private _warningCounter;
  96332. private _warning;
  96333. }
  96334. }
  96335. declare module BABYLON {
  96336. /**
  96337. * Default Inputs manager for the FollowCamera.
  96338. * It groups all the default supported inputs for ease of use.
  96339. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96340. */
  96341. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  96342. /**
  96343. * Instantiates a new FollowCameraInputsManager.
  96344. * @param camera Defines the camera the inputs belong to
  96345. */
  96346. constructor(camera: FollowCamera);
  96347. /**
  96348. * Add keyboard input support to the input manager.
  96349. * @returns the current input manager
  96350. */
  96351. addKeyboard(): FollowCameraInputsManager;
  96352. /**
  96353. * Add mouse wheel input support to the input manager.
  96354. * @returns the current input manager
  96355. */
  96356. addMouseWheel(): FollowCameraInputsManager;
  96357. /**
  96358. * Add pointers input support to the input manager.
  96359. * @returns the current input manager
  96360. */
  96361. addPointers(): FollowCameraInputsManager;
  96362. /**
  96363. * Add orientation input support to the input manager.
  96364. * @returns the current input manager
  96365. */
  96366. addVRDeviceOrientation(): FollowCameraInputsManager;
  96367. }
  96368. }
  96369. declare module BABYLON {
  96370. /**
  96371. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  96372. * an arc rotate version arcFollowCamera are available.
  96373. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96374. */
  96375. export class FollowCamera extends TargetCamera {
  96376. /**
  96377. * Distance the follow camera should follow an object at
  96378. */
  96379. radius: number;
  96380. /**
  96381. * Minimum allowed distance of the camera to the axis of rotation
  96382. * (The camera can not get closer).
  96383. * This can help limiting how the Camera is able to move in the scene.
  96384. */
  96385. lowerRadiusLimit: Nullable<number>;
  96386. /**
  96387. * Maximum allowed distance of the camera to the axis of rotation
  96388. * (The camera can not get further).
  96389. * This can help limiting how the Camera is able to move in the scene.
  96390. */
  96391. upperRadiusLimit: Nullable<number>;
  96392. /**
  96393. * Define a rotation offset between the camera and the object it follows
  96394. */
  96395. rotationOffset: number;
  96396. /**
  96397. * Minimum allowed angle to camera position relative to target object.
  96398. * This can help limiting how the Camera is able to move in the scene.
  96399. */
  96400. lowerRotationOffsetLimit: Nullable<number>;
  96401. /**
  96402. * Maximum allowed angle to camera position relative to target object.
  96403. * This can help limiting how the Camera is able to move in the scene.
  96404. */
  96405. upperRotationOffsetLimit: Nullable<number>;
  96406. /**
  96407. * Define a height offset between the camera and the object it follows.
  96408. * It can help following an object from the top (like a car chaing a plane)
  96409. */
  96410. heightOffset: number;
  96411. /**
  96412. * Minimum allowed height of camera position relative to target object.
  96413. * This can help limiting how the Camera is able to move in the scene.
  96414. */
  96415. lowerHeightOffsetLimit: Nullable<number>;
  96416. /**
  96417. * Maximum allowed height of camera position relative to target object.
  96418. * This can help limiting how the Camera is able to move in the scene.
  96419. */
  96420. upperHeightOffsetLimit: Nullable<number>;
  96421. /**
  96422. * Define how fast the camera can accelerate to follow it s target.
  96423. */
  96424. cameraAcceleration: number;
  96425. /**
  96426. * Define the speed limit of the camera following an object.
  96427. */
  96428. maxCameraSpeed: number;
  96429. /**
  96430. * Define the target of the camera.
  96431. */
  96432. lockedTarget: Nullable<AbstractMesh>;
  96433. /**
  96434. * Defines the input associated with the camera.
  96435. */
  96436. inputs: FollowCameraInputsManager;
  96437. /**
  96438. * Instantiates the follow camera.
  96439. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96440. * @param name Define the name of the camera in the scene
  96441. * @param position Define the position of the camera
  96442. * @param scene Define the scene the camera belong to
  96443. * @param lockedTarget Define the target of the camera
  96444. */
  96445. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  96446. private _follow;
  96447. /**
  96448. * Attached controls to the current camera.
  96449. * @param element Defines the element the controls should be listened from
  96450. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96451. */
  96452. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96453. /**
  96454. * Detach the current controls from the camera.
  96455. * The camera will stop reacting to inputs.
  96456. * @param element Defines the element to stop listening the inputs from
  96457. */
  96458. detachControl(element: HTMLElement): void;
  96459. /** @hidden */
  96460. _checkInputs(): void;
  96461. private _checkLimits;
  96462. /**
  96463. * Gets the camera class name.
  96464. * @returns the class name
  96465. */
  96466. getClassName(): string;
  96467. }
  96468. /**
  96469. * Arc Rotate version of the follow camera.
  96470. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  96471. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96472. */
  96473. export class ArcFollowCamera extends TargetCamera {
  96474. /** The longitudinal angle of the camera */
  96475. alpha: number;
  96476. /** The latitudinal angle of the camera */
  96477. beta: number;
  96478. /** The radius of the camera from its target */
  96479. radius: number;
  96480. /** Define the camera target (the messh it should follow) */
  96481. target: Nullable<AbstractMesh>;
  96482. private _cartesianCoordinates;
  96483. /**
  96484. * Instantiates a new ArcFollowCamera
  96485. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96486. * @param name Define the name of the camera
  96487. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  96488. * @param beta Define the rotation angle of the camera around the elevation axis
  96489. * @param radius Define the radius of the camera from its target point
  96490. * @param target Define the target of the camera
  96491. * @param scene Define the scene the camera belongs to
  96492. */
  96493. constructor(name: string,
  96494. /** The longitudinal angle of the camera */
  96495. alpha: number,
  96496. /** The latitudinal angle of the camera */
  96497. beta: number,
  96498. /** The radius of the camera from its target */
  96499. radius: number,
  96500. /** Define the camera target (the messh it should follow) */
  96501. target: Nullable<AbstractMesh>, scene: Scene);
  96502. private _follow;
  96503. /** @hidden */
  96504. _checkInputs(): void;
  96505. /**
  96506. * Returns the class name of the object.
  96507. * It is mostly used internally for serialization purposes.
  96508. */
  96509. getClassName(): string;
  96510. }
  96511. }
  96512. declare module BABYLON {
  96513. /**
  96514. * Manage the keyboard inputs to control the movement of a follow camera.
  96515. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96516. */
  96517. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  96518. /**
  96519. * Defines the camera the input is attached to.
  96520. */
  96521. camera: FollowCamera;
  96522. /**
  96523. * Defines the list of key codes associated with the up action (increase heightOffset)
  96524. */
  96525. keysHeightOffsetIncr: number[];
  96526. /**
  96527. * Defines the list of key codes associated with the down action (decrease heightOffset)
  96528. */
  96529. keysHeightOffsetDecr: number[];
  96530. /**
  96531. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  96532. */
  96533. keysHeightOffsetModifierAlt: boolean;
  96534. /**
  96535. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  96536. */
  96537. keysHeightOffsetModifierCtrl: boolean;
  96538. /**
  96539. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  96540. */
  96541. keysHeightOffsetModifierShift: boolean;
  96542. /**
  96543. * Defines the list of key codes associated with the left action (increase rotationOffset)
  96544. */
  96545. keysRotationOffsetIncr: number[];
  96546. /**
  96547. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  96548. */
  96549. keysRotationOffsetDecr: number[];
  96550. /**
  96551. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  96552. */
  96553. keysRotationOffsetModifierAlt: boolean;
  96554. /**
  96555. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  96556. */
  96557. keysRotationOffsetModifierCtrl: boolean;
  96558. /**
  96559. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  96560. */
  96561. keysRotationOffsetModifierShift: boolean;
  96562. /**
  96563. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  96564. */
  96565. keysRadiusIncr: number[];
  96566. /**
  96567. * Defines the list of key codes associated with the zoom-out action (increase radius)
  96568. */
  96569. keysRadiusDecr: number[];
  96570. /**
  96571. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  96572. */
  96573. keysRadiusModifierAlt: boolean;
  96574. /**
  96575. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  96576. */
  96577. keysRadiusModifierCtrl: boolean;
  96578. /**
  96579. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  96580. */
  96581. keysRadiusModifierShift: boolean;
  96582. /**
  96583. * Defines the rate of change of heightOffset.
  96584. */
  96585. heightSensibility: number;
  96586. /**
  96587. * Defines the rate of change of rotationOffset.
  96588. */
  96589. rotationSensibility: number;
  96590. /**
  96591. * Defines the rate of change of radius.
  96592. */
  96593. radiusSensibility: number;
  96594. private _keys;
  96595. private _ctrlPressed;
  96596. private _altPressed;
  96597. private _shiftPressed;
  96598. private _onCanvasBlurObserver;
  96599. private _onKeyboardObserver;
  96600. private _engine;
  96601. private _scene;
  96602. /**
  96603. * Attach the input controls to a specific dom element to get the input from.
  96604. * @param element Defines the element the controls should be listened from
  96605. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96606. */
  96607. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96608. /**
  96609. * Detach the current controls from the specified dom element.
  96610. * @param element Defines the element to stop listening the inputs from
  96611. */
  96612. detachControl(element: Nullable<HTMLElement>): void;
  96613. /**
  96614. * Update the current camera state depending on the inputs that have been used this frame.
  96615. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96616. */
  96617. checkInputs(): void;
  96618. /**
  96619. * Gets the class name of the current input.
  96620. * @returns the class name
  96621. */
  96622. getClassName(): string;
  96623. /**
  96624. * Get the friendly name associated with the input class.
  96625. * @returns the input friendly name
  96626. */
  96627. getSimpleName(): string;
  96628. /**
  96629. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96630. * allow modification of the heightOffset value.
  96631. */
  96632. private _modifierHeightOffset;
  96633. /**
  96634. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96635. * allow modification of the rotationOffset value.
  96636. */
  96637. private _modifierRotationOffset;
  96638. /**
  96639. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96640. * allow modification of the radius value.
  96641. */
  96642. private _modifierRadius;
  96643. }
  96644. }
  96645. declare module BABYLON {
  96646. interface FreeCameraInputsManager {
  96647. /**
  96648. * @hidden
  96649. */
  96650. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  96651. /**
  96652. * Add orientation input support to the input manager.
  96653. * @returns the current input manager
  96654. */
  96655. addDeviceOrientation(): FreeCameraInputsManager;
  96656. }
  96657. /**
  96658. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  96659. * Screen rotation is taken into account.
  96660. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96661. */
  96662. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  96663. private _camera;
  96664. private _screenOrientationAngle;
  96665. private _constantTranform;
  96666. private _screenQuaternion;
  96667. private _alpha;
  96668. private _beta;
  96669. private _gamma;
  96670. /**
  96671. * @hidden
  96672. */
  96673. _onDeviceOrientationChangedObservable: Observable<void>;
  96674. /**
  96675. * Instantiates a new input
  96676. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96677. */
  96678. constructor();
  96679. /**
  96680. * Define the camera controlled by the input.
  96681. */
  96682. camera: FreeCamera;
  96683. /**
  96684. * Attach the input controls to a specific dom element to get the input from.
  96685. * @param element Defines the element the controls should be listened from
  96686. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96687. */
  96688. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96689. private _orientationChanged;
  96690. private _deviceOrientation;
  96691. /**
  96692. * Detach the current controls from the specified dom element.
  96693. * @param element Defines the element to stop listening the inputs from
  96694. */
  96695. detachControl(element: Nullable<HTMLElement>): void;
  96696. /**
  96697. * Update the current camera state depending on the inputs that have been used this frame.
  96698. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96699. */
  96700. checkInputs(): void;
  96701. /**
  96702. * Gets the class name of the current intput.
  96703. * @returns the class name
  96704. */
  96705. getClassName(): string;
  96706. /**
  96707. * Get the friendly name associated with the input class.
  96708. * @returns the input friendly name
  96709. */
  96710. getSimpleName(): string;
  96711. }
  96712. }
  96713. declare module BABYLON {
  96714. /**
  96715. * Manage the gamepad inputs to control a free camera.
  96716. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96717. */
  96718. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  96719. /**
  96720. * Define the camera the input is attached to.
  96721. */
  96722. camera: FreeCamera;
  96723. /**
  96724. * Define the Gamepad controlling the input
  96725. */
  96726. gamepad: Nullable<Gamepad>;
  96727. /**
  96728. * Defines the gamepad rotation sensiblity.
  96729. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96730. */
  96731. gamepadAngularSensibility: number;
  96732. /**
  96733. * Defines the gamepad move sensiblity.
  96734. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96735. */
  96736. gamepadMoveSensibility: number;
  96737. private _onGamepadConnectedObserver;
  96738. private _onGamepadDisconnectedObserver;
  96739. private _cameraTransform;
  96740. private _deltaTransform;
  96741. private _vector3;
  96742. private _vector2;
  96743. /**
  96744. * Attach the input controls to a specific dom element to get the input from.
  96745. * @param element Defines the element the controls should be listened from
  96746. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96747. */
  96748. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96749. /**
  96750. * Detach the current controls from the specified dom element.
  96751. * @param element Defines the element to stop listening the inputs from
  96752. */
  96753. detachControl(element: Nullable<HTMLElement>): void;
  96754. /**
  96755. * Update the current camera state depending on the inputs that have been used this frame.
  96756. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96757. */
  96758. checkInputs(): void;
  96759. /**
  96760. * Gets the class name of the current intput.
  96761. * @returns the class name
  96762. */
  96763. getClassName(): string;
  96764. /**
  96765. * Get the friendly name associated with the input class.
  96766. * @returns the input friendly name
  96767. */
  96768. getSimpleName(): string;
  96769. }
  96770. }
  96771. declare module BABYLON {
  96772. /**
  96773. * Defines the potential axis of a Joystick
  96774. */
  96775. export enum JoystickAxis {
  96776. /** X axis */
  96777. X = 0,
  96778. /** Y axis */
  96779. Y = 1,
  96780. /** Z axis */
  96781. Z = 2
  96782. }
  96783. /**
  96784. * Class used to define virtual joystick (used in touch mode)
  96785. */
  96786. export class VirtualJoystick {
  96787. /**
  96788. * Gets or sets a boolean indicating that left and right values must be inverted
  96789. */
  96790. reverseLeftRight: boolean;
  96791. /**
  96792. * Gets or sets a boolean indicating that up and down values must be inverted
  96793. */
  96794. reverseUpDown: boolean;
  96795. /**
  96796. * Gets the offset value for the position (ie. the change of the position value)
  96797. */
  96798. deltaPosition: Vector3;
  96799. /**
  96800. * Gets a boolean indicating if the virtual joystick was pressed
  96801. */
  96802. pressed: boolean;
  96803. /**
  96804. * Canvas the virtual joystick will render onto, default z-index of this is 5
  96805. */
  96806. static Canvas: Nullable<HTMLCanvasElement>;
  96807. private static _globalJoystickIndex;
  96808. private static vjCanvasContext;
  96809. private static vjCanvasWidth;
  96810. private static vjCanvasHeight;
  96811. private static halfWidth;
  96812. private _action;
  96813. private _axisTargetedByLeftAndRight;
  96814. private _axisTargetedByUpAndDown;
  96815. private _joystickSensibility;
  96816. private _inversedSensibility;
  96817. private _joystickPointerID;
  96818. private _joystickColor;
  96819. private _joystickPointerPos;
  96820. private _joystickPreviousPointerPos;
  96821. private _joystickPointerStartPos;
  96822. private _deltaJoystickVector;
  96823. private _leftJoystick;
  96824. private _touches;
  96825. private _onPointerDownHandlerRef;
  96826. private _onPointerMoveHandlerRef;
  96827. private _onPointerUpHandlerRef;
  96828. private _onResize;
  96829. /**
  96830. * Creates a new virtual joystick
  96831. * @param leftJoystick defines that the joystick is for left hand (false by default)
  96832. */
  96833. constructor(leftJoystick?: boolean);
  96834. /**
  96835. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  96836. * @param newJoystickSensibility defines the new sensibility
  96837. */
  96838. setJoystickSensibility(newJoystickSensibility: number): void;
  96839. private _onPointerDown;
  96840. private _onPointerMove;
  96841. private _onPointerUp;
  96842. /**
  96843. * Change the color of the virtual joystick
  96844. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  96845. */
  96846. setJoystickColor(newColor: string): void;
  96847. /**
  96848. * Defines a callback to call when the joystick is touched
  96849. * @param action defines the callback
  96850. */
  96851. setActionOnTouch(action: () => any): void;
  96852. /**
  96853. * Defines which axis you'd like to control for left & right
  96854. * @param axis defines the axis to use
  96855. */
  96856. setAxisForLeftRight(axis: JoystickAxis): void;
  96857. /**
  96858. * Defines which axis you'd like to control for up & down
  96859. * @param axis defines the axis to use
  96860. */
  96861. setAxisForUpDown(axis: JoystickAxis): void;
  96862. private _drawVirtualJoystick;
  96863. /**
  96864. * Release internal HTML canvas
  96865. */
  96866. releaseCanvas(): void;
  96867. }
  96868. }
  96869. declare module BABYLON {
  96870. interface FreeCameraInputsManager {
  96871. /**
  96872. * Add virtual joystick input support to the input manager.
  96873. * @returns the current input manager
  96874. */
  96875. addVirtualJoystick(): FreeCameraInputsManager;
  96876. }
  96877. /**
  96878. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  96879. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96880. */
  96881. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  96882. /**
  96883. * Defines the camera the input is attached to.
  96884. */
  96885. camera: FreeCamera;
  96886. private _leftjoystick;
  96887. private _rightjoystick;
  96888. /**
  96889. * Gets the left stick of the virtual joystick.
  96890. * @returns The virtual Joystick
  96891. */
  96892. getLeftJoystick(): VirtualJoystick;
  96893. /**
  96894. * Gets the right stick of the virtual joystick.
  96895. * @returns The virtual Joystick
  96896. */
  96897. getRightJoystick(): VirtualJoystick;
  96898. /**
  96899. * Update the current camera state depending on the inputs that have been used this frame.
  96900. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96901. */
  96902. checkInputs(): void;
  96903. /**
  96904. * Attach the input controls to a specific dom element to get the input from.
  96905. * @param element Defines the element the controls should be listened from
  96906. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96907. */
  96908. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96909. /**
  96910. * Detach the current controls from the specified dom element.
  96911. * @param element Defines the element to stop listening the inputs from
  96912. */
  96913. detachControl(element: Nullable<HTMLElement>): void;
  96914. /**
  96915. * Gets the class name of the current intput.
  96916. * @returns the class name
  96917. */
  96918. getClassName(): string;
  96919. /**
  96920. * Get the friendly name associated with the input class.
  96921. * @returns the input friendly name
  96922. */
  96923. getSimpleName(): string;
  96924. }
  96925. }
  96926. declare module BABYLON {
  96927. /**
  96928. * This represents a FPS type of camera controlled by touch.
  96929. * This is like a universal camera minus the Gamepad controls.
  96930. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96931. */
  96932. export class TouchCamera extends FreeCamera {
  96933. /**
  96934. * Defines the touch sensibility for rotation.
  96935. * The higher the faster.
  96936. */
  96937. touchAngularSensibility: number;
  96938. /**
  96939. * Defines the touch sensibility for move.
  96940. * The higher the faster.
  96941. */
  96942. touchMoveSensibility: number;
  96943. /**
  96944. * Instantiates a new touch camera.
  96945. * This represents a FPS type of camera controlled by touch.
  96946. * This is like a universal camera minus the Gamepad controls.
  96947. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96948. * @param name Define the name of the camera in the scene
  96949. * @param position Define the start position of the camera in the scene
  96950. * @param scene Define the scene the camera belongs to
  96951. */
  96952. constructor(name: string, position: Vector3, scene: Scene);
  96953. /**
  96954. * Gets the current object class name.
  96955. * @return the class name
  96956. */
  96957. getClassName(): string;
  96958. /** @hidden */
  96959. _setupInputs(): void;
  96960. }
  96961. }
  96962. declare module BABYLON {
  96963. /**
  96964. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  96965. * being tilted forward or back and left or right.
  96966. */
  96967. export class DeviceOrientationCamera extends FreeCamera {
  96968. private _initialQuaternion;
  96969. private _quaternionCache;
  96970. private _tmpDragQuaternion;
  96971. /**
  96972. * Creates a new device orientation camera
  96973. * @param name The name of the camera
  96974. * @param position The start position camera
  96975. * @param scene The scene the camera belongs to
  96976. */
  96977. constructor(name: string, position: Vector3, scene: Scene);
  96978. /**
  96979. * @hidden
  96980. * Disabled pointer input on first orientation sensor update (Default: true)
  96981. */
  96982. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  96983. private _dragFactor;
  96984. /**
  96985. * Enabled turning on the y axis when the orientation sensor is active
  96986. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  96987. */
  96988. enableHorizontalDragging(dragFactor?: number): void;
  96989. /**
  96990. * Gets the current instance class name ("DeviceOrientationCamera").
  96991. * This helps avoiding instanceof at run time.
  96992. * @returns the class name
  96993. */
  96994. getClassName(): string;
  96995. /**
  96996. * @hidden
  96997. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  96998. */
  96999. _checkInputs(): void;
  97000. /**
  97001. * Reset the camera to its default orientation on the specified axis only.
  97002. * @param axis The axis to reset
  97003. */
  97004. resetToCurrentRotation(axis?: Axis): void;
  97005. }
  97006. }
  97007. declare module BABYLON {
  97008. /**
  97009. * 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,
  97010. * which still works and will still be found in many Playgrounds.
  97011. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97012. */
  97013. export class UniversalCamera extends TouchCamera {
  97014. /**
  97015. * Defines the gamepad rotation sensiblity.
  97016. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  97017. */
  97018. gamepadAngularSensibility: number;
  97019. /**
  97020. * Defines the gamepad move sensiblity.
  97021. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  97022. */
  97023. gamepadMoveSensibility: number;
  97024. /**
  97025. * 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,
  97026. * which still works and will still be found in many Playgrounds.
  97027. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97028. * @param name Define the name of the camera in the scene
  97029. * @param position Define the start position of the camera in the scene
  97030. * @param scene Define the scene the camera belongs to
  97031. */
  97032. constructor(name: string, position: Vector3, scene: Scene);
  97033. /**
  97034. * Gets the current object class name.
  97035. * @return the class name
  97036. */
  97037. getClassName(): string;
  97038. }
  97039. }
  97040. declare module BABYLON {
  97041. /**
  97042. * This represents a FPS type of camera. This is only here for back compat purpose.
  97043. * Please use the UniversalCamera instead as both are identical.
  97044. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97045. */
  97046. export class GamepadCamera extends UniversalCamera {
  97047. /**
  97048. * Instantiates a new Gamepad Camera
  97049. * This represents a FPS type of camera. This is only here for back compat purpose.
  97050. * Please use the UniversalCamera instead as both are identical.
  97051. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97052. * @param name Define the name of the camera in the scene
  97053. * @param position Define the start position of the camera in the scene
  97054. * @param scene Define the scene the camera belongs to
  97055. */
  97056. constructor(name: string, position: Vector3, scene: Scene);
  97057. /**
  97058. * Gets the current object class name.
  97059. * @return the class name
  97060. */
  97061. getClassName(): string;
  97062. }
  97063. }
  97064. declare module BABYLON {
  97065. /** @hidden */
  97066. export var passPixelShader: {
  97067. name: string;
  97068. shader: string;
  97069. };
  97070. }
  97071. declare module BABYLON {
  97072. /** @hidden */
  97073. export var passCubePixelShader: {
  97074. name: string;
  97075. shader: string;
  97076. };
  97077. }
  97078. declare module BABYLON {
  97079. /**
  97080. * PassPostProcess which produces an output the same as it's input
  97081. */
  97082. export class PassPostProcess extends PostProcess {
  97083. /**
  97084. * Creates the PassPostProcess
  97085. * @param name The name of the effect.
  97086. * @param options The required width/height ratio to downsize to before computing the render pass.
  97087. * @param camera The camera to apply the render pass to.
  97088. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97089. * @param engine The engine which the post process will be applied. (default: current engine)
  97090. * @param reusable If the post process can be reused on the same frame. (default: false)
  97091. * @param textureType The type of texture to be used when performing the post processing.
  97092. * @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)
  97093. */
  97094. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  97095. }
  97096. /**
  97097. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  97098. */
  97099. export class PassCubePostProcess extends PostProcess {
  97100. private _face;
  97101. /**
  97102. * Gets or sets the cube face to display.
  97103. * * 0 is +X
  97104. * * 1 is -X
  97105. * * 2 is +Y
  97106. * * 3 is -Y
  97107. * * 4 is +Z
  97108. * * 5 is -Z
  97109. */
  97110. face: number;
  97111. /**
  97112. * Creates the PassCubePostProcess
  97113. * @param name The name of the effect.
  97114. * @param options The required width/height ratio to downsize to before computing the render pass.
  97115. * @param camera The camera to apply the render pass to.
  97116. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97117. * @param engine The engine which the post process will be applied. (default: current engine)
  97118. * @param reusable If the post process can be reused on the same frame. (default: false)
  97119. * @param textureType The type of texture to be used when performing the post processing.
  97120. * @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)
  97121. */
  97122. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  97123. }
  97124. }
  97125. declare module BABYLON {
  97126. /** @hidden */
  97127. export var anaglyphPixelShader: {
  97128. name: string;
  97129. shader: string;
  97130. };
  97131. }
  97132. declare module BABYLON {
  97133. /**
  97134. * Postprocess used to generate anaglyphic rendering
  97135. */
  97136. export class AnaglyphPostProcess extends PostProcess {
  97137. private _passedProcess;
  97138. /**
  97139. * Creates a new AnaglyphPostProcess
  97140. * @param name defines postprocess name
  97141. * @param options defines creation options or target ratio scale
  97142. * @param rigCameras defines cameras using this postprocess
  97143. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  97144. * @param engine defines hosting engine
  97145. * @param reusable defines if the postprocess will be reused multiple times per frame
  97146. */
  97147. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  97148. }
  97149. }
  97150. declare module BABYLON {
  97151. /**
  97152. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  97153. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97154. */
  97155. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  97156. /**
  97157. * Creates a new AnaglyphArcRotateCamera
  97158. * @param name defines camera name
  97159. * @param alpha defines alpha angle (in radians)
  97160. * @param beta defines beta angle (in radians)
  97161. * @param radius defines radius
  97162. * @param target defines camera target
  97163. * @param interaxialDistance defines distance between each color axis
  97164. * @param scene defines the hosting scene
  97165. */
  97166. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  97167. /**
  97168. * Gets camera class name
  97169. * @returns AnaglyphArcRotateCamera
  97170. */
  97171. getClassName(): string;
  97172. }
  97173. }
  97174. declare module BABYLON {
  97175. /**
  97176. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  97177. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97178. */
  97179. export class AnaglyphFreeCamera extends FreeCamera {
  97180. /**
  97181. * Creates a new AnaglyphFreeCamera
  97182. * @param name defines camera name
  97183. * @param position defines initial position
  97184. * @param interaxialDistance defines distance between each color axis
  97185. * @param scene defines the hosting scene
  97186. */
  97187. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97188. /**
  97189. * Gets camera class name
  97190. * @returns AnaglyphFreeCamera
  97191. */
  97192. getClassName(): string;
  97193. }
  97194. }
  97195. declare module BABYLON {
  97196. /**
  97197. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  97198. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97199. */
  97200. export class AnaglyphGamepadCamera extends GamepadCamera {
  97201. /**
  97202. * Creates a new AnaglyphGamepadCamera
  97203. * @param name defines camera name
  97204. * @param position defines initial position
  97205. * @param interaxialDistance defines distance between each color axis
  97206. * @param scene defines the hosting scene
  97207. */
  97208. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97209. /**
  97210. * Gets camera class name
  97211. * @returns AnaglyphGamepadCamera
  97212. */
  97213. getClassName(): string;
  97214. }
  97215. }
  97216. declare module BABYLON {
  97217. /**
  97218. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  97219. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97220. */
  97221. export class AnaglyphUniversalCamera extends UniversalCamera {
  97222. /**
  97223. * Creates a new AnaglyphUniversalCamera
  97224. * @param name defines camera name
  97225. * @param position defines initial position
  97226. * @param interaxialDistance defines distance between each color axis
  97227. * @param scene defines the hosting scene
  97228. */
  97229. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97230. /**
  97231. * Gets camera class name
  97232. * @returns AnaglyphUniversalCamera
  97233. */
  97234. getClassName(): string;
  97235. }
  97236. }
  97237. declare module BABYLON {
  97238. /** @hidden */
  97239. export var stereoscopicInterlacePixelShader: {
  97240. name: string;
  97241. shader: string;
  97242. };
  97243. }
  97244. declare module BABYLON {
  97245. /**
  97246. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  97247. */
  97248. export class StereoscopicInterlacePostProcess extends PostProcess {
  97249. private _stepSize;
  97250. private _passedProcess;
  97251. /**
  97252. * Initializes a StereoscopicInterlacePostProcess
  97253. * @param name The name of the effect.
  97254. * @param rigCameras The rig cameras to be appled to the post process
  97255. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  97256. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97257. * @param engine The engine which the post process will be applied. (default: current engine)
  97258. * @param reusable If the post process can be reused on the same frame. (default: false)
  97259. */
  97260. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  97261. }
  97262. }
  97263. declare module BABYLON {
  97264. /**
  97265. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  97266. * @see http://doc.babylonjs.com/features/cameras
  97267. */
  97268. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  97269. /**
  97270. * Creates a new StereoscopicArcRotateCamera
  97271. * @param name defines camera name
  97272. * @param alpha defines alpha angle (in radians)
  97273. * @param beta defines beta angle (in radians)
  97274. * @param radius defines radius
  97275. * @param target defines camera target
  97276. * @param interaxialDistance defines distance between each color axis
  97277. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97278. * @param scene defines the hosting scene
  97279. */
  97280. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97281. /**
  97282. * Gets camera class name
  97283. * @returns StereoscopicArcRotateCamera
  97284. */
  97285. getClassName(): string;
  97286. }
  97287. }
  97288. declare module BABYLON {
  97289. /**
  97290. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  97291. * @see http://doc.babylonjs.com/features/cameras
  97292. */
  97293. export class StereoscopicFreeCamera extends FreeCamera {
  97294. /**
  97295. * Creates a new StereoscopicFreeCamera
  97296. * @param name defines camera name
  97297. * @param position defines initial position
  97298. * @param interaxialDistance defines distance between each color axis
  97299. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97300. * @param scene defines the hosting scene
  97301. */
  97302. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97303. /**
  97304. * Gets camera class name
  97305. * @returns StereoscopicFreeCamera
  97306. */
  97307. getClassName(): string;
  97308. }
  97309. }
  97310. declare module BABYLON {
  97311. /**
  97312. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  97313. * @see http://doc.babylonjs.com/features/cameras
  97314. */
  97315. export class StereoscopicGamepadCamera extends GamepadCamera {
  97316. /**
  97317. * Creates a new StereoscopicGamepadCamera
  97318. * @param name defines camera name
  97319. * @param position defines initial position
  97320. * @param interaxialDistance defines distance between each color axis
  97321. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97322. * @param scene defines the hosting scene
  97323. */
  97324. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97325. /**
  97326. * Gets camera class name
  97327. * @returns StereoscopicGamepadCamera
  97328. */
  97329. getClassName(): string;
  97330. }
  97331. }
  97332. declare module BABYLON {
  97333. /**
  97334. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  97335. * @see http://doc.babylonjs.com/features/cameras
  97336. */
  97337. export class StereoscopicUniversalCamera extends UniversalCamera {
  97338. /**
  97339. * Creates a new StereoscopicUniversalCamera
  97340. * @param name defines camera name
  97341. * @param position defines initial position
  97342. * @param interaxialDistance defines distance between each color axis
  97343. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97344. * @param scene defines the hosting scene
  97345. */
  97346. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97347. /**
  97348. * Gets camera class name
  97349. * @returns StereoscopicUniversalCamera
  97350. */
  97351. getClassName(): string;
  97352. }
  97353. }
  97354. declare module BABYLON {
  97355. /**
  97356. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97357. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  97358. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  97359. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  97360. */
  97361. export class VirtualJoysticksCamera extends FreeCamera {
  97362. /**
  97363. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  97364. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  97365. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  97366. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  97367. * @param name Define the name of the camera in the scene
  97368. * @param position Define the start position of the camera in the scene
  97369. * @param scene Define the scene the camera belongs to
  97370. */
  97371. constructor(name: string, position: Vector3, scene: Scene);
  97372. /**
  97373. * Gets the current object class name.
  97374. * @return the class name
  97375. */
  97376. getClassName(): string;
  97377. }
  97378. }
  97379. declare module BABYLON {
  97380. /**
  97381. * This represents all the required metrics to create a VR camera.
  97382. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  97383. */
  97384. export class VRCameraMetrics {
  97385. /**
  97386. * Define the horizontal resolution off the screen.
  97387. */
  97388. hResolution: number;
  97389. /**
  97390. * Define the vertical resolution off the screen.
  97391. */
  97392. vResolution: number;
  97393. /**
  97394. * Define the horizontal screen size.
  97395. */
  97396. hScreenSize: number;
  97397. /**
  97398. * Define the vertical screen size.
  97399. */
  97400. vScreenSize: number;
  97401. /**
  97402. * Define the vertical screen center position.
  97403. */
  97404. vScreenCenter: number;
  97405. /**
  97406. * Define the distance of the eyes to the screen.
  97407. */
  97408. eyeToScreenDistance: number;
  97409. /**
  97410. * Define the distance between both lenses
  97411. */
  97412. lensSeparationDistance: number;
  97413. /**
  97414. * Define the distance between both viewer's eyes.
  97415. */
  97416. interpupillaryDistance: number;
  97417. /**
  97418. * Define the distortion factor of the VR postprocess.
  97419. * Please, touch with care.
  97420. */
  97421. distortionK: number[];
  97422. /**
  97423. * Define the chromatic aberration correction factors for the VR post process.
  97424. */
  97425. chromaAbCorrection: number[];
  97426. /**
  97427. * Define the scale factor of the post process.
  97428. * The smaller the better but the slower.
  97429. */
  97430. postProcessScaleFactor: number;
  97431. /**
  97432. * Define an offset for the lens center.
  97433. */
  97434. lensCenterOffset: number;
  97435. /**
  97436. * Define if the current vr camera should compensate the distortion of the lense or not.
  97437. */
  97438. compensateDistortion: boolean;
  97439. /**
  97440. * Defines if multiview should be enabled when rendering (Default: false)
  97441. */
  97442. multiviewEnabled: boolean;
  97443. /**
  97444. * Gets the rendering aspect ratio based on the provided resolutions.
  97445. */
  97446. readonly aspectRatio: number;
  97447. /**
  97448. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  97449. */
  97450. readonly aspectRatioFov: number;
  97451. /**
  97452. * @hidden
  97453. */
  97454. readonly leftHMatrix: Matrix;
  97455. /**
  97456. * @hidden
  97457. */
  97458. readonly rightHMatrix: Matrix;
  97459. /**
  97460. * @hidden
  97461. */
  97462. readonly leftPreViewMatrix: Matrix;
  97463. /**
  97464. * @hidden
  97465. */
  97466. readonly rightPreViewMatrix: Matrix;
  97467. /**
  97468. * Get the default VRMetrics based on the most generic setup.
  97469. * @returns the default vr metrics
  97470. */
  97471. static GetDefault(): VRCameraMetrics;
  97472. }
  97473. }
  97474. declare module BABYLON {
  97475. /** @hidden */
  97476. export var vrDistortionCorrectionPixelShader: {
  97477. name: string;
  97478. shader: string;
  97479. };
  97480. }
  97481. declare module BABYLON {
  97482. /**
  97483. * VRDistortionCorrectionPostProcess used for mobile VR
  97484. */
  97485. export class VRDistortionCorrectionPostProcess extends PostProcess {
  97486. private _isRightEye;
  97487. private _distortionFactors;
  97488. private _postProcessScaleFactor;
  97489. private _lensCenterOffset;
  97490. private _scaleIn;
  97491. private _scaleFactor;
  97492. private _lensCenter;
  97493. /**
  97494. * Initializes the VRDistortionCorrectionPostProcess
  97495. * @param name The name of the effect.
  97496. * @param camera The camera to apply the render pass to.
  97497. * @param isRightEye If this is for the right eye distortion
  97498. * @param vrMetrics All the required metrics for the VR camera
  97499. */
  97500. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  97501. }
  97502. }
  97503. declare module BABYLON {
  97504. /**
  97505. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  97506. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97507. */
  97508. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  97509. /**
  97510. * Creates a new VRDeviceOrientationArcRotateCamera
  97511. * @param name defines camera name
  97512. * @param alpha defines the camera rotation along the logitudinal axis
  97513. * @param beta defines the camera rotation along the latitudinal axis
  97514. * @param radius defines the camera distance from its target
  97515. * @param target defines the camera target
  97516. * @param scene defines the scene the camera belongs to
  97517. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97518. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97519. */
  97520. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97521. /**
  97522. * Gets camera class name
  97523. * @returns VRDeviceOrientationArcRotateCamera
  97524. */
  97525. getClassName(): string;
  97526. }
  97527. }
  97528. declare module BABYLON {
  97529. /**
  97530. * Camera used to simulate VR rendering (based on FreeCamera)
  97531. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97532. */
  97533. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  97534. /**
  97535. * Creates a new VRDeviceOrientationFreeCamera
  97536. * @param name defines camera name
  97537. * @param position defines the start position of the camera
  97538. * @param scene defines the scene the camera belongs to
  97539. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97540. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97541. */
  97542. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97543. /**
  97544. * Gets camera class name
  97545. * @returns VRDeviceOrientationFreeCamera
  97546. */
  97547. getClassName(): string;
  97548. }
  97549. }
  97550. declare module BABYLON {
  97551. /**
  97552. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  97553. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97554. */
  97555. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  97556. /**
  97557. * Creates a new VRDeviceOrientationGamepadCamera
  97558. * @param name defines camera name
  97559. * @param position defines the start position of the camera
  97560. * @param scene defines the scene the camera belongs to
  97561. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97562. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97563. */
  97564. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97565. /**
  97566. * Gets camera class name
  97567. * @returns VRDeviceOrientationGamepadCamera
  97568. */
  97569. getClassName(): string;
  97570. }
  97571. }
  97572. declare module BABYLON {
  97573. /**
  97574. * Defines supported buttons for XBox360 compatible gamepads
  97575. */
  97576. export enum Xbox360Button {
  97577. /** A */
  97578. A = 0,
  97579. /** B */
  97580. B = 1,
  97581. /** X */
  97582. X = 2,
  97583. /** Y */
  97584. Y = 3,
  97585. /** Start */
  97586. Start = 4,
  97587. /** Back */
  97588. Back = 5,
  97589. /** Left button */
  97590. LB = 6,
  97591. /** Right button */
  97592. RB = 7,
  97593. /** Left stick */
  97594. LeftStick = 8,
  97595. /** Right stick */
  97596. RightStick = 9
  97597. }
  97598. /** Defines values for XBox360 DPad */
  97599. export enum Xbox360Dpad {
  97600. /** Up */
  97601. Up = 0,
  97602. /** Down */
  97603. Down = 1,
  97604. /** Left */
  97605. Left = 2,
  97606. /** Right */
  97607. Right = 3
  97608. }
  97609. /**
  97610. * Defines a XBox360 gamepad
  97611. */
  97612. export class Xbox360Pad extends Gamepad {
  97613. private _leftTrigger;
  97614. private _rightTrigger;
  97615. private _onlefttriggerchanged;
  97616. private _onrighttriggerchanged;
  97617. private _onbuttondown;
  97618. private _onbuttonup;
  97619. private _ondpaddown;
  97620. private _ondpadup;
  97621. /** Observable raised when a button is pressed */
  97622. onButtonDownObservable: Observable<Xbox360Button>;
  97623. /** Observable raised when a button is released */
  97624. onButtonUpObservable: Observable<Xbox360Button>;
  97625. /** Observable raised when a pad is pressed */
  97626. onPadDownObservable: Observable<Xbox360Dpad>;
  97627. /** Observable raised when a pad is released */
  97628. onPadUpObservable: Observable<Xbox360Dpad>;
  97629. private _buttonA;
  97630. private _buttonB;
  97631. private _buttonX;
  97632. private _buttonY;
  97633. private _buttonBack;
  97634. private _buttonStart;
  97635. private _buttonLB;
  97636. private _buttonRB;
  97637. private _buttonLeftStick;
  97638. private _buttonRightStick;
  97639. private _dPadUp;
  97640. private _dPadDown;
  97641. private _dPadLeft;
  97642. private _dPadRight;
  97643. private _isXboxOnePad;
  97644. /**
  97645. * Creates a new XBox360 gamepad object
  97646. * @param id defines the id of this gamepad
  97647. * @param index defines its index
  97648. * @param gamepad defines the internal HTML gamepad object
  97649. * @param xboxOne defines if it is a XBox One gamepad
  97650. */
  97651. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  97652. /**
  97653. * Defines the callback to call when left trigger is pressed
  97654. * @param callback defines the callback to use
  97655. */
  97656. onlefttriggerchanged(callback: (value: number) => void): void;
  97657. /**
  97658. * Defines the callback to call when right trigger is pressed
  97659. * @param callback defines the callback to use
  97660. */
  97661. onrighttriggerchanged(callback: (value: number) => void): void;
  97662. /**
  97663. * Gets the left trigger value
  97664. */
  97665. /**
  97666. * Sets the left trigger value
  97667. */
  97668. leftTrigger: number;
  97669. /**
  97670. * Gets the right trigger value
  97671. */
  97672. /**
  97673. * Sets the right trigger value
  97674. */
  97675. rightTrigger: number;
  97676. /**
  97677. * Defines the callback to call when a button is pressed
  97678. * @param callback defines the callback to use
  97679. */
  97680. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  97681. /**
  97682. * Defines the callback to call when a button is released
  97683. * @param callback defines the callback to use
  97684. */
  97685. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  97686. /**
  97687. * Defines the callback to call when a pad is pressed
  97688. * @param callback defines the callback to use
  97689. */
  97690. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  97691. /**
  97692. * Defines the callback to call when a pad is released
  97693. * @param callback defines the callback to use
  97694. */
  97695. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  97696. private _setButtonValue;
  97697. private _setDPadValue;
  97698. /**
  97699. * Gets the value of the `A` button
  97700. */
  97701. /**
  97702. * Sets the value of the `A` button
  97703. */
  97704. buttonA: number;
  97705. /**
  97706. * Gets the value of the `B` button
  97707. */
  97708. /**
  97709. * Sets the value of the `B` button
  97710. */
  97711. buttonB: number;
  97712. /**
  97713. * Gets the value of the `X` button
  97714. */
  97715. /**
  97716. * Sets the value of the `X` button
  97717. */
  97718. buttonX: number;
  97719. /**
  97720. * Gets the value of the `Y` button
  97721. */
  97722. /**
  97723. * Sets the value of the `Y` button
  97724. */
  97725. buttonY: number;
  97726. /**
  97727. * Gets the value of the `Start` button
  97728. */
  97729. /**
  97730. * Sets the value of the `Start` button
  97731. */
  97732. buttonStart: number;
  97733. /**
  97734. * Gets the value of the `Back` button
  97735. */
  97736. /**
  97737. * Sets the value of the `Back` button
  97738. */
  97739. buttonBack: number;
  97740. /**
  97741. * Gets the value of the `Left` button
  97742. */
  97743. /**
  97744. * Sets the value of the `Left` button
  97745. */
  97746. buttonLB: number;
  97747. /**
  97748. * Gets the value of the `Right` button
  97749. */
  97750. /**
  97751. * Sets the value of the `Right` button
  97752. */
  97753. buttonRB: number;
  97754. /**
  97755. * Gets the value of the Left joystick
  97756. */
  97757. /**
  97758. * Sets the value of the Left joystick
  97759. */
  97760. buttonLeftStick: number;
  97761. /**
  97762. * Gets the value of the Right joystick
  97763. */
  97764. /**
  97765. * Sets the value of the Right joystick
  97766. */
  97767. buttonRightStick: number;
  97768. /**
  97769. * Gets the value of D-pad up
  97770. */
  97771. /**
  97772. * Sets the value of D-pad up
  97773. */
  97774. dPadUp: number;
  97775. /**
  97776. * Gets the value of D-pad down
  97777. */
  97778. /**
  97779. * Sets the value of D-pad down
  97780. */
  97781. dPadDown: number;
  97782. /**
  97783. * Gets the value of D-pad left
  97784. */
  97785. /**
  97786. * Sets the value of D-pad left
  97787. */
  97788. dPadLeft: number;
  97789. /**
  97790. * Gets the value of D-pad right
  97791. */
  97792. /**
  97793. * Sets the value of D-pad right
  97794. */
  97795. dPadRight: number;
  97796. /**
  97797. * Force the gamepad to synchronize with device values
  97798. */
  97799. update(): void;
  97800. /**
  97801. * Disposes the gamepad
  97802. */
  97803. dispose(): void;
  97804. }
  97805. }
  97806. declare module BABYLON {
  97807. /**
  97808. * Base class of materials working in push mode in babylon JS
  97809. * @hidden
  97810. */
  97811. export class PushMaterial extends Material {
  97812. protected _activeEffect: Effect;
  97813. protected _normalMatrix: Matrix;
  97814. /**
  97815. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  97816. * This means that the material can keep using a previous shader while a new one is being compiled.
  97817. * This is mostly used when shader parallel compilation is supported (true by default)
  97818. */
  97819. allowShaderHotSwapping: boolean;
  97820. constructor(name: string, scene: Scene);
  97821. getEffect(): Effect;
  97822. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97823. /**
  97824. * Binds the given world matrix to the active effect
  97825. *
  97826. * @param world the matrix to bind
  97827. */
  97828. bindOnlyWorldMatrix(world: Matrix): void;
  97829. /**
  97830. * Binds the given normal matrix to the active effect
  97831. *
  97832. * @param normalMatrix the matrix to bind
  97833. */
  97834. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  97835. bind(world: Matrix, mesh?: Mesh): void;
  97836. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  97837. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  97838. }
  97839. }
  97840. declare module BABYLON {
  97841. /**
  97842. * This groups all the flags used to control the materials channel.
  97843. */
  97844. export class MaterialFlags {
  97845. private static _DiffuseTextureEnabled;
  97846. /**
  97847. * Are diffuse textures enabled in the application.
  97848. */
  97849. static DiffuseTextureEnabled: boolean;
  97850. private static _AmbientTextureEnabled;
  97851. /**
  97852. * Are ambient textures enabled in the application.
  97853. */
  97854. static AmbientTextureEnabled: boolean;
  97855. private static _OpacityTextureEnabled;
  97856. /**
  97857. * Are opacity textures enabled in the application.
  97858. */
  97859. static OpacityTextureEnabled: boolean;
  97860. private static _ReflectionTextureEnabled;
  97861. /**
  97862. * Are reflection textures enabled in the application.
  97863. */
  97864. static ReflectionTextureEnabled: boolean;
  97865. private static _EmissiveTextureEnabled;
  97866. /**
  97867. * Are emissive textures enabled in the application.
  97868. */
  97869. static EmissiveTextureEnabled: boolean;
  97870. private static _SpecularTextureEnabled;
  97871. /**
  97872. * Are specular textures enabled in the application.
  97873. */
  97874. static SpecularTextureEnabled: boolean;
  97875. private static _BumpTextureEnabled;
  97876. /**
  97877. * Are bump textures enabled in the application.
  97878. */
  97879. static BumpTextureEnabled: boolean;
  97880. private static _LightmapTextureEnabled;
  97881. /**
  97882. * Are lightmap textures enabled in the application.
  97883. */
  97884. static LightmapTextureEnabled: boolean;
  97885. private static _RefractionTextureEnabled;
  97886. /**
  97887. * Are refraction textures enabled in the application.
  97888. */
  97889. static RefractionTextureEnabled: boolean;
  97890. private static _ColorGradingTextureEnabled;
  97891. /**
  97892. * Are color grading textures enabled in the application.
  97893. */
  97894. static ColorGradingTextureEnabled: boolean;
  97895. private static _FresnelEnabled;
  97896. /**
  97897. * Are fresnels enabled in the application.
  97898. */
  97899. static FresnelEnabled: boolean;
  97900. private static _ClearCoatTextureEnabled;
  97901. /**
  97902. * Are clear coat textures enabled in the application.
  97903. */
  97904. static ClearCoatTextureEnabled: boolean;
  97905. private static _ClearCoatBumpTextureEnabled;
  97906. /**
  97907. * Are clear coat bump textures enabled in the application.
  97908. */
  97909. static ClearCoatBumpTextureEnabled: boolean;
  97910. private static _ClearCoatTintTextureEnabled;
  97911. /**
  97912. * Are clear coat tint textures enabled in the application.
  97913. */
  97914. static ClearCoatTintTextureEnabled: boolean;
  97915. private static _SheenTextureEnabled;
  97916. /**
  97917. * Are sheen textures enabled in the application.
  97918. */
  97919. static SheenTextureEnabled: boolean;
  97920. private static _AnisotropicTextureEnabled;
  97921. /**
  97922. * Are anisotropic textures enabled in the application.
  97923. */
  97924. static AnisotropicTextureEnabled: boolean;
  97925. private static _ThicknessTextureEnabled;
  97926. /**
  97927. * Are thickness textures enabled in the application.
  97928. */
  97929. static ThicknessTextureEnabled: boolean;
  97930. }
  97931. }
  97932. declare module BABYLON {
  97933. /** @hidden */
  97934. export var defaultFragmentDeclaration: {
  97935. name: string;
  97936. shader: string;
  97937. };
  97938. }
  97939. declare module BABYLON {
  97940. /** @hidden */
  97941. export var defaultUboDeclaration: {
  97942. name: string;
  97943. shader: string;
  97944. };
  97945. }
  97946. declare module BABYLON {
  97947. /** @hidden */
  97948. export var lightFragmentDeclaration: {
  97949. name: string;
  97950. shader: string;
  97951. };
  97952. }
  97953. declare module BABYLON {
  97954. /** @hidden */
  97955. export var lightUboDeclaration: {
  97956. name: string;
  97957. shader: string;
  97958. };
  97959. }
  97960. declare module BABYLON {
  97961. /** @hidden */
  97962. export var lightsFragmentFunctions: {
  97963. name: string;
  97964. shader: string;
  97965. };
  97966. }
  97967. declare module BABYLON {
  97968. /** @hidden */
  97969. export var shadowsFragmentFunctions: {
  97970. name: string;
  97971. shader: string;
  97972. };
  97973. }
  97974. declare module BABYLON {
  97975. /** @hidden */
  97976. export var fresnelFunction: {
  97977. name: string;
  97978. shader: string;
  97979. };
  97980. }
  97981. declare module BABYLON {
  97982. /** @hidden */
  97983. export var reflectionFunction: {
  97984. name: string;
  97985. shader: string;
  97986. };
  97987. }
  97988. declare module BABYLON {
  97989. /** @hidden */
  97990. export var bumpFragmentFunctions: {
  97991. name: string;
  97992. shader: string;
  97993. };
  97994. }
  97995. declare module BABYLON {
  97996. /** @hidden */
  97997. export var logDepthDeclaration: {
  97998. name: string;
  97999. shader: string;
  98000. };
  98001. }
  98002. declare module BABYLON {
  98003. /** @hidden */
  98004. export var bumpFragment: {
  98005. name: string;
  98006. shader: string;
  98007. };
  98008. }
  98009. declare module BABYLON {
  98010. /** @hidden */
  98011. export var depthPrePass: {
  98012. name: string;
  98013. shader: string;
  98014. };
  98015. }
  98016. declare module BABYLON {
  98017. /** @hidden */
  98018. export var lightFragment: {
  98019. name: string;
  98020. shader: string;
  98021. };
  98022. }
  98023. declare module BABYLON {
  98024. /** @hidden */
  98025. export var logDepthFragment: {
  98026. name: string;
  98027. shader: string;
  98028. };
  98029. }
  98030. declare module BABYLON {
  98031. /** @hidden */
  98032. export var defaultPixelShader: {
  98033. name: string;
  98034. shader: string;
  98035. };
  98036. }
  98037. declare module BABYLON {
  98038. /** @hidden */
  98039. export var defaultVertexDeclaration: {
  98040. name: string;
  98041. shader: string;
  98042. };
  98043. }
  98044. declare module BABYLON {
  98045. /** @hidden */
  98046. export var bumpVertexDeclaration: {
  98047. name: string;
  98048. shader: string;
  98049. };
  98050. }
  98051. declare module BABYLON {
  98052. /** @hidden */
  98053. export var bumpVertex: {
  98054. name: string;
  98055. shader: string;
  98056. };
  98057. }
  98058. declare module BABYLON {
  98059. /** @hidden */
  98060. export var fogVertex: {
  98061. name: string;
  98062. shader: string;
  98063. };
  98064. }
  98065. declare module BABYLON {
  98066. /** @hidden */
  98067. export var shadowsVertex: {
  98068. name: string;
  98069. shader: string;
  98070. };
  98071. }
  98072. declare module BABYLON {
  98073. /** @hidden */
  98074. export var pointCloudVertex: {
  98075. name: string;
  98076. shader: string;
  98077. };
  98078. }
  98079. declare module BABYLON {
  98080. /** @hidden */
  98081. export var logDepthVertex: {
  98082. name: string;
  98083. shader: string;
  98084. };
  98085. }
  98086. declare module BABYLON {
  98087. /** @hidden */
  98088. export var defaultVertexShader: {
  98089. name: string;
  98090. shader: string;
  98091. };
  98092. }
  98093. declare module BABYLON {
  98094. /** @hidden */
  98095. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  98096. MAINUV1: boolean;
  98097. MAINUV2: boolean;
  98098. DIFFUSE: boolean;
  98099. DIFFUSEDIRECTUV: number;
  98100. AMBIENT: boolean;
  98101. AMBIENTDIRECTUV: number;
  98102. OPACITY: boolean;
  98103. OPACITYDIRECTUV: number;
  98104. OPACITYRGB: boolean;
  98105. REFLECTION: boolean;
  98106. EMISSIVE: boolean;
  98107. EMISSIVEDIRECTUV: number;
  98108. SPECULAR: boolean;
  98109. SPECULARDIRECTUV: number;
  98110. BUMP: boolean;
  98111. BUMPDIRECTUV: number;
  98112. PARALLAX: boolean;
  98113. PARALLAXOCCLUSION: boolean;
  98114. SPECULAROVERALPHA: boolean;
  98115. CLIPPLANE: boolean;
  98116. CLIPPLANE2: boolean;
  98117. CLIPPLANE3: boolean;
  98118. CLIPPLANE4: boolean;
  98119. ALPHATEST: boolean;
  98120. DEPTHPREPASS: boolean;
  98121. ALPHAFROMDIFFUSE: boolean;
  98122. POINTSIZE: boolean;
  98123. FOG: boolean;
  98124. SPECULARTERM: boolean;
  98125. DIFFUSEFRESNEL: boolean;
  98126. OPACITYFRESNEL: boolean;
  98127. REFLECTIONFRESNEL: boolean;
  98128. REFRACTIONFRESNEL: boolean;
  98129. EMISSIVEFRESNEL: boolean;
  98130. FRESNEL: boolean;
  98131. NORMAL: boolean;
  98132. UV1: boolean;
  98133. UV2: boolean;
  98134. VERTEXCOLOR: boolean;
  98135. VERTEXALPHA: boolean;
  98136. NUM_BONE_INFLUENCERS: number;
  98137. BonesPerMesh: number;
  98138. BONETEXTURE: boolean;
  98139. INSTANCES: boolean;
  98140. GLOSSINESS: boolean;
  98141. ROUGHNESS: boolean;
  98142. EMISSIVEASILLUMINATION: boolean;
  98143. LINKEMISSIVEWITHDIFFUSE: boolean;
  98144. REFLECTIONFRESNELFROMSPECULAR: boolean;
  98145. LIGHTMAP: boolean;
  98146. LIGHTMAPDIRECTUV: number;
  98147. OBJECTSPACE_NORMALMAP: boolean;
  98148. USELIGHTMAPASSHADOWMAP: boolean;
  98149. REFLECTIONMAP_3D: boolean;
  98150. REFLECTIONMAP_SPHERICAL: boolean;
  98151. REFLECTIONMAP_PLANAR: boolean;
  98152. REFLECTIONMAP_CUBIC: boolean;
  98153. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  98154. REFLECTIONMAP_PROJECTION: boolean;
  98155. REFLECTIONMAP_SKYBOX: boolean;
  98156. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  98157. REFLECTIONMAP_EXPLICIT: boolean;
  98158. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  98159. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  98160. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  98161. INVERTCUBICMAP: boolean;
  98162. LOGARITHMICDEPTH: boolean;
  98163. REFRACTION: boolean;
  98164. REFRACTIONMAP_3D: boolean;
  98165. REFLECTIONOVERALPHA: boolean;
  98166. TWOSIDEDLIGHTING: boolean;
  98167. SHADOWFLOAT: boolean;
  98168. MORPHTARGETS: boolean;
  98169. MORPHTARGETS_NORMAL: boolean;
  98170. MORPHTARGETS_TANGENT: boolean;
  98171. NUM_MORPH_INFLUENCERS: number;
  98172. NONUNIFORMSCALING: boolean;
  98173. PREMULTIPLYALPHA: boolean;
  98174. IMAGEPROCESSING: boolean;
  98175. VIGNETTE: boolean;
  98176. VIGNETTEBLENDMODEMULTIPLY: boolean;
  98177. VIGNETTEBLENDMODEOPAQUE: boolean;
  98178. TONEMAPPING: boolean;
  98179. TONEMAPPING_ACES: boolean;
  98180. CONTRAST: boolean;
  98181. COLORCURVES: boolean;
  98182. COLORGRADING: boolean;
  98183. COLORGRADING3D: boolean;
  98184. SAMPLER3DGREENDEPTH: boolean;
  98185. SAMPLER3DBGRMAP: boolean;
  98186. IMAGEPROCESSINGPOSTPROCESS: boolean;
  98187. MULTIVIEW: boolean;
  98188. /**
  98189. * If the reflection texture on this material is in linear color space
  98190. * @hidden
  98191. */
  98192. IS_REFLECTION_LINEAR: boolean;
  98193. /**
  98194. * If the refraction texture on this material is in linear color space
  98195. * @hidden
  98196. */
  98197. IS_REFRACTION_LINEAR: boolean;
  98198. EXPOSURE: boolean;
  98199. constructor();
  98200. setReflectionMode(modeToEnable: string): void;
  98201. }
  98202. /**
  98203. * This is the default material used in Babylon. It is the best trade off between quality
  98204. * and performances.
  98205. * @see http://doc.babylonjs.com/babylon101/materials
  98206. */
  98207. export class StandardMaterial extends PushMaterial {
  98208. private _diffuseTexture;
  98209. /**
  98210. * The basic texture of the material as viewed under a light.
  98211. */
  98212. diffuseTexture: Nullable<BaseTexture>;
  98213. private _ambientTexture;
  98214. /**
  98215. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  98216. */
  98217. ambientTexture: Nullable<BaseTexture>;
  98218. private _opacityTexture;
  98219. /**
  98220. * Define the transparency of the material from a texture.
  98221. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  98222. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  98223. */
  98224. opacityTexture: Nullable<BaseTexture>;
  98225. private _reflectionTexture;
  98226. /**
  98227. * Define the texture used to display the reflection.
  98228. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98229. */
  98230. reflectionTexture: Nullable<BaseTexture>;
  98231. private _emissiveTexture;
  98232. /**
  98233. * Define texture of the material as if self lit.
  98234. * This will be mixed in the final result even in the absence of light.
  98235. */
  98236. emissiveTexture: Nullable<BaseTexture>;
  98237. private _specularTexture;
  98238. /**
  98239. * Define how the color and intensity of the highlight given by the light in the material.
  98240. */
  98241. specularTexture: Nullable<BaseTexture>;
  98242. private _bumpTexture;
  98243. /**
  98244. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  98245. * 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.
  98246. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  98247. */
  98248. bumpTexture: Nullable<BaseTexture>;
  98249. private _lightmapTexture;
  98250. /**
  98251. * Complex lighting can be computationally expensive to compute at runtime.
  98252. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  98253. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  98254. */
  98255. lightmapTexture: Nullable<BaseTexture>;
  98256. private _refractionTexture;
  98257. /**
  98258. * Define the texture used to display the refraction.
  98259. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98260. */
  98261. refractionTexture: Nullable<BaseTexture>;
  98262. /**
  98263. * The color of the material lit by the environmental background lighting.
  98264. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  98265. */
  98266. ambientColor: Color3;
  98267. /**
  98268. * The basic color of the material as viewed under a light.
  98269. */
  98270. diffuseColor: Color3;
  98271. /**
  98272. * Define how the color and intensity of the highlight given by the light in the material.
  98273. */
  98274. specularColor: Color3;
  98275. /**
  98276. * Define the color of the material as if self lit.
  98277. * This will be mixed in the final result even in the absence of light.
  98278. */
  98279. emissiveColor: Color3;
  98280. /**
  98281. * Defines how sharp are the highlights in the material.
  98282. * The bigger the value the sharper giving a more glossy feeling to the result.
  98283. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  98284. */
  98285. specularPower: number;
  98286. private _useAlphaFromDiffuseTexture;
  98287. /**
  98288. * Does the transparency come from the diffuse texture alpha channel.
  98289. */
  98290. useAlphaFromDiffuseTexture: boolean;
  98291. private _useEmissiveAsIllumination;
  98292. /**
  98293. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  98294. */
  98295. useEmissiveAsIllumination: boolean;
  98296. private _linkEmissiveWithDiffuse;
  98297. /**
  98298. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  98299. * the emissive level when the final color is close to one.
  98300. */
  98301. linkEmissiveWithDiffuse: boolean;
  98302. private _useSpecularOverAlpha;
  98303. /**
  98304. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  98305. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  98306. */
  98307. useSpecularOverAlpha: boolean;
  98308. private _useReflectionOverAlpha;
  98309. /**
  98310. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  98311. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  98312. */
  98313. useReflectionOverAlpha: boolean;
  98314. private _disableLighting;
  98315. /**
  98316. * Does lights from the scene impacts this material.
  98317. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  98318. */
  98319. disableLighting: boolean;
  98320. private _useObjectSpaceNormalMap;
  98321. /**
  98322. * Allows using an object space normal map (instead of tangent space).
  98323. */
  98324. useObjectSpaceNormalMap: boolean;
  98325. private _useParallax;
  98326. /**
  98327. * Is parallax enabled or not.
  98328. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98329. */
  98330. useParallax: boolean;
  98331. private _useParallaxOcclusion;
  98332. /**
  98333. * Is parallax occlusion enabled or not.
  98334. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  98335. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98336. */
  98337. useParallaxOcclusion: boolean;
  98338. /**
  98339. * 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.
  98340. */
  98341. parallaxScaleBias: number;
  98342. private _roughness;
  98343. /**
  98344. * Helps to define how blurry the reflections should appears in the material.
  98345. */
  98346. roughness: number;
  98347. /**
  98348. * In case of refraction, define the value of the indice of refraction.
  98349. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98350. */
  98351. indexOfRefraction: number;
  98352. /**
  98353. * Invert the refraction texture alongside the y axis.
  98354. * It can be useful with procedural textures or probe for instance.
  98355. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98356. */
  98357. invertRefractionY: boolean;
  98358. /**
  98359. * Defines the alpha limits in alpha test mode.
  98360. */
  98361. alphaCutOff: number;
  98362. private _useLightmapAsShadowmap;
  98363. /**
  98364. * In case of light mapping, define whether the map contains light or shadow informations.
  98365. */
  98366. useLightmapAsShadowmap: boolean;
  98367. private _diffuseFresnelParameters;
  98368. /**
  98369. * Define the diffuse fresnel parameters of the material.
  98370. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98371. */
  98372. diffuseFresnelParameters: FresnelParameters;
  98373. private _opacityFresnelParameters;
  98374. /**
  98375. * Define the opacity fresnel parameters of the material.
  98376. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98377. */
  98378. opacityFresnelParameters: FresnelParameters;
  98379. private _reflectionFresnelParameters;
  98380. /**
  98381. * Define the reflection fresnel parameters of the material.
  98382. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98383. */
  98384. reflectionFresnelParameters: FresnelParameters;
  98385. private _refractionFresnelParameters;
  98386. /**
  98387. * Define the refraction fresnel parameters of the material.
  98388. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98389. */
  98390. refractionFresnelParameters: FresnelParameters;
  98391. private _emissiveFresnelParameters;
  98392. /**
  98393. * Define the emissive fresnel parameters of the material.
  98394. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98395. */
  98396. emissiveFresnelParameters: FresnelParameters;
  98397. private _useReflectionFresnelFromSpecular;
  98398. /**
  98399. * If true automatically deducts the fresnels values from the material specularity.
  98400. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98401. */
  98402. useReflectionFresnelFromSpecular: boolean;
  98403. private _useGlossinessFromSpecularMapAlpha;
  98404. /**
  98405. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  98406. */
  98407. useGlossinessFromSpecularMapAlpha: boolean;
  98408. private _maxSimultaneousLights;
  98409. /**
  98410. * Defines the maximum number of lights that can be used in the material
  98411. */
  98412. maxSimultaneousLights: number;
  98413. private _invertNormalMapX;
  98414. /**
  98415. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  98416. */
  98417. invertNormalMapX: boolean;
  98418. private _invertNormalMapY;
  98419. /**
  98420. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  98421. */
  98422. invertNormalMapY: boolean;
  98423. private _twoSidedLighting;
  98424. /**
  98425. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  98426. */
  98427. twoSidedLighting: boolean;
  98428. /**
  98429. * Default configuration related to image processing available in the standard Material.
  98430. */
  98431. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98432. /**
  98433. * Gets the image processing configuration used either in this material.
  98434. */
  98435. /**
  98436. * Sets the Default image processing configuration used either in the this material.
  98437. *
  98438. * If sets to null, the scene one is in use.
  98439. */
  98440. imageProcessingConfiguration: ImageProcessingConfiguration;
  98441. /**
  98442. * Keep track of the image processing observer to allow dispose and replace.
  98443. */
  98444. private _imageProcessingObserver;
  98445. /**
  98446. * Attaches a new image processing configuration to the Standard Material.
  98447. * @param configuration
  98448. */
  98449. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98450. /**
  98451. * Gets wether the color curves effect is enabled.
  98452. */
  98453. /**
  98454. * Sets wether the color curves effect is enabled.
  98455. */
  98456. cameraColorCurvesEnabled: boolean;
  98457. /**
  98458. * Gets wether the color grading effect is enabled.
  98459. */
  98460. /**
  98461. * Gets wether the color grading effect is enabled.
  98462. */
  98463. cameraColorGradingEnabled: boolean;
  98464. /**
  98465. * Gets wether tonemapping is enabled or not.
  98466. */
  98467. /**
  98468. * Sets wether tonemapping is enabled or not
  98469. */
  98470. cameraToneMappingEnabled: boolean;
  98471. /**
  98472. * The camera exposure used on this material.
  98473. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98474. * This corresponds to a photographic exposure.
  98475. */
  98476. /**
  98477. * The camera exposure used on this material.
  98478. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98479. * This corresponds to a photographic exposure.
  98480. */
  98481. cameraExposure: number;
  98482. /**
  98483. * Gets The camera contrast used on this material.
  98484. */
  98485. /**
  98486. * Sets The camera contrast used on this material.
  98487. */
  98488. cameraContrast: number;
  98489. /**
  98490. * Gets the Color Grading 2D Lookup Texture.
  98491. */
  98492. /**
  98493. * Sets the Color Grading 2D Lookup Texture.
  98494. */
  98495. cameraColorGradingTexture: Nullable<BaseTexture>;
  98496. /**
  98497. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98498. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98499. * 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;
  98500. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98501. */
  98502. /**
  98503. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98504. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98505. * 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;
  98506. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98507. */
  98508. cameraColorCurves: Nullable<ColorCurves>;
  98509. /**
  98510. * Custom callback helping to override the default shader used in the material.
  98511. */
  98512. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  98513. protected _renderTargets: SmartArray<RenderTargetTexture>;
  98514. protected _worldViewProjectionMatrix: Matrix;
  98515. protected _globalAmbientColor: Color3;
  98516. protected _useLogarithmicDepth: boolean;
  98517. /**
  98518. * Instantiates a new standard material.
  98519. * This is the default material used in Babylon. It is the best trade off between quality
  98520. * and performances.
  98521. * @see http://doc.babylonjs.com/babylon101/materials
  98522. * @param name Define the name of the material in the scene
  98523. * @param scene Define the scene the material belong to
  98524. */
  98525. constructor(name: string, scene: Scene);
  98526. /**
  98527. * Gets a boolean indicating that current material needs to register RTT
  98528. */
  98529. readonly hasRenderTargetTextures: boolean;
  98530. /**
  98531. * Gets the current class name of the material e.g. "StandardMaterial"
  98532. * Mainly use in serialization.
  98533. * @returns the class name
  98534. */
  98535. getClassName(): string;
  98536. /**
  98537. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  98538. * You can try switching to logarithmic depth.
  98539. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  98540. */
  98541. useLogarithmicDepth: boolean;
  98542. /**
  98543. * Specifies if the material will require alpha blending
  98544. * @returns a boolean specifying if alpha blending is needed
  98545. */
  98546. needAlphaBlending(): boolean;
  98547. /**
  98548. * Specifies if this material should be rendered in alpha test mode
  98549. * @returns a boolean specifying if an alpha test is needed.
  98550. */
  98551. needAlphaTesting(): boolean;
  98552. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  98553. /**
  98554. * Get the texture used for alpha test purpose.
  98555. * @returns the diffuse texture in case of the standard material.
  98556. */
  98557. getAlphaTestTexture(): Nullable<BaseTexture>;
  98558. /**
  98559. * Get if the submesh is ready to be used and all its information available.
  98560. * Child classes can use it to update shaders
  98561. * @param mesh defines the mesh to check
  98562. * @param subMesh defines which submesh to check
  98563. * @param useInstances specifies that instances should be used
  98564. * @returns a boolean indicating that the submesh is ready or not
  98565. */
  98566. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98567. /**
  98568. * Builds the material UBO layouts.
  98569. * Used internally during the effect preparation.
  98570. */
  98571. buildUniformLayout(): void;
  98572. /**
  98573. * Unbinds the material from the mesh
  98574. */
  98575. unbind(): void;
  98576. /**
  98577. * Binds the submesh to this material by preparing the effect and shader to draw
  98578. * @param world defines the world transformation matrix
  98579. * @param mesh defines the mesh containing the submesh
  98580. * @param subMesh defines the submesh to bind the material to
  98581. */
  98582. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98583. /**
  98584. * Get the list of animatables in the material.
  98585. * @returns the list of animatables object used in the material
  98586. */
  98587. getAnimatables(): IAnimatable[];
  98588. /**
  98589. * Gets the active textures from the material
  98590. * @returns an array of textures
  98591. */
  98592. getActiveTextures(): BaseTexture[];
  98593. /**
  98594. * Specifies if the material uses a texture
  98595. * @param texture defines the texture to check against the material
  98596. * @returns a boolean specifying if the material uses the texture
  98597. */
  98598. hasTexture(texture: BaseTexture): boolean;
  98599. /**
  98600. * Disposes the material
  98601. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  98602. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  98603. */
  98604. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  98605. /**
  98606. * Makes a duplicate of the material, and gives it a new name
  98607. * @param name defines the new name for the duplicated material
  98608. * @returns the cloned material
  98609. */
  98610. clone(name: string): StandardMaterial;
  98611. /**
  98612. * Serializes this material in a JSON representation
  98613. * @returns the serialized material object
  98614. */
  98615. serialize(): any;
  98616. /**
  98617. * Creates a standard material from parsed material data
  98618. * @param source defines the JSON representation of the material
  98619. * @param scene defines the hosting scene
  98620. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98621. * @returns a new standard material
  98622. */
  98623. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  98624. /**
  98625. * Are diffuse textures enabled in the application.
  98626. */
  98627. static DiffuseTextureEnabled: boolean;
  98628. /**
  98629. * Are ambient textures enabled in the application.
  98630. */
  98631. static AmbientTextureEnabled: boolean;
  98632. /**
  98633. * Are opacity textures enabled in the application.
  98634. */
  98635. static OpacityTextureEnabled: boolean;
  98636. /**
  98637. * Are reflection textures enabled in the application.
  98638. */
  98639. static ReflectionTextureEnabled: boolean;
  98640. /**
  98641. * Are emissive textures enabled in the application.
  98642. */
  98643. static EmissiveTextureEnabled: boolean;
  98644. /**
  98645. * Are specular textures enabled in the application.
  98646. */
  98647. static SpecularTextureEnabled: boolean;
  98648. /**
  98649. * Are bump textures enabled in the application.
  98650. */
  98651. static BumpTextureEnabled: boolean;
  98652. /**
  98653. * Are lightmap textures enabled in the application.
  98654. */
  98655. static LightmapTextureEnabled: boolean;
  98656. /**
  98657. * Are refraction textures enabled in the application.
  98658. */
  98659. static RefractionTextureEnabled: boolean;
  98660. /**
  98661. * Are color grading textures enabled in the application.
  98662. */
  98663. static ColorGradingTextureEnabled: boolean;
  98664. /**
  98665. * Are fresnels enabled in the application.
  98666. */
  98667. static FresnelEnabled: boolean;
  98668. }
  98669. }
  98670. declare module BABYLON {
  98671. /**
  98672. * A class extending Texture allowing drawing on a texture
  98673. * @see http://doc.babylonjs.com/how_to/dynamictexture
  98674. */
  98675. export class DynamicTexture extends Texture {
  98676. private _generateMipMaps;
  98677. private _canvas;
  98678. private _context;
  98679. private _engine;
  98680. /**
  98681. * Creates a DynamicTexture
  98682. * @param name defines the name of the texture
  98683. * @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
  98684. * @param scene defines the scene where you want the texture
  98685. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  98686. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  98687. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  98688. */
  98689. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  98690. /**
  98691. * Get the current class name of the texture useful for serialization or dynamic coding.
  98692. * @returns "DynamicTexture"
  98693. */
  98694. getClassName(): string;
  98695. /**
  98696. * Gets the current state of canRescale
  98697. */
  98698. readonly canRescale: boolean;
  98699. private _recreate;
  98700. /**
  98701. * Scales the texture
  98702. * @param ratio the scale factor to apply to both width and height
  98703. */
  98704. scale(ratio: number): void;
  98705. /**
  98706. * Resizes the texture
  98707. * @param width the new width
  98708. * @param height the new height
  98709. */
  98710. scaleTo(width: number, height: number): void;
  98711. /**
  98712. * Gets the context of the canvas used by the texture
  98713. * @returns the canvas context of the dynamic texture
  98714. */
  98715. getContext(): CanvasRenderingContext2D;
  98716. /**
  98717. * Clears the texture
  98718. */
  98719. clear(): void;
  98720. /**
  98721. * Updates the texture
  98722. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  98723. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  98724. */
  98725. update(invertY?: boolean, premulAlpha?: boolean): void;
  98726. /**
  98727. * Draws text onto the texture
  98728. * @param text defines the text to be drawn
  98729. * @param x defines the placement of the text from the left
  98730. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  98731. * @param font defines the font to be used with font-style, font-size, font-name
  98732. * @param color defines the color used for the text
  98733. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  98734. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  98735. * @param update defines whether texture is immediately update (default is true)
  98736. */
  98737. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  98738. /**
  98739. * Clones the texture
  98740. * @returns the clone of the texture.
  98741. */
  98742. clone(): DynamicTexture;
  98743. /**
  98744. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  98745. * @returns a serialized dynamic texture object
  98746. */
  98747. serialize(): any;
  98748. /** @hidden */
  98749. _rebuild(): void;
  98750. }
  98751. }
  98752. declare module BABYLON {
  98753. /** @hidden */
  98754. export var imageProcessingPixelShader: {
  98755. name: string;
  98756. shader: string;
  98757. };
  98758. }
  98759. declare module BABYLON {
  98760. /**
  98761. * ImageProcessingPostProcess
  98762. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  98763. */
  98764. export class ImageProcessingPostProcess extends PostProcess {
  98765. /**
  98766. * Default configuration related to image processing available in the PBR Material.
  98767. */
  98768. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98769. /**
  98770. * Gets the image processing configuration used either in this material.
  98771. */
  98772. /**
  98773. * Sets the Default image processing configuration used either in the this material.
  98774. *
  98775. * If sets to null, the scene one is in use.
  98776. */
  98777. imageProcessingConfiguration: ImageProcessingConfiguration;
  98778. /**
  98779. * Keep track of the image processing observer to allow dispose and replace.
  98780. */
  98781. private _imageProcessingObserver;
  98782. /**
  98783. * Attaches a new image processing configuration to the PBR Material.
  98784. * @param configuration
  98785. */
  98786. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  98787. /**
  98788. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  98789. */
  98790. /**
  98791. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  98792. */
  98793. colorCurves: Nullable<ColorCurves>;
  98794. /**
  98795. * Gets wether the color curves effect is enabled.
  98796. */
  98797. /**
  98798. * Sets wether the color curves effect is enabled.
  98799. */
  98800. colorCurvesEnabled: boolean;
  98801. /**
  98802. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  98803. */
  98804. /**
  98805. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  98806. */
  98807. colorGradingTexture: Nullable<BaseTexture>;
  98808. /**
  98809. * Gets wether the color grading effect is enabled.
  98810. */
  98811. /**
  98812. * Gets wether the color grading effect is enabled.
  98813. */
  98814. colorGradingEnabled: boolean;
  98815. /**
  98816. * Gets exposure used in the effect.
  98817. */
  98818. /**
  98819. * Sets exposure used in the effect.
  98820. */
  98821. exposure: number;
  98822. /**
  98823. * Gets wether tonemapping is enabled or not.
  98824. */
  98825. /**
  98826. * Sets wether tonemapping is enabled or not
  98827. */
  98828. toneMappingEnabled: boolean;
  98829. /**
  98830. * Gets the type of tone mapping effect.
  98831. */
  98832. /**
  98833. * Sets the type of tone mapping effect.
  98834. */
  98835. toneMappingType: number;
  98836. /**
  98837. * Gets contrast used in the effect.
  98838. */
  98839. /**
  98840. * Sets contrast used in the effect.
  98841. */
  98842. contrast: number;
  98843. /**
  98844. * Gets Vignette stretch size.
  98845. */
  98846. /**
  98847. * Sets Vignette stretch size.
  98848. */
  98849. vignetteStretch: number;
  98850. /**
  98851. * Gets Vignette centre X Offset.
  98852. */
  98853. /**
  98854. * Sets Vignette centre X Offset.
  98855. */
  98856. vignetteCentreX: number;
  98857. /**
  98858. * Gets Vignette centre Y Offset.
  98859. */
  98860. /**
  98861. * Sets Vignette centre Y Offset.
  98862. */
  98863. vignetteCentreY: number;
  98864. /**
  98865. * Gets Vignette weight or intensity of the vignette effect.
  98866. */
  98867. /**
  98868. * Sets Vignette weight or intensity of the vignette effect.
  98869. */
  98870. vignetteWeight: number;
  98871. /**
  98872. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  98873. * if vignetteEnabled is set to true.
  98874. */
  98875. /**
  98876. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  98877. * if vignetteEnabled is set to true.
  98878. */
  98879. vignetteColor: Color4;
  98880. /**
  98881. * Gets Camera field of view used by the Vignette effect.
  98882. */
  98883. /**
  98884. * Sets Camera field of view used by the Vignette effect.
  98885. */
  98886. vignetteCameraFov: number;
  98887. /**
  98888. * Gets the vignette blend mode allowing different kind of effect.
  98889. */
  98890. /**
  98891. * Sets the vignette blend mode allowing different kind of effect.
  98892. */
  98893. vignetteBlendMode: number;
  98894. /**
  98895. * Gets wether the vignette effect is enabled.
  98896. */
  98897. /**
  98898. * Sets wether the vignette effect is enabled.
  98899. */
  98900. vignetteEnabled: boolean;
  98901. private _fromLinearSpace;
  98902. /**
  98903. * Gets wether the input of the processing is in Gamma or Linear Space.
  98904. */
  98905. /**
  98906. * Sets wether the input of the processing is in Gamma or Linear Space.
  98907. */
  98908. fromLinearSpace: boolean;
  98909. /**
  98910. * Defines cache preventing GC.
  98911. */
  98912. private _defines;
  98913. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  98914. /**
  98915. * "ImageProcessingPostProcess"
  98916. * @returns "ImageProcessingPostProcess"
  98917. */
  98918. getClassName(): string;
  98919. protected _updateParameters(): void;
  98920. dispose(camera?: Camera): void;
  98921. }
  98922. }
  98923. declare module BABYLON {
  98924. /**
  98925. * Class containing static functions to help procedurally build meshes
  98926. */
  98927. export class GroundBuilder {
  98928. /**
  98929. * Creates a ground mesh
  98930. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  98931. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  98932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98933. * @param name defines the name of the mesh
  98934. * @param options defines the options used to create the mesh
  98935. * @param scene defines the hosting scene
  98936. * @returns the ground mesh
  98937. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  98938. */
  98939. static CreateGround(name: string, options: {
  98940. width?: number;
  98941. height?: number;
  98942. subdivisions?: number;
  98943. subdivisionsX?: number;
  98944. subdivisionsY?: number;
  98945. updatable?: boolean;
  98946. }, scene: any): Mesh;
  98947. /**
  98948. * Creates a tiled ground mesh
  98949. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  98950. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  98951. * * 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
  98952. * * 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
  98953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98954. * @param name defines the name of the mesh
  98955. * @param options defines the options used to create the mesh
  98956. * @param scene defines the hosting scene
  98957. * @returns the tiled ground mesh
  98958. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  98959. */
  98960. static CreateTiledGround(name: string, options: {
  98961. xmin: number;
  98962. zmin: number;
  98963. xmax: number;
  98964. zmax: number;
  98965. subdivisions?: {
  98966. w: number;
  98967. h: number;
  98968. };
  98969. precision?: {
  98970. w: number;
  98971. h: number;
  98972. };
  98973. updatable?: boolean;
  98974. }, scene?: Nullable<Scene>): Mesh;
  98975. /**
  98976. * Creates a ground mesh from a height map
  98977. * * The parameter `url` sets the URL of the height map image resource.
  98978. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  98979. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  98980. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  98981. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  98982. * * 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.
  98983. * * 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).
  98984. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98986. * @param name defines the name of the mesh
  98987. * @param url defines the url to the height map
  98988. * @param options defines the options used to create the mesh
  98989. * @param scene defines the hosting scene
  98990. * @returns the ground mesh
  98991. * @see https://doc.babylonjs.com/babylon101/height_map
  98992. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  98993. */
  98994. static CreateGroundFromHeightMap(name: string, url: string, options: {
  98995. width?: number;
  98996. height?: number;
  98997. subdivisions?: number;
  98998. minHeight?: number;
  98999. maxHeight?: number;
  99000. colorFilter?: Color3;
  99001. alphaFilter?: number;
  99002. updatable?: boolean;
  99003. onReady?: (mesh: GroundMesh) => void;
  99004. }, scene?: Nullable<Scene>): GroundMesh;
  99005. }
  99006. }
  99007. declare module BABYLON {
  99008. /**
  99009. * Class containing static functions to help procedurally build meshes
  99010. */
  99011. export class TorusBuilder {
  99012. /**
  99013. * Creates a torus mesh
  99014. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  99015. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  99016. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  99017. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99018. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99020. * @param name defines the name of the mesh
  99021. * @param options defines the options used to create the mesh
  99022. * @param scene defines the hosting scene
  99023. * @returns the torus mesh
  99024. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  99025. */
  99026. static CreateTorus(name: string, options: {
  99027. diameter?: number;
  99028. thickness?: number;
  99029. tessellation?: number;
  99030. updatable?: boolean;
  99031. sideOrientation?: number;
  99032. frontUVs?: Vector4;
  99033. backUVs?: Vector4;
  99034. }, scene: any): Mesh;
  99035. }
  99036. }
  99037. declare module BABYLON {
  99038. /**
  99039. * Class containing static functions to help procedurally build meshes
  99040. */
  99041. export class CylinderBuilder {
  99042. /**
  99043. * Creates a cylinder or a cone mesh
  99044. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  99045. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  99046. * * 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.
  99047. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  99048. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  99049. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  99050. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  99051. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  99052. * * 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).
  99053. * * 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
  99054. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  99055. * * 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
  99056. * * 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.
  99057. * * If `enclose` is false, a ring surface is one element.
  99058. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  99059. * * 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
  99060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99061. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99063. * @param name defines the name of the mesh
  99064. * @param options defines the options used to create the mesh
  99065. * @param scene defines the hosting scene
  99066. * @returns the cylinder mesh
  99067. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  99068. */
  99069. static CreateCylinder(name: string, options: {
  99070. height?: number;
  99071. diameterTop?: number;
  99072. diameterBottom?: number;
  99073. diameter?: number;
  99074. tessellation?: number;
  99075. subdivisions?: number;
  99076. arc?: number;
  99077. faceColors?: Color4[];
  99078. faceUV?: Vector4[];
  99079. updatable?: boolean;
  99080. hasRings?: boolean;
  99081. enclose?: boolean;
  99082. sideOrientation?: number;
  99083. frontUVs?: Vector4;
  99084. backUVs?: Vector4;
  99085. }, scene: any): Mesh;
  99086. }
  99087. }
  99088. declare module BABYLON {
  99089. /**
  99090. * Manager for handling gamepads
  99091. */
  99092. export class GamepadManager {
  99093. private _scene?;
  99094. private _babylonGamepads;
  99095. private _oneGamepadConnected;
  99096. /** @hidden */
  99097. _isMonitoring: boolean;
  99098. private _gamepadEventSupported;
  99099. private _gamepadSupport;
  99100. /**
  99101. * observable to be triggered when the gamepad controller has been connected
  99102. */
  99103. onGamepadConnectedObservable: Observable<Gamepad>;
  99104. /**
  99105. * observable to be triggered when the gamepad controller has been disconnected
  99106. */
  99107. onGamepadDisconnectedObservable: Observable<Gamepad>;
  99108. private _onGamepadConnectedEvent;
  99109. private _onGamepadDisconnectedEvent;
  99110. /**
  99111. * Initializes the gamepad manager
  99112. * @param _scene BabylonJS scene
  99113. */
  99114. constructor(_scene?: Scene | undefined);
  99115. /**
  99116. * The gamepads in the game pad manager
  99117. */
  99118. readonly gamepads: Gamepad[];
  99119. /**
  99120. * Get the gamepad controllers based on type
  99121. * @param type The type of gamepad controller
  99122. * @returns Nullable gamepad
  99123. */
  99124. getGamepadByType(type?: number): Nullable<Gamepad>;
  99125. /**
  99126. * Disposes the gamepad manager
  99127. */
  99128. dispose(): void;
  99129. private _addNewGamepad;
  99130. private _startMonitoringGamepads;
  99131. private _stopMonitoringGamepads;
  99132. /** @hidden */
  99133. _checkGamepadsStatus(): void;
  99134. private _updateGamepadObjects;
  99135. }
  99136. }
  99137. declare module BABYLON {
  99138. interface Scene {
  99139. /** @hidden */
  99140. _gamepadManager: Nullable<GamepadManager>;
  99141. /**
  99142. * Gets the gamepad manager associated with the scene
  99143. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  99144. */
  99145. gamepadManager: GamepadManager;
  99146. }
  99147. /**
  99148. * Interface representing a free camera inputs manager
  99149. */
  99150. interface FreeCameraInputsManager {
  99151. /**
  99152. * Adds gamepad input support to the FreeCameraInputsManager.
  99153. * @returns the FreeCameraInputsManager
  99154. */
  99155. addGamepad(): FreeCameraInputsManager;
  99156. }
  99157. /**
  99158. * Interface representing an arc rotate camera inputs manager
  99159. */
  99160. interface ArcRotateCameraInputsManager {
  99161. /**
  99162. * Adds gamepad input support to the ArcRotateCamera InputManager.
  99163. * @returns the camera inputs manager
  99164. */
  99165. addGamepad(): ArcRotateCameraInputsManager;
  99166. }
  99167. /**
  99168. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  99169. */
  99170. export class GamepadSystemSceneComponent implements ISceneComponent {
  99171. /**
  99172. * The component name helpfull to identify the component in the list of scene components.
  99173. */
  99174. readonly name: string;
  99175. /**
  99176. * The scene the component belongs to.
  99177. */
  99178. scene: Scene;
  99179. /**
  99180. * Creates a new instance of the component for the given scene
  99181. * @param scene Defines the scene to register the component in
  99182. */
  99183. constructor(scene: Scene);
  99184. /**
  99185. * Registers the component in a given scene
  99186. */
  99187. register(): void;
  99188. /**
  99189. * Rebuilds the elements related to this component in case of
  99190. * context lost for instance.
  99191. */
  99192. rebuild(): void;
  99193. /**
  99194. * Disposes the component and the associated ressources
  99195. */
  99196. dispose(): void;
  99197. private _beforeCameraUpdate;
  99198. }
  99199. }
  99200. declare module BABYLON {
  99201. /**
  99202. * Options to modify the vr teleportation behavior.
  99203. */
  99204. export interface VRTeleportationOptions {
  99205. /**
  99206. * The name of the mesh which should be used as the teleportation floor. (default: null)
  99207. */
  99208. floorMeshName?: string;
  99209. /**
  99210. * A list of meshes to be used as the teleportation floor. (default: empty)
  99211. */
  99212. floorMeshes?: Mesh[];
  99213. }
  99214. /**
  99215. * Options to modify the vr experience helper's behavior.
  99216. */
  99217. export interface VRExperienceHelperOptions extends WebVROptions {
  99218. /**
  99219. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  99220. */
  99221. createDeviceOrientationCamera?: boolean;
  99222. /**
  99223. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  99224. */
  99225. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  99226. /**
  99227. * Uses the main button on the controller to toggle the laser casted. (default: true)
  99228. */
  99229. laserToggle?: boolean;
  99230. /**
  99231. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  99232. */
  99233. floorMeshes?: Mesh[];
  99234. /**
  99235. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  99236. */
  99237. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  99238. }
  99239. /**
  99240. * Event containing information after VR has been entered
  99241. */
  99242. export class OnAfterEnteringVRObservableEvent {
  99243. /**
  99244. * If entering vr was successful
  99245. */
  99246. success: boolean;
  99247. }
  99248. /**
  99249. * Helps to quickly add VR support to an existing scene.
  99250. * See http://doc.babylonjs.com/how_to/webvr_helper
  99251. */
  99252. export class VRExperienceHelper {
  99253. /** Options to modify the vr experience helper's behavior. */
  99254. webVROptions: VRExperienceHelperOptions;
  99255. private _scene;
  99256. private _position;
  99257. private _btnVR;
  99258. private _btnVRDisplayed;
  99259. private _webVRsupported;
  99260. private _webVRready;
  99261. private _webVRrequesting;
  99262. private _webVRpresenting;
  99263. private _hasEnteredVR;
  99264. private _fullscreenVRpresenting;
  99265. private _canvas;
  99266. private _webVRCamera;
  99267. private _vrDeviceOrientationCamera;
  99268. private _deviceOrientationCamera;
  99269. private _existingCamera;
  99270. private _onKeyDown;
  99271. private _onVrDisplayPresentChange;
  99272. private _onVRDisplayChanged;
  99273. private _onVRRequestPresentStart;
  99274. private _onVRRequestPresentComplete;
  99275. /**
  99276. * Observable raised right before entering VR.
  99277. */
  99278. onEnteringVRObservable: Observable<VRExperienceHelper>;
  99279. /**
  99280. * Observable raised when entering VR has completed.
  99281. */
  99282. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  99283. /**
  99284. * Observable raised when exiting VR.
  99285. */
  99286. onExitingVRObservable: Observable<VRExperienceHelper>;
  99287. /**
  99288. * Observable raised when controller mesh is loaded.
  99289. */
  99290. onControllerMeshLoadedObservable: Observable<WebVRController>;
  99291. /** Return this.onEnteringVRObservable
  99292. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  99293. */
  99294. readonly onEnteringVR: Observable<VRExperienceHelper>;
  99295. /** Return this.onExitingVRObservable
  99296. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  99297. */
  99298. readonly onExitingVR: Observable<VRExperienceHelper>;
  99299. /** Return this.onControllerMeshLoadedObservable
  99300. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  99301. */
  99302. readonly onControllerMeshLoaded: Observable<WebVRController>;
  99303. private _rayLength;
  99304. private _useCustomVRButton;
  99305. private _teleportationRequested;
  99306. private _teleportActive;
  99307. private _floorMeshName;
  99308. private _floorMeshesCollection;
  99309. private _rotationAllowed;
  99310. private _teleportBackwardsVector;
  99311. private _teleportationTarget;
  99312. private _isDefaultTeleportationTarget;
  99313. private _postProcessMove;
  99314. private _teleportationFillColor;
  99315. private _teleportationBorderColor;
  99316. private _rotationAngle;
  99317. private _haloCenter;
  99318. private _cameraGazer;
  99319. private _padSensibilityUp;
  99320. private _padSensibilityDown;
  99321. private _leftController;
  99322. private _rightController;
  99323. /**
  99324. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  99325. */
  99326. onNewMeshSelected: Observable<AbstractMesh>;
  99327. /**
  99328. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  99329. */
  99330. onNewMeshPicked: Observable<PickingInfo>;
  99331. private _circleEase;
  99332. /**
  99333. * Observable raised before camera teleportation
  99334. */
  99335. onBeforeCameraTeleport: Observable<Vector3>;
  99336. /**
  99337. * Observable raised after camera teleportation
  99338. */
  99339. onAfterCameraTeleport: Observable<Vector3>;
  99340. /**
  99341. * Observable raised when current selected mesh gets unselected
  99342. */
  99343. onSelectedMeshUnselected: Observable<AbstractMesh>;
  99344. private _raySelectionPredicate;
  99345. /**
  99346. * To be optionaly changed by user to define custom ray selection
  99347. */
  99348. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  99349. /**
  99350. * To be optionaly changed by user to define custom selection logic (after ray selection)
  99351. */
  99352. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  99353. /**
  99354. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  99355. */
  99356. teleportationEnabled: boolean;
  99357. private _defaultHeight;
  99358. private _teleportationInitialized;
  99359. private _interactionsEnabled;
  99360. private _interactionsRequested;
  99361. private _displayGaze;
  99362. private _displayLaserPointer;
  99363. /**
  99364. * The mesh used to display where the user is going to teleport.
  99365. */
  99366. /**
  99367. * Sets the mesh to be used to display where the user is going to teleport.
  99368. */
  99369. teleportationTarget: Mesh;
  99370. /**
  99371. * 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
  99372. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  99373. * See http://doc.babylonjs.com/resources/baking_transformations
  99374. */
  99375. gazeTrackerMesh: Mesh;
  99376. /**
  99377. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  99378. */
  99379. updateGazeTrackerScale: boolean;
  99380. /**
  99381. * If the gaze trackers color should be updated when selecting meshes
  99382. */
  99383. updateGazeTrackerColor: boolean;
  99384. /**
  99385. * The gaze tracking mesh corresponding to the left controller
  99386. */
  99387. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  99388. /**
  99389. * The gaze tracking mesh corresponding to the right controller
  99390. */
  99391. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  99392. /**
  99393. * If the ray of the gaze should be displayed.
  99394. */
  99395. /**
  99396. * Sets if the ray of the gaze should be displayed.
  99397. */
  99398. displayGaze: boolean;
  99399. /**
  99400. * If the ray of the LaserPointer should be displayed.
  99401. */
  99402. /**
  99403. * Sets if the ray of the LaserPointer should be displayed.
  99404. */
  99405. displayLaserPointer: boolean;
  99406. /**
  99407. * The deviceOrientationCamera used as the camera when not in VR.
  99408. */
  99409. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  99410. /**
  99411. * Based on the current WebVR support, returns the current VR camera used.
  99412. */
  99413. readonly currentVRCamera: Nullable<Camera>;
  99414. /**
  99415. * The webVRCamera which is used when in VR.
  99416. */
  99417. readonly webVRCamera: WebVRFreeCamera;
  99418. /**
  99419. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  99420. */
  99421. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  99422. private readonly _teleportationRequestInitiated;
  99423. /**
  99424. * Defines wether or not Pointer lock should be requested when switching to
  99425. * full screen.
  99426. */
  99427. requestPointerLockOnFullScreen: boolean;
  99428. /**
  99429. * Instantiates a VRExperienceHelper.
  99430. * Helps to quickly add VR support to an existing scene.
  99431. * @param scene The scene the VRExperienceHelper belongs to.
  99432. * @param webVROptions Options to modify the vr experience helper's behavior.
  99433. */
  99434. constructor(scene: Scene,
  99435. /** Options to modify the vr experience helper's behavior. */
  99436. webVROptions?: VRExperienceHelperOptions);
  99437. private _onDefaultMeshLoaded;
  99438. private _onResize;
  99439. private _onFullscreenChange;
  99440. /**
  99441. * Gets a value indicating if we are currently in VR mode.
  99442. */
  99443. readonly isInVRMode: boolean;
  99444. private onVrDisplayPresentChange;
  99445. private onVRDisplayChanged;
  99446. private moveButtonToBottomRight;
  99447. private displayVRButton;
  99448. private updateButtonVisibility;
  99449. private _cachedAngularSensibility;
  99450. /**
  99451. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  99452. * Otherwise, will use the fullscreen API.
  99453. */
  99454. enterVR(): void;
  99455. /**
  99456. * Attempt to exit VR, or fullscreen.
  99457. */
  99458. exitVR(): void;
  99459. /**
  99460. * The position of the vr experience helper.
  99461. */
  99462. /**
  99463. * Sets the position of the vr experience helper.
  99464. */
  99465. position: Vector3;
  99466. /**
  99467. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  99468. */
  99469. enableInteractions(): void;
  99470. private readonly _noControllerIsActive;
  99471. private beforeRender;
  99472. private _isTeleportationFloor;
  99473. /**
  99474. * Adds a floor mesh to be used for teleportation.
  99475. * @param floorMesh the mesh to be used for teleportation.
  99476. */
  99477. addFloorMesh(floorMesh: Mesh): void;
  99478. /**
  99479. * Removes a floor mesh from being used for teleportation.
  99480. * @param floorMesh the mesh to be removed.
  99481. */
  99482. removeFloorMesh(floorMesh: Mesh): void;
  99483. /**
  99484. * Enables interactions and teleportation using the VR controllers and gaze.
  99485. * @param vrTeleportationOptions options to modify teleportation behavior.
  99486. */
  99487. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  99488. private _onNewGamepadConnected;
  99489. private _tryEnableInteractionOnController;
  99490. private _onNewGamepadDisconnected;
  99491. private _enableInteractionOnController;
  99492. private _checkTeleportWithRay;
  99493. private _checkRotate;
  99494. private _checkTeleportBackwards;
  99495. private _enableTeleportationOnController;
  99496. private _createTeleportationCircles;
  99497. private _displayTeleportationTarget;
  99498. private _hideTeleportationTarget;
  99499. private _rotateCamera;
  99500. private _moveTeleportationSelectorTo;
  99501. private _workingVector;
  99502. private _workingQuaternion;
  99503. private _workingMatrix;
  99504. /**
  99505. * Teleports the users feet to the desired location
  99506. * @param location The location where the user's feet should be placed
  99507. */
  99508. teleportCamera(location: Vector3): void;
  99509. private _convertNormalToDirectionOfRay;
  99510. private _castRayAndSelectObject;
  99511. private _notifySelectedMeshUnselected;
  99512. /**
  99513. * Sets the color of the laser ray from the vr controllers.
  99514. * @param color new color for the ray.
  99515. */
  99516. changeLaserColor(color: Color3): void;
  99517. /**
  99518. * Sets the color of the ray from the vr headsets gaze.
  99519. * @param color new color for the ray.
  99520. */
  99521. changeGazeColor(color: Color3): void;
  99522. /**
  99523. * Exits VR and disposes of the vr experience helper
  99524. */
  99525. dispose(): void;
  99526. /**
  99527. * Gets the name of the VRExperienceHelper class
  99528. * @returns "VRExperienceHelper"
  99529. */
  99530. getClassName(): string;
  99531. }
  99532. }
  99533. declare module BABYLON {
  99534. /**
  99535. * Manages an XRSession
  99536. * @see https://doc.babylonjs.com/how_to/webxr
  99537. */
  99538. export class WebXRSessionManager implements IDisposable {
  99539. private scene;
  99540. /**
  99541. * Fires every time a new xrFrame arrives which can be used to update the camera
  99542. */
  99543. onXRFrameObservable: Observable<any>;
  99544. /**
  99545. * Fires when the xr session is ended either by the device or manually done
  99546. */
  99547. onXRSessionEnded: Observable<any>;
  99548. /** @hidden */
  99549. _xrSession: XRSession;
  99550. /** @hidden */
  99551. _frameOfReference: XRFrameOfReference;
  99552. /** @hidden */
  99553. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  99554. /** @hidden */
  99555. _currentXRFrame: Nullable<XRFrame>;
  99556. private _xrNavigator;
  99557. private _xrDevice;
  99558. private _tmpMatrix;
  99559. /**
  99560. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  99561. * @param scene The scene which the session should be created for
  99562. */
  99563. constructor(scene: Scene);
  99564. /**
  99565. * Initializes the manager
  99566. * After initialization enterXR can be called to start an XR session
  99567. * @returns Promise which resolves after it is initialized
  99568. */
  99569. initializeAsync(): Promise<void>;
  99570. /**
  99571. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  99572. * @param sessionCreationOptions xr options to create the session with
  99573. * @param frameOfReferenceType option to configure how the xr pose is expressed
  99574. * @returns Promise which resolves after it enters XR
  99575. */
  99576. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  99577. /**
  99578. * Stops the xrSession and restores the renderloop
  99579. * @returns Promise which resolves after it exits XR
  99580. */
  99581. exitXRAsync(): Promise<void>;
  99582. /**
  99583. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99584. * @param ray ray to cast into the environment
  99585. * @returns Promise which resolves with a collision point in the environment if it exists
  99586. */
  99587. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99588. /**
  99589. * Checks if a session would be supported for the creation options specified
  99590. * @param options creation options to check if they are supported
  99591. * @returns true if supported
  99592. */
  99593. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99594. /**
  99595. * @hidden
  99596. * Converts the render layer of xrSession to a render target
  99597. * @param session session to create render target for
  99598. * @param scene scene the new render target should be created for
  99599. */
  99600. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  99601. /**
  99602. * Disposes of the session manager
  99603. */
  99604. dispose(): void;
  99605. }
  99606. }
  99607. declare module BABYLON {
  99608. /**
  99609. * WebXR Camera which holds the views for the xrSession
  99610. * @see https://doc.babylonjs.com/how_to/webxr
  99611. */
  99612. export class WebXRCamera extends FreeCamera {
  99613. private static _TmpMatrix;
  99614. /**
  99615. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  99616. * @param name the name of the camera
  99617. * @param scene the scene to add the camera to
  99618. */
  99619. constructor(name: string, scene: Scene);
  99620. private _updateNumberOfRigCameras;
  99621. /** @hidden */
  99622. _updateForDualEyeDebugging(pupilDistance?: number): void;
  99623. /**
  99624. * Updates the cameras position from the current pose information of the XR session
  99625. * @param xrSessionManager the session containing pose information
  99626. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  99627. */
  99628. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  99629. }
  99630. }
  99631. declare module BABYLON {
  99632. /**
  99633. * States of the webXR experience
  99634. */
  99635. export enum WebXRState {
  99636. /**
  99637. * Transitioning to being in XR mode
  99638. */
  99639. ENTERING_XR = 0,
  99640. /**
  99641. * Transitioning to non XR mode
  99642. */
  99643. EXITING_XR = 1,
  99644. /**
  99645. * In XR mode and presenting
  99646. */
  99647. IN_XR = 2,
  99648. /**
  99649. * Not entered XR mode
  99650. */
  99651. NOT_IN_XR = 3
  99652. }
  99653. /**
  99654. * Helper class used to enable XR
  99655. * @see https://doc.babylonjs.com/how_to/webxr
  99656. */
  99657. export class WebXRExperienceHelper implements IDisposable {
  99658. private scene;
  99659. /**
  99660. * 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
  99661. */
  99662. container: AbstractMesh;
  99663. /**
  99664. * Camera used to render xr content
  99665. */
  99666. camera: WebXRCamera;
  99667. /**
  99668. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  99669. */
  99670. state: WebXRState;
  99671. private _setState;
  99672. private static _TmpVector;
  99673. /**
  99674. * Fires when the state of the experience helper has changed
  99675. */
  99676. onStateChangedObservable: Observable<WebXRState>;
  99677. /** @hidden */
  99678. _sessionManager: WebXRSessionManager;
  99679. private _nonVRCamera;
  99680. private _originalSceneAutoClear;
  99681. private _supported;
  99682. /**
  99683. * Creates the experience helper
  99684. * @param scene the scene to attach the experience helper to
  99685. * @returns a promise for the experience helper
  99686. */
  99687. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  99688. /**
  99689. * Creates a WebXRExperienceHelper
  99690. * @param scene The scene the helper should be created in
  99691. */
  99692. private constructor();
  99693. /**
  99694. * Exits XR mode and returns the scene to its original state
  99695. * @returns promise that resolves after xr mode has exited
  99696. */
  99697. exitXRAsync(): Promise<void>;
  99698. /**
  99699. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  99700. * @param sessionCreationOptions options for the XR session
  99701. * @param frameOfReference frame of reference of the XR session
  99702. * @returns promise that resolves after xr mode has entered
  99703. */
  99704. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  99705. /**
  99706. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99707. * @param ray ray to cast into the environment
  99708. * @returns Promise which resolves with a collision point in the environment if it exists
  99709. */
  99710. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99711. /**
  99712. * Updates the global position of the camera by moving the camera's container
  99713. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  99714. * @param position The desired global position of the camera
  99715. */
  99716. setPositionOfCameraUsingContainer(position: Vector3): void;
  99717. /**
  99718. * Rotates the xr camera by rotating the camera's container around the camera's position
  99719. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  99720. * @param rotation the desired quaternion rotation to apply to the camera
  99721. */
  99722. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  99723. /**
  99724. * Checks if the creation options are supported by the xr session
  99725. * @param options creation options
  99726. * @returns true if supported
  99727. */
  99728. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99729. /**
  99730. * Disposes of the experience helper
  99731. */
  99732. dispose(): void;
  99733. }
  99734. }
  99735. declare module BABYLON {
  99736. /**
  99737. * Button which can be used to enter a different mode of XR
  99738. */
  99739. export class WebXREnterExitUIButton {
  99740. /** button element */
  99741. element: HTMLElement;
  99742. /** XR initialization options for the button */
  99743. initializationOptions: XRSessionCreationOptions;
  99744. /**
  99745. * Creates a WebXREnterExitUIButton
  99746. * @param element button element
  99747. * @param initializationOptions XR initialization options for the button
  99748. */
  99749. constructor(
  99750. /** button element */
  99751. element: HTMLElement,
  99752. /** XR initialization options for the button */
  99753. initializationOptions: XRSessionCreationOptions);
  99754. /**
  99755. * Overwritable function which can be used to update the button's visuals when the state changes
  99756. * @param activeButton the current active button in the UI
  99757. */
  99758. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  99759. }
  99760. /**
  99761. * Options to create the webXR UI
  99762. */
  99763. export class WebXREnterExitUIOptions {
  99764. /**
  99765. * Context to enter xr with
  99766. */
  99767. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  99768. /**
  99769. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  99770. */
  99771. customButtons?: Array<WebXREnterExitUIButton>;
  99772. }
  99773. /**
  99774. * UI to allow the user to enter/exit XR mode
  99775. */
  99776. export class WebXREnterExitUI implements IDisposable {
  99777. private scene;
  99778. private _overlay;
  99779. private _buttons;
  99780. private _activeButton;
  99781. /**
  99782. * Fired every time the active button is changed.
  99783. *
  99784. * When xr is entered via a button that launches xr that button will be the callback parameter
  99785. *
  99786. * When exiting xr the callback parameter will be null)
  99787. */
  99788. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  99789. /**
  99790. * Creates UI to allow the user to enter/exit XR mode
  99791. * @param scene the scene to add the ui to
  99792. * @param helper the xr experience helper to enter/exit xr with
  99793. * @param options options to configure the UI
  99794. * @returns the created ui
  99795. */
  99796. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  99797. private constructor();
  99798. private _updateButtons;
  99799. /**
  99800. * Disposes of the object
  99801. */
  99802. dispose(): void;
  99803. }
  99804. }
  99805. declare module BABYLON {
  99806. /**
  99807. * Represents an XR input
  99808. */
  99809. export class WebXRController {
  99810. /**
  99811. * 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
  99812. */
  99813. grip?: AbstractMesh;
  99814. /**
  99815. * Pointer which can be used to select objects or attach a visible laser to
  99816. */
  99817. pointer: AbstractMesh;
  99818. /**
  99819. * Creates the controller
  99820. * @see https://doc.babylonjs.com/how_to/webxr
  99821. * @param scene the scene which the controller should be associated to
  99822. */
  99823. constructor(scene: Scene);
  99824. /**
  99825. * Disposes of the object
  99826. */
  99827. dispose(): void;
  99828. }
  99829. /**
  99830. * XR input used to track XR inputs such as controllers/rays
  99831. */
  99832. export class WebXRInput implements IDisposable {
  99833. private helper;
  99834. /**
  99835. * XR controllers being tracked
  99836. */
  99837. controllers: Array<WebXRController>;
  99838. private _tmpMatrix;
  99839. private _frameObserver;
  99840. /**
  99841. * Initializes the WebXRInput
  99842. * @param helper experience helper which the input should be created for
  99843. */
  99844. constructor(helper: WebXRExperienceHelper);
  99845. /**
  99846. * Disposes of the object
  99847. */
  99848. dispose(): void;
  99849. }
  99850. }
  99851. declare module BABYLON {
  99852. /**
  99853. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  99854. */
  99855. export class WebXRManagedOutputCanvas implements IDisposable {
  99856. private _canvas;
  99857. /**
  99858. * xrpresent context of the canvas which can be used to display/mirror xr content
  99859. */
  99860. canvasContext: Nullable<WebGLRenderingContext>;
  99861. /**
  99862. * Initializes the canvas to be added/removed upon entering/exiting xr
  99863. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  99864. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  99865. */
  99866. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  99867. /**
  99868. * Disposes of the object
  99869. */
  99870. dispose(): void;
  99871. private _setManagedOutputCanvas;
  99872. private _addCanvas;
  99873. private _removeCanvas;
  99874. }
  99875. }
  99876. declare module BABYLON {
  99877. /**
  99878. * Contains an array of blocks representing the octree
  99879. */
  99880. export interface IOctreeContainer<T> {
  99881. /**
  99882. * Blocks within the octree
  99883. */
  99884. blocks: Array<OctreeBlock<T>>;
  99885. }
  99886. /**
  99887. * Class used to store a cell in an octree
  99888. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99889. */
  99890. export class OctreeBlock<T> {
  99891. /**
  99892. * Gets the content of the current block
  99893. */
  99894. entries: T[];
  99895. /**
  99896. * Gets the list of block children
  99897. */
  99898. blocks: Array<OctreeBlock<T>>;
  99899. private _depth;
  99900. private _maxDepth;
  99901. private _capacity;
  99902. private _minPoint;
  99903. private _maxPoint;
  99904. private _boundingVectors;
  99905. private _creationFunc;
  99906. /**
  99907. * Creates a new block
  99908. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  99909. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  99910. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  99911. * @param depth defines the current depth of this block in the octree
  99912. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  99913. * @param creationFunc defines a callback to call when an element is added to the block
  99914. */
  99915. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  99916. /**
  99917. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  99918. */
  99919. readonly capacity: number;
  99920. /**
  99921. * Gets the minimum vector (in world space) of the block's bounding box
  99922. */
  99923. readonly minPoint: Vector3;
  99924. /**
  99925. * Gets the maximum vector (in world space) of the block's bounding box
  99926. */
  99927. readonly maxPoint: Vector3;
  99928. /**
  99929. * Add a new element to this block
  99930. * @param entry defines the element to add
  99931. */
  99932. addEntry(entry: T): void;
  99933. /**
  99934. * Remove an element from this block
  99935. * @param entry defines the element to remove
  99936. */
  99937. removeEntry(entry: T): void;
  99938. /**
  99939. * Add an array of elements to this block
  99940. * @param entries defines the array of elements to add
  99941. */
  99942. addEntries(entries: T[]): void;
  99943. /**
  99944. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  99945. * @param frustumPlanes defines the frustum planes to test
  99946. * @param selection defines the array to store current content if selection is positive
  99947. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99948. */
  99949. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  99950. /**
  99951. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  99952. * @param sphereCenter defines the bounding sphere center
  99953. * @param sphereRadius defines the bounding sphere radius
  99954. * @param selection defines the array to store current content if selection is positive
  99955. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99956. */
  99957. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  99958. /**
  99959. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  99960. * @param ray defines the ray to test with
  99961. * @param selection defines the array to store current content if selection is positive
  99962. */
  99963. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  99964. /**
  99965. * Subdivide the content into child blocks (this block will then be empty)
  99966. */
  99967. createInnerBlocks(): void;
  99968. /**
  99969. * @hidden
  99970. */
  99971. 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;
  99972. }
  99973. }
  99974. declare module BABYLON {
  99975. /**
  99976. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  99977. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99978. */
  99979. export class Octree<T> {
  99980. /** 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.) */
  99981. maxDepth: number;
  99982. /**
  99983. * Blocks within the octree containing objects
  99984. */
  99985. blocks: Array<OctreeBlock<T>>;
  99986. /**
  99987. * Content stored in the octree
  99988. */
  99989. dynamicContent: T[];
  99990. private _maxBlockCapacity;
  99991. private _selectionContent;
  99992. private _creationFunc;
  99993. /**
  99994. * Creates a octree
  99995. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99996. * @param creationFunc function to be used to instatiate the octree
  99997. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  99998. * @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.)
  99999. */
  100000. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  100001. /** 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.) */
  100002. maxDepth?: number);
  100003. /**
  100004. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  100005. * @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);
  100006. * @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);
  100007. * @param entries meshes to be added to the octree blocks
  100008. */
  100009. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  100010. /**
  100011. * Adds a mesh to the octree
  100012. * @param entry Mesh to add to the octree
  100013. */
  100014. addMesh(entry: T): void;
  100015. /**
  100016. * Remove an element from the octree
  100017. * @param entry defines the element to remove
  100018. */
  100019. removeMesh(entry: T): void;
  100020. /**
  100021. * Selects an array of meshes within the frustum
  100022. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  100023. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  100024. * @returns array of meshes within the frustum
  100025. */
  100026. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  100027. /**
  100028. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  100029. * @param sphereCenter defines the bounding sphere center
  100030. * @param sphereRadius defines the bounding sphere radius
  100031. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100032. * @returns an array of objects that intersect the sphere
  100033. */
  100034. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  100035. /**
  100036. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  100037. * @param ray defines the ray to test with
  100038. * @returns array of intersected objects
  100039. */
  100040. intersectsRay(ray: Ray): SmartArray<T>;
  100041. /**
  100042. * Adds a mesh into the octree block if it intersects the block
  100043. */
  100044. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  100045. /**
  100046. * Adds a submesh into the octree block if it intersects the block
  100047. */
  100048. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  100049. }
  100050. }
  100051. declare module BABYLON {
  100052. interface Scene {
  100053. /**
  100054. * @hidden
  100055. * Backing Filed
  100056. */
  100057. _selectionOctree: Octree<AbstractMesh>;
  100058. /**
  100059. * Gets the octree used to boost mesh selection (picking)
  100060. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100061. */
  100062. selectionOctree: Octree<AbstractMesh>;
  100063. /**
  100064. * Creates or updates the octree used to boost selection (picking)
  100065. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100066. * @param maxCapacity defines the maximum capacity per leaf
  100067. * @param maxDepth defines the maximum depth of the octree
  100068. * @returns an octree of AbstractMesh
  100069. */
  100070. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  100071. }
  100072. interface AbstractMesh {
  100073. /**
  100074. * @hidden
  100075. * Backing Field
  100076. */
  100077. _submeshesOctree: Octree<SubMesh>;
  100078. /**
  100079. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  100080. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  100081. * @param maxCapacity defines the maximum size of each block (64 by default)
  100082. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  100083. * @returns the new octree
  100084. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  100085. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100086. */
  100087. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  100088. }
  100089. /**
  100090. * Defines the octree scene component responsible to manage any octrees
  100091. * in a given scene.
  100092. */
  100093. export class OctreeSceneComponent {
  100094. /**
  100095. * The component name helpfull to identify the component in the list of scene components.
  100096. */
  100097. readonly name: string;
  100098. /**
  100099. * The scene the component belongs to.
  100100. */
  100101. scene: Scene;
  100102. /**
  100103. * Indicates if the meshes have been checked to make sure they are isEnabled()
  100104. */
  100105. readonly checksIsEnabled: boolean;
  100106. /**
  100107. * Creates a new instance of the component for the given scene
  100108. * @param scene Defines the scene to register the component in
  100109. */
  100110. constructor(scene: Scene);
  100111. /**
  100112. * Registers the component in a given scene
  100113. */
  100114. register(): void;
  100115. /**
  100116. * Return the list of active meshes
  100117. * @returns the list of active meshes
  100118. */
  100119. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  100120. /**
  100121. * Return the list of active sub meshes
  100122. * @param mesh The mesh to get the candidates sub meshes from
  100123. * @returns the list of active sub meshes
  100124. */
  100125. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  100126. private _tempRay;
  100127. /**
  100128. * Return the list of sub meshes intersecting with a given local ray
  100129. * @param mesh defines the mesh to find the submesh for
  100130. * @param localRay defines the ray in local space
  100131. * @returns the list of intersecting sub meshes
  100132. */
  100133. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  100134. /**
  100135. * Return the list of sub meshes colliding with a collider
  100136. * @param mesh defines the mesh to find the submesh for
  100137. * @param collider defines the collider to evaluate the collision against
  100138. * @returns the list of colliding sub meshes
  100139. */
  100140. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  100141. /**
  100142. * Rebuilds the elements related to this component in case of
  100143. * context lost for instance.
  100144. */
  100145. rebuild(): void;
  100146. /**
  100147. * Disposes the component and the associated ressources.
  100148. */
  100149. dispose(): void;
  100150. }
  100151. }
  100152. declare module BABYLON {
  100153. /**
  100154. * Renders a layer on top of an existing scene
  100155. */
  100156. export class UtilityLayerRenderer implements IDisposable {
  100157. /** the original scene that will be rendered on top of */
  100158. originalScene: Scene;
  100159. private _pointerCaptures;
  100160. private _lastPointerEvents;
  100161. private static _DefaultUtilityLayer;
  100162. private static _DefaultKeepDepthUtilityLayer;
  100163. private _sharedGizmoLight;
  100164. /**
  100165. * @hidden
  100166. * Light which used by gizmos to get light shading
  100167. */
  100168. _getSharedGizmoLight(): HemisphericLight;
  100169. /**
  100170. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  100171. */
  100172. pickUtilitySceneFirst: boolean;
  100173. /**
  100174. * 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)
  100175. */
  100176. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  100177. /**
  100178. * 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)
  100179. */
  100180. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  100181. /**
  100182. * The scene that is rendered on top of the original scene
  100183. */
  100184. utilityLayerScene: Scene;
  100185. /**
  100186. * If the utility layer should automatically be rendered on top of existing scene
  100187. */
  100188. shouldRender: boolean;
  100189. /**
  100190. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  100191. */
  100192. onlyCheckPointerDownEvents: boolean;
  100193. /**
  100194. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  100195. */
  100196. processAllEvents: boolean;
  100197. /**
  100198. * Observable raised when the pointer move from the utility layer scene to the main scene
  100199. */
  100200. onPointerOutObservable: Observable<number>;
  100201. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  100202. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  100203. private _afterRenderObserver;
  100204. private _sceneDisposeObserver;
  100205. private _originalPointerObserver;
  100206. /**
  100207. * Instantiates a UtilityLayerRenderer
  100208. * @param originalScene the original scene that will be rendered on top of
  100209. * @param handleEvents boolean indicating if the utility layer should handle events
  100210. */
  100211. constructor(
  100212. /** the original scene that will be rendered on top of */
  100213. originalScene: Scene, handleEvents?: boolean);
  100214. private _notifyObservers;
  100215. /**
  100216. * Renders the utility layers scene on top of the original scene
  100217. */
  100218. render(): void;
  100219. /**
  100220. * Disposes of the renderer
  100221. */
  100222. dispose(): void;
  100223. private _updateCamera;
  100224. }
  100225. }
  100226. declare module BABYLON {
  100227. /**
  100228. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  100229. */
  100230. export class Gizmo implements IDisposable {
  100231. /** The utility layer the gizmo will be added to */
  100232. gizmoLayer: UtilityLayerRenderer;
  100233. /**
  100234. * The root mesh of the gizmo
  100235. */
  100236. _rootMesh: Mesh;
  100237. private _attachedMesh;
  100238. /**
  100239. * Ratio for the scale of the gizmo (Default: 1)
  100240. */
  100241. scaleRatio: number;
  100242. /**
  100243. * If a custom mesh has been set (Default: false)
  100244. */
  100245. protected _customMeshSet: boolean;
  100246. /**
  100247. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  100248. * * When set, interactions will be enabled
  100249. */
  100250. attachedMesh: Nullable<AbstractMesh>;
  100251. /**
  100252. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  100253. * @param mesh The mesh to replace the default mesh of the gizmo
  100254. */
  100255. setCustomMesh(mesh: Mesh): void;
  100256. /**
  100257. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  100258. */
  100259. updateGizmoRotationToMatchAttachedMesh: boolean;
  100260. /**
  100261. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  100262. */
  100263. updateGizmoPositionToMatchAttachedMesh: boolean;
  100264. /**
  100265. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  100266. */
  100267. protected _updateScale: boolean;
  100268. protected _interactionsEnabled: boolean;
  100269. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100270. private _beforeRenderObserver;
  100271. private _tempVector;
  100272. /**
  100273. * Creates a gizmo
  100274. * @param gizmoLayer The utility layer the gizmo will be added to
  100275. */
  100276. constructor(
  100277. /** The utility layer the gizmo will be added to */
  100278. gizmoLayer?: UtilityLayerRenderer);
  100279. /**
  100280. * Updates the gizmo to match the attached mesh's position/rotation
  100281. */
  100282. protected _update(): void;
  100283. /**
  100284. * Disposes of the gizmo
  100285. */
  100286. dispose(): void;
  100287. }
  100288. }
  100289. declare module BABYLON {
  100290. /**
  100291. * Single axis drag gizmo
  100292. */
  100293. export class AxisDragGizmo extends Gizmo {
  100294. /**
  100295. * Drag behavior responsible for the gizmos dragging interactions
  100296. */
  100297. dragBehavior: PointerDragBehavior;
  100298. private _pointerObserver;
  100299. /**
  100300. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100301. */
  100302. snapDistance: number;
  100303. /**
  100304. * Event that fires each time the gizmo snaps to a new location.
  100305. * * snapDistance is the the change in distance
  100306. */
  100307. onSnapObservable: Observable<{
  100308. snapDistance: number;
  100309. }>;
  100310. /** @hidden */
  100311. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  100312. /** @hidden */
  100313. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  100314. /**
  100315. * Creates an AxisDragGizmo
  100316. * @param gizmoLayer The utility layer the gizmo will be added to
  100317. * @param dragAxis The axis which the gizmo will be able to drag on
  100318. * @param color The color of the gizmo
  100319. */
  100320. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100321. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100322. /**
  100323. * Disposes of the gizmo
  100324. */
  100325. dispose(): void;
  100326. }
  100327. }
  100328. declare module BABYLON.Debug {
  100329. /**
  100330. * The Axes viewer will show 3 axes in a specific point in space
  100331. */
  100332. export class AxesViewer {
  100333. private _xAxis;
  100334. private _yAxis;
  100335. private _zAxis;
  100336. private _scaleLinesFactor;
  100337. private _instanced;
  100338. /**
  100339. * Gets the hosting scene
  100340. */
  100341. scene: Scene;
  100342. /**
  100343. * Gets or sets a number used to scale line length
  100344. */
  100345. scaleLines: number;
  100346. /** Gets the node hierarchy used to render x-axis */
  100347. readonly xAxis: TransformNode;
  100348. /** Gets the node hierarchy used to render y-axis */
  100349. readonly yAxis: TransformNode;
  100350. /** Gets the node hierarchy used to render z-axis */
  100351. readonly zAxis: TransformNode;
  100352. /**
  100353. * Creates a new AxesViewer
  100354. * @param scene defines the hosting scene
  100355. * @param scaleLines defines a number used to scale line length (1 by default)
  100356. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  100357. * @param xAxis defines the node hierarchy used to render the x-axis
  100358. * @param yAxis defines the node hierarchy used to render the y-axis
  100359. * @param zAxis defines the node hierarchy used to render the z-axis
  100360. */
  100361. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  100362. /**
  100363. * Force the viewer to update
  100364. * @param position defines the position of the viewer
  100365. * @param xaxis defines the x axis of the viewer
  100366. * @param yaxis defines the y axis of the viewer
  100367. * @param zaxis defines the z axis of the viewer
  100368. */
  100369. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  100370. /**
  100371. * Creates an instance of this axes viewer.
  100372. * @returns a new axes viewer with instanced meshes
  100373. */
  100374. createInstance(): AxesViewer;
  100375. /** Releases resources */
  100376. dispose(): void;
  100377. private static _SetRenderingGroupId;
  100378. }
  100379. }
  100380. declare module BABYLON.Debug {
  100381. /**
  100382. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  100383. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  100384. */
  100385. export class BoneAxesViewer extends AxesViewer {
  100386. /**
  100387. * Gets or sets the target mesh where to display the axes viewer
  100388. */
  100389. mesh: Nullable<Mesh>;
  100390. /**
  100391. * Gets or sets the target bone where to display the axes viewer
  100392. */
  100393. bone: Nullable<Bone>;
  100394. /** Gets current position */
  100395. pos: Vector3;
  100396. /** Gets direction of X axis */
  100397. xaxis: Vector3;
  100398. /** Gets direction of Y axis */
  100399. yaxis: Vector3;
  100400. /** Gets direction of Z axis */
  100401. zaxis: Vector3;
  100402. /**
  100403. * Creates a new BoneAxesViewer
  100404. * @param scene defines the hosting scene
  100405. * @param bone defines the target bone
  100406. * @param mesh defines the target mesh
  100407. * @param scaleLines defines a scaling factor for line length (1 by default)
  100408. */
  100409. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  100410. /**
  100411. * Force the viewer to update
  100412. */
  100413. update(): void;
  100414. /** Releases resources */
  100415. dispose(): void;
  100416. }
  100417. }
  100418. declare module BABYLON {
  100419. /**
  100420. * Interface used to define scene explorer extensibility option
  100421. */
  100422. export interface IExplorerExtensibilityOption {
  100423. /**
  100424. * Define the option label
  100425. */
  100426. label: string;
  100427. /**
  100428. * Defines the action to execute on click
  100429. */
  100430. action: (entity: any) => void;
  100431. }
  100432. /**
  100433. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  100434. */
  100435. export interface IExplorerExtensibilityGroup {
  100436. /**
  100437. * Defines a predicate to test if a given type mut be extended
  100438. */
  100439. predicate: (entity: any) => boolean;
  100440. /**
  100441. * Gets the list of options added to a type
  100442. */
  100443. entries: IExplorerExtensibilityOption[];
  100444. }
  100445. /**
  100446. * Interface used to define the options to use to create the Inspector
  100447. */
  100448. export interface IInspectorOptions {
  100449. /**
  100450. * Display in overlay mode (default: false)
  100451. */
  100452. overlay?: boolean;
  100453. /**
  100454. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  100455. */
  100456. globalRoot?: HTMLElement;
  100457. /**
  100458. * Display the Scene explorer
  100459. */
  100460. showExplorer?: boolean;
  100461. /**
  100462. * Display the property inspector
  100463. */
  100464. showInspector?: boolean;
  100465. /**
  100466. * Display in embed mode (both panes on the right)
  100467. */
  100468. embedMode?: boolean;
  100469. /**
  100470. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  100471. */
  100472. handleResize?: boolean;
  100473. /**
  100474. * Allow the panes to popup (default: true)
  100475. */
  100476. enablePopup?: boolean;
  100477. /**
  100478. * Allow the panes to be closed by users (default: true)
  100479. */
  100480. enableClose?: boolean;
  100481. /**
  100482. * Optional list of extensibility entries
  100483. */
  100484. explorerExtensibility?: IExplorerExtensibilityGroup[];
  100485. /**
  100486. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  100487. */
  100488. inspectorURL?: string;
  100489. }
  100490. interface Scene {
  100491. /**
  100492. * @hidden
  100493. * Backing field
  100494. */
  100495. _debugLayer: DebugLayer;
  100496. /**
  100497. * Gets the debug layer (aka Inspector) associated with the scene
  100498. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100499. */
  100500. debugLayer: DebugLayer;
  100501. }
  100502. /**
  100503. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100504. * what is happening in your scene
  100505. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100506. */
  100507. export class DebugLayer {
  100508. /**
  100509. * Define the url to get the inspector script from.
  100510. * By default it uses the babylonjs CDN.
  100511. * @ignoreNaming
  100512. */
  100513. static InspectorURL: string;
  100514. private _scene;
  100515. private BJSINSPECTOR;
  100516. /**
  100517. * Observable triggered when a property is changed through the inspector.
  100518. */
  100519. onPropertyChangedObservable: Observable<{
  100520. object: any;
  100521. property: string;
  100522. value: any;
  100523. initialValue: any;
  100524. }>;
  100525. /**
  100526. * Instantiates a new debug layer.
  100527. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100528. * what is happening in your scene
  100529. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100530. * @param scene Defines the scene to inspect
  100531. */
  100532. constructor(scene: Scene);
  100533. /** Creates the inspector window. */
  100534. private _createInspector;
  100535. /**
  100536. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  100537. * @param entity defines the entity to select
  100538. * @param lineContainerTitle defines the specific block to highlight
  100539. */
  100540. select(entity: any, lineContainerTitle?: string): void;
  100541. /** Get the inspector from bundle or global */
  100542. private _getGlobalInspector;
  100543. /**
  100544. * Get if the inspector is visible or not.
  100545. * @returns true if visible otherwise, false
  100546. */
  100547. isVisible(): boolean;
  100548. /**
  100549. * Hide the inspector and close its window.
  100550. */
  100551. hide(): void;
  100552. /**
  100553. * Launch the debugLayer.
  100554. * @param config Define the configuration of the inspector
  100555. * @return a promise fulfilled when the debug layer is visible
  100556. */
  100557. show(config?: IInspectorOptions): Promise<DebugLayer>;
  100558. }
  100559. }
  100560. declare module BABYLON {
  100561. /**
  100562. * Class containing static functions to help procedurally build meshes
  100563. */
  100564. export class BoxBuilder {
  100565. /**
  100566. * Creates a box mesh
  100567. * * The parameter `size` sets the size (float) of each box side (default 1)
  100568. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  100569. * * 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)
  100570. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  100571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100572. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100574. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  100575. * @param name defines the name of the mesh
  100576. * @param options defines the options used to create the mesh
  100577. * @param scene defines the hosting scene
  100578. * @returns the box mesh
  100579. */
  100580. static CreateBox(name: string, options: {
  100581. size?: number;
  100582. width?: number;
  100583. height?: number;
  100584. depth?: number;
  100585. faceUV?: Vector4[];
  100586. faceColors?: Color4[];
  100587. sideOrientation?: number;
  100588. frontUVs?: Vector4;
  100589. backUVs?: Vector4;
  100590. wrap?: boolean;
  100591. topBaseAt?: number;
  100592. bottomBaseAt?: number;
  100593. updatable?: boolean;
  100594. }, scene?: Nullable<Scene>): Mesh;
  100595. }
  100596. }
  100597. declare module BABYLON {
  100598. /**
  100599. * Class containing static functions to help procedurally build meshes
  100600. */
  100601. export class SphereBuilder {
  100602. /**
  100603. * Creates a sphere mesh
  100604. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  100605. * * 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`)
  100606. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  100607. * * 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
  100608. * * 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)
  100609. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100610. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100612. * @param name defines the name of the mesh
  100613. * @param options defines the options used to create the mesh
  100614. * @param scene defines the hosting scene
  100615. * @returns the sphere mesh
  100616. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  100617. */
  100618. static CreateSphere(name: string, options: {
  100619. segments?: number;
  100620. diameter?: number;
  100621. diameterX?: number;
  100622. diameterY?: number;
  100623. diameterZ?: number;
  100624. arc?: number;
  100625. slice?: number;
  100626. sideOrientation?: number;
  100627. frontUVs?: Vector4;
  100628. backUVs?: Vector4;
  100629. updatable?: boolean;
  100630. }, scene: any): Mesh;
  100631. }
  100632. }
  100633. declare module BABYLON.Debug {
  100634. /**
  100635. * Used to show the physics impostor around the specific mesh
  100636. */
  100637. export class PhysicsViewer {
  100638. /** @hidden */
  100639. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  100640. /** @hidden */
  100641. protected _meshes: Array<Nullable<AbstractMesh>>;
  100642. /** @hidden */
  100643. protected _scene: Nullable<Scene>;
  100644. /** @hidden */
  100645. protected _numMeshes: number;
  100646. /** @hidden */
  100647. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  100648. private _renderFunction;
  100649. private _utilityLayer;
  100650. private _debugBoxMesh;
  100651. private _debugSphereMesh;
  100652. private _debugCylinderMesh;
  100653. private _debugMaterial;
  100654. private _debugMeshMeshes;
  100655. /**
  100656. * Creates a new PhysicsViewer
  100657. * @param scene defines the hosting scene
  100658. */
  100659. constructor(scene: Scene);
  100660. /** @hidden */
  100661. protected _updateDebugMeshes(): void;
  100662. /**
  100663. * Renders a specified physic impostor
  100664. * @param impostor defines the impostor to render
  100665. * @param targetMesh defines the mesh represented by the impostor
  100666. * @returns the new debug mesh used to render the impostor
  100667. */
  100668. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  100669. /**
  100670. * Hides a specified physic impostor
  100671. * @param impostor defines the impostor to hide
  100672. */
  100673. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  100674. private _getDebugMaterial;
  100675. private _getDebugBoxMesh;
  100676. private _getDebugSphereMesh;
  100677. private _getDebugCylinderMesh;
  100678. private _getDebugMeshMesh;
  100679. private _getDebugMesh;
  100680. /** Releases all resources */
  100681. dispose(): void;
  100682. }
  100683. }
  100684. declare module BABYLON {
  100685. /**
  100686. * Class containing static functions to help procedurally build meshes
  100687. */
  100688. export class LinesBuilder {
  100689. /**
  100690. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  100691. * * 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
  100692. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  100693. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  100694. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  100695. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  100696. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  100697. * * 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
  100698. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  100699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100700. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  100701. * @param name defines the name of the new line system
  100702. * @param options defines the options used to create the line system
  100703. * @param scene defines the hosting scene
  100704. * @returns a new line system mesh
  100705. */
  100706. static CreateLineSystem(name: string, options: {
  100707. lines: Vector3[][];
  100708. updatable?: boolean;
  100709. instance?: Nullable<LinesMesh>;
  100710. colors?: Nullable<Color4[][]>;
  100711. useVertexAlpha?: boolean;
  100712. }, scene: Nullable<Scene>): LinesMesh;
  100713. /**
  100714. * Creates a line mesh
  100715. * 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
  100716. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  100717. * * The parameter `points` is an array successive Vector3
  100718. * * 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
  100719. * * The optional parameter `colors` is an array of successive Color4, one per line point
  100720. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  100721. * * When updating an instance, remember that only point positions can change, not the number of points
  100722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100723. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  100724. * @param name defines the name of the new line system
  100725. * @param options defines the options used to create the line system
  100726. * @param scene defines the hosting scene
  100727. * @returns a new line mesh
  100728. */
  100729. static CreateLines(name: string, options: {
  100730. points: Vector3[];
  100731. updatable?: boolean;
  100732. instance?: Nullable<LinesMesh>;
  100733. colors?: Color4[];
  100734. useVertexAlpha?: boolean;
  100735. }, scene?: Nullable<Scene>): LinesMesh;
  100736. /**
  100737. * Creates a dashed line mesh
  100738. * * 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
  100739. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  100740. * * The parameter `points` is an array successive Vector3
  100741. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  100742. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  100743. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  100744. * * 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
  100745. * * When updating an instance, remember that only point positions can change, not the number of points
  100746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100747. * @param name defines the name of the mesh
  100748. * @param options defines the options used to create the mesh
  100749. * @param scene defines the hosting scene
  100750. * @returns the dashed line mesh
  100751. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  100752. */
  100753. static CreateDashedLines(name: string, options: {
  100754. points: Vector3[];
  100755. dashSize?: number;
  100756. gapSize?: number;
  100757. dashNb?: number;
  100758. updatable?: boolean;
  100759. instance?: LinesMesh;
  100760. }, scene?: Nullable<Scene>): LinesMesh;
  100761. }
  100762. }
  100763. declare module BABYLON {
  100764. /**
  100765. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  100766. * in order to better appreciate the issue one might have.
  100767. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  100768. */
  100769. export class RayHelper {
  100770. /**
  100771. * Defines the ray we are currently tryin to visualize.
  100772. */
  100773. ray: Nullable<Ray>;
  100774. private _renderPoints;
  100775. private _renderLine;
  100776. private _renderFunction;
  100777. private _scene;
  100778. private _updateToMeshFunction;
  100779. private _attachedToMesh;
  100780. private _meshSpaceDirection;
  100781. private _meshSpaceOrigin;
  100782. /**
  100783. * Helper function to create a colored helper in a scene in one line.
  100784. * @param ray Defines the ray we are currently tryin to visualize
  100785. * @param scene Defines the scene the ray is used in
  100786. * @param color Defines the color we want to see the ray in
  100787. * @returns The newly created ray helper.
  100788. */
  100789. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  100790. /**
  100791. * Instantiate a new ray helper.
  100792. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  100793. * in order to better appreciate the issue one might have.
  100794. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  100795. * @param ray Defines the ray we are currently tryin to visualize
  100796. */
  100797. constructor(ray: Ray);
  100798. /**
  100799. * Shows the ray we are willing to debug.
  100800. * @param scene Defines the scene the ray needs to be rendered in
  100801. * @param color Defines the color the ray needs to be rendered in
  100802. */
  100803. show(scene: Scene, color?: Color3): void;
  100804. /**
  100805. * Hides the ray we are debugging.
  100806. */
  100807. hide(): void;
  100808. private _render;
  100809. /**
  100810. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  100811. * @param mesh Defines the mesh we want the helper attached to
  100812. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  100813. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  100814. * @param length Defines the length of the ray
  100815. */
  100816. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  100817. /**
  100818. * Detach the ray helper from the mesh it has previously been attached to.
  100819. */
  100820. detachFromMesh(): void;
  100821. private _updateToMesh;
  100822. /**
  100823. * Dispose the helper and release its associated resources.
  100824. */
  100825. dispose(): void;
  100826. }
  100827. }
  100828. declare module BABYLON.Debug {
  100829. /**
  100830. * Class used to render a debug view of a given skeleton
  100831. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  100832. */
  100833. export class SkeletonViewer {
  100834. /** defines the skeleton to render */
  100835. skeleton: Skeleton;
  100836. /** defines the mesh attached to the skeleton */
  100837. mesh: AbstractMesh;
  100838. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  100839. autoUpdateBonesMatrices: boolean;
  100840. /** defines the rendering group id to use with the viewer */
  100841. renderingGroupId: number;
  100842. /** Gets or sets the color used to render the skeleton */
  100843. color: Color3;
  100844. private _scene;
  100845. private _debugLines;
  100846. private _debugMesh;
  100847. private _isEnabled;
  100848. private _renderFunction;
  100849. private _utilityLayer;
  100850. /**
  100851. * Returns the mesh used to render the bones
  100852. */
  100853. readonly debugMesh: Nullable<LinesMesh>;
  100854. /**
  100855. * Creates a new SkeletonViewer
  100856. * @param skeleton defines the skeleton to render
  100857. * @param mesh defines the mesh attached to the skeleton
  100858. * @param scene defines the hosting scene
  100859. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  100860. * @param renderingGroupId defines the rendering group id to use with the viewer
  100861. */
  100862. constructor(
  100863. /** defines the skeleton to render */
  100864. skeleton: Skeleton,
  100865. /** defines the mesh attached to the skeleton */
  100866. mesh: AbstractMesh, scene: Scene,
  100867. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  100868. autoUpdateBonesMatrices?: boolean,
  100869. /** defines the rendering group id to use with the viewer */
  100870. renderingGroupId?: number);
  100871. /** Gets or sets a boolean indicating if the viewer is enabled */
  100872. isEnabled: boolean;
  100873. private _getBonePosition;
  100874. private _getLinesForBonesWithLength;
  100875. private _getLinesForBonesNoLength;
  100876. /** Update the viewer to sync with current skeleton state */
  100877. update(): void;
  100878. /** Release associated resources */
  100879. dispose(): void;
  100880. }
  100881. }
  100882. declare module BABYLON {
  100883. /**
  100884. * Options to create the null engine
  100885. */
  100886. export class NullEngineOptions {
  100887. /**
  100888. * Render width (Default: 512)
  100889. */
  100890. renderWidth: number;
  100891. /**
  100892. * Render height (Default: 256)
  100893. */
  100894. renderHeight: number;
  100895. /**
  100896. * Texture size (Default: 512)
  100897. */
  100898. textureSize: number;
  100899. /**
  100900. * If delta time between frames should be constant
  100901. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100902. */
  100903. deterministicLockstep: boolean;
  100904. /**
  100905. * Maximum about of steps between frames (Default: 4)
  100906. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100907. */
  100908. lockstepMaxSteps: number;
  100909. }
  100910. /**
  100911. * The null engine class provides support for headless version of babylon.js.
  100912. * This can be used in server side scenario or for testing purposes
  100913. */
  100914. export class NullEngine extends Engine {
  100915. private _options;
  100916. /**
  100917. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100918. */
  100919. isDeterministicLockStep(): boolean;
  100920. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  100921. getLockstepMaxSteps(): number;
  100922. /**
  100923. * Sets hardware scaling, used to save performance if needed
  100924. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100925. */
  100926. getHardwareScalingLevel(): number;
  100927. constructor(options?: NullEngineOptions);
  100928. createVertexBuffer(vertices: FloatArray): DataBuffer;
  100929. createIndexBuffer(indices: IndicesArray): DataBuffer;
  100930. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  100931. getRenderWidth(useScreen?: boolean): number;
  100932. getRenderHeight(useScreen?: boolean): number;
  100933. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  100934. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  100935. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  100936. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  100937. bindSamplers(effect: Effect): void;
  100938. enableEffect(effect: Effect): void;
  100939. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  100940. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  100941. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  100942. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  100943. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  100944. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  100945. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  100946. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  100947. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  100948. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  100949. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  100950. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  100951. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  100952. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  100953. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  100954. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  100955. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  100956. setFloat(uniform: WebGLUniformLocation, value: number): void;
  100957. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  100958. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  100959. setBool(uniform: WebGLUniformLocation, bool: number): void;
  100960. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  100961. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  100962. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  100963. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  100964. bindBuffers(vertexBuffers: {
  100965. [key: string]: VertexBuffer;
  100966. }, indexBuffer: DataBuffer, effect: Effect): void;
  100967. wipeCaches(bruteForce?: boolean): void;
  100968. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  100969. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  100970. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  100971. /** @hidden */
  100972. _createTexture(): WebGLTexture;
  100973. /** @hidden */
  100974. _releaseTexture(texture: InternalTexture): void;
  100975. 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;
  100976. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  100977. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  100978. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  100979. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  100980. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  100981. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  100982. areAllEffectsReady(): boolean;
  100983. /**
  100984. * @hidden
  100985. * Get the current error code of the webGL context
  100986. * @returns the error code
  100987. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  100988. */
  100989. getError(): number;
  100990. /** @hidden */
  100991. _getUnpackAlignement(): number;
  100992. /** @hidden */
  100993. _unpackFlipY(value: boolean): void;
  100994. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  100995. /**
  100996. * Updates a dynamic vertex buffer.
  100997. * @param vertexBuffer the vertex buffer to update
  100998. * @param data the data used to update the vertex buffer
  100999. * @param byteOffset the byte offset of the data (optional)
  101000. * @param byteLength the byte length of the data (optional)
  101001. */
  101002. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  101003. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  101004. /** @hidden */
  101005. _bindTexture(channel: number, texture: InternalTexture): void;
  101006. /** @hidden */
  101007. _releaseBuffer(buffer: DataBuffer): boolean;
  101008. releaseEffects(): void;
  101009. displayLoadingUI(): void;
  101010. hideLoadingUI(): void;
  101011. /** @hidden */
  101012. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101013. /** @hidden */
  101014. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101015. /** @hidden */
  101016. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101017. /** @hidden */
  101018. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  101019. }
  101020. }
  101021. declare module BABYLON {
  101022. /** @hidden */
  101023. export class _OcclusionDataStorage {
  101024. /** @hidden */
  101025. occlusionInternalRetryCounter: number;
  101026. /** @hidden */
  101027. isOcclusionQueryInProgress: boolean;
  101028. /** @hidden */
  101029. isOccluded: boolean;
  101030. /** @hidden */
  101031. occlusionRetryCount: number;
  101032. /** @hidden */
  101033. occlusionType: number;
  101034. /** @hidden */
  101035. occlusionQueryAlgorithmType: number;
  101036. }
  101037. interface Engine {
  101038. /**
  101039. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  101040. * @return the new query
  101041. */
  101042. createQuery(): WebGLQuery;
  101043. /**
  101044. * Delete and release a webGL query
  101045. * @param query defines the query to delete
  101046. * @return the current engine
  101047. */
  101048. deleteQuery(query: WebGLQuery): Engine;
  101049. /**
  101050. * Check if a given query has resolved and got its value
  101051. * @param query defines the query to check
  101052. * @returns true if the query got its value
  101053. */
  101054. isQueryResultAvailable(query: WebGLQuery): boolean;
  101055. /**
  101056. * Gets the value of a given query
  101057. * @param query defines the query to check
  101058. * @returns the value of the query
  101059. */
  101060. getQueryResult(query: WebGLQuery): number;
  101061. /**
  101062. * Initiates an occlusion query
  101063. * @param algorithmType defines the algorithm to use
  101064. * @param query defines the query to use
  101065. * @returns the current engine
  101066. * @see http://doc.babylonjs.com/features/occlusionquery
  101067. */
  101068. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  101069. /**
  101070. * Ends an occlusion query
  101071. * @see http://doc.babylonjs.com/features/occlusionquery
  101072. * @param algorithmType defines the algorithm to use
  101073. * @returns the current engine
  101074. */
  101075. endOcclusionQuery(algorithmType: number): Engine;
  101076. /**
  101077. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  101078. * Please note that only one query can be issued at a time
  101079. * @returns a time token used to track the time span
  101080. */
  101081. startTimeQuery(): Nullable<_TimeToken>;
  101082. /**
  101083. * Ends a time query
  101084. * @param token defines the token used to measure the time span
  101085. * @returns the time spent (in ns)
  101086. */
  101087. endTimeQuery(token: _TimeToken): int;
  101088. /** @hidden */
  101089. _currentNonTimestampToken: Nullable<_TimeToken>;
  101090. /** @hidden */
  101091. _createTimeQuery(): WebGLQuery;
  101092. /** @hidden */
  101093. _deleteTimeQuery(query: WebGLQuery): void;
  101094. /** @hidden */
  101095. _getGlAlgorithmType(algorithmType: number): number;
  101096. /** @hidden */
  101097. _getTimeQueryResult(query: WebGLQuery): any;
  101098. /** @hidden */
  101099. _getTimeQueryAvailability(query: WebGLQuery): any;
  101100. }
  101101. interface AbstractMesh {
  101102. /**
  101103. * Backing filed
  101104. * @hidden
  101105. */
  101106. __occlusionDataStorage: _OcclusionDataStorage;
  101107. /**
  101108. * Access property
  101109. * @hidden
  101110. */
  101111. _occlusionDataStorage: _OcclusionDataStorage;
  101112. /**
  101113. * 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.
  101114. * The default value is -1 which means don't break the query and wait till the result
  101115. * @see http://doc.babylonjs.com/features/occlusionquery
  101116. */
  101117. occlusionRetryCount: number;
  101118. /**
  101119. * 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:
  101120. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  101121. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  101122. * * 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.
  101123. * @see http://doc.babylonjs.com/features/occlusionquery
  101124. */
  101125. occlusionType: number;
  101126. /**
  101127. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  101128. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  101129. * * 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.
  101130. * @see http://doc.babylonjs.com/features/occlusionquery
  101131. */
  101132. occlusionQueryAlgorithmType: number;
  101133. /**
  101134. * 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
  101135. * @see http://doc.babylonjs.com/features/occlusionquery
  101136. */
  101137. isOccluded: boolean;
  101138. /**
  101139. * Flag to check the progress status of the query
  101140. * @see http://doc.babylonjs.com/features/occlusionquery
  101141. */
  101142. isOcclusionQueryInProgress: boolean;
  101143. }
  101144. }
  101145. declare module BABYLON {
  101146. /** @hidden */
  101147. export var _forceTransformFeedbackToBundle: boolean;
  101148. interface Engine {
  101149. /**
  101150. * Creates a webGL transform feedback object
  101151. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  101152. * @returns the webGL transform feedback object
  101153. */
  101154. createTransformFeedback(): WebGLTransformFeedback;
  101155. /**
  101156. * Delete a webGL transform feedback object
  101157. * @param value defines the webGL transform feedback object to delete
  101158. */
  101159. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  101160. /**
  101161. * Bind a webGL transform feedback object to the webgl context
  101162. * @param value defines the webGL transform feedback object to bind
  101163. */
  101164. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  101165. /**
  101166. * Begins a transform feedback operation
  101167. * @param usePoints defines if points or triangles must be used
  101168. */
  101169. beginTransformFeedback(usePoints: boolean): void;
  101170. /**
  101171. * Ends a transform feedback operation
  101172. */
  101173. endTransformFeedback(): void;
  101174. /**
  101175. * Specify the varyings to use with transform feedback
  101176. * @param program defines the associated webGL program
  101177. * @param value defines the list of strings representing the varying names
  101178. */
  101179. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  101180. /**
  101181. * Bind a webGL buffer for a transform feedback operation
  101182. * @param value defines the webGL buffer to bind
  101183. */
  101184. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  101185. }
  101186. }
  101187. declare module BABYLON {
  101188. /**
  101189. * Creation options of the multi render target texture.
  101190. */
  101191. export interface IMultiRenderTargetOptions {
  101192. /**
  101193. * Define if the texture needs to create mip maps after render.
  101194. */
  101195. generateMipMaps?: boolean;
  101196. /**
  101197. * Define the types of all the draw buffers we want to create
  101198. */
  101199. types?: number[];
  101200. /**
  101201. * Define the sampling modes of all the draw buffers we want to create
  101202. */
  101203. samplingModes?: number[];
  101204. /**
  101205. * Define if a depth buffer is required
  101206. */
  101207. generateDepthBuffer?: boolean;
  101208. /**
  101209. * Define if a stencil buffer is required
  101210. */
  101211. generateStencilBuffer?: boolean;
  101212. /**
  101213. * Define if a depth texture is required instead of a depth buffer
  101214. */
  101215. generateDepthTexture?: boolean;
  101216. /**
  101217. * Define the number of desired draw buffers
  101218. */
  101219. textureCount?: number;
  101220. /**
  101221. * Define if aspect ratio should be adapted to the texture or stay the scene one
  101222. */
  101223. doNotChangeAspectRatio?: boolean;
  101224. /**
  101225. * Define the default type of the buffers we are creating
  101226. */
  101227. defaultType?: number;
  101228. }
  101229. /**
  101230. * A multi render target, like a render target provides the ability to render to a texture.
  101231. * Unlike the render target, it can render to several draw buffers in one draw.
  101232. * This is specially interesting in deferred rendering or for any effects requiring more than
  101233. * just one color from a single pass.
  101234. */
  101235. export class MultiRenderTarget extends RenderTargetTexture {
  101236. private _internalTextures;
  101237. private _textures;
  101238. private _multiRenderTargetOptions;
  101239. /**
  101240. * Get if draw buffers are currently supported by the used hardware and browser.
  101241. */
  101242. readonly isSupported: boolean;
  101243. /**
  101244. * Get the list of textures generated by the multi render target.
  101245. */
  101246. readonly textures: Texture[];
  101247. /**
  101248. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  101249. */
  101250. readonly depthTexture: Texture;
  101251. /**
  101252. * Set the wrapping mode on U of all the textures we are rendering to.
  101253. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  101254. */
  101255. wrapU: number;
  101256. /**
  101257. * Set the wrapping mode on V of all the textures we are rendering to.
  101258. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  101259. */
  101260. wrapV: number;
  101261. /**
  101262. * Instantiate a new multi render target texture.
  101263. * A multi render target, like a render target provides the ability to render to a texture.
  101264. * Unlike the render target, it can render to several draw buffers in one draw.
  101265. * This is specially interesting in deferred rendering or for any effects requiring more than
  101266. * just one color from a single pass.
  101267. * @param name Define the name of the texture
  101268. * @param size Define the size of the buffers to render to
  101269. * @param count Define the number of target we are rendering into
  101270. * @param scene Define the scene the texture belongs to
  101271. * @param options Define the options used to create the multi render target
  101272. */
  101273. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  101274. /** @hidden */
  101275. _rebuild(): void;
  101276. private _createInternalTextures;
  101277. private _createTextures;
  101278. /**
  101279. * Define the number of samples used if MSAA is enabled.
  101280. */
  101281. samples: number;
  101282. /**
  101283. * Resize all the textures in the multi render target.
  101284. * Be carrefull as it will recreate all the data in the new texture.
  101285. * @param size Define the new size
  101286. */
  101287. resize(size: any): void;
  101288. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  101289. /**
  101290. * Dispose the render targets and their associated resources
  101291. */
  101292. dispose(): void;
  101293. /**
  101294. * Release all the underlying texture used as draw buffers.
  101295. */
  101296. releaseInternalTextures(): void;
  101297. }
  101298. }
  101299. declare module BABYLON {
  101300. interface Engine {
  101301. /**
  101302. * Unbind a list of render target textures from the webGL context
  101303. * This is used only when drawBuffer extension or webGL2 are active
  101304. * @param textures defines the render target textures to unbind
  101305. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  101306. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  101307. */
  101308. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  101309. /**
  101310. * Create a multi render target texture
  101311. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  101312. * @param size defines the size of the texture
  101313. * @param options defines the creation options
  101314. * @returns the cube texture as an InternalTexture
  101315. */
  101316. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  101317. /**
  101318. * Update the sample count for a given multiple render target texture
  101319. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  101320. * @param textures defines the textures to update
  101321. * @param samples defines the sample count to set
  101322. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  101323. */
  101324. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  101325. }
  101326. }
  101327. declare module BABYLON {
  101328. /**
  101329. * Gather the list of clipboard event types as constants.
  101330. */
  101331. export class ClipboardEventTypes {
  101332. /**
  101333. * The clipboard event is fired when a copy command is active (pressed).
  101334. */
  101335. static readonly COPY: number;
  101336. /**
  101337. * The clipboard event is fired when a cut command is active (pressed).
  101338. */
  101339. static readonly CUT: number;
  101340. /**
  101341. * The clipboard event is fired when a paste command is active (pressed).
  101342. */
  101343. static readonly PASTE: number;
  101344. }
  101345. /**
  101346. * This class is used to store clipboard related info for the onClipboardObservable event.
  101347. */
  101348. export class ClipboardInfo {
  101349. /**
  101350. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101351. */
  101352. type: number;
  101353. /**
  101354. * Defines the related dom event
  101355. */
  101356. event: ClipboardEvent;
  101357. /**
  101358. *Creates an instance of ClipboardInfo.
  101359. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  101360. * @param event Defines the related dom event
  101361. */
  101362. constructor(
  101363. /**
  101364. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101365. */
  101366. type: number,
  101367. /**
  101368. * Defines the related dom event
  101369. */
  101370. event: ClipboardEvent);
  101371. /**
  101372. * Get the clipboard event's type from the keycode.
  101373. * @param keyCode Defines the keyCode for the current keyboard event.
  101374. * @return {number}
  101375. */
  101376. static GetTypeFromCharacter(keyCode: number): number;
  101377. }
  101378. }
  101379. declare module BABYLON {
  101380. /**
  101381. * Class used to represent data loading progression
  101382. */
  101383. export class SceneLoaderProgressEvent {
  101384. /** defines if data length to load can be evaluated */
  101385. readonly lengthComputable: boolean;
  101386. /** defines the loaded data length */
  101387. readonly loaded: number;
  101388. /** defines the data length to load */
  101389. readonly total: number;
  101390. /**
  101391. * Create a new progress event
  101392. * @param lengthComputable defines if data length to load can be evaluated
  101393. * @param loaded defines the loaded data length
  101394. * @param total defines the data length to load
  101395. */
  101396. constructor(
  101397. /** defines if data length to load can be evaluated */
  101398. lengthComputable: boolean,
  101399. /** defines the loaded data length */
  101400. loaded: number,
  101401. /** defines the data length to load */
  101402. total: number);
  101403. /**
  101404. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  101405. * @param event defines the source event
  101406. * @returns a new SceneLoaderProgressEvent
  101407. */
  101408. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  101409. }
  101410. /**
  101411. * Interface used by SceneLoader plugins to define supported file extensions
  101412. */
  101413. export interface ISceneLoaderPluginExtensions {
  101414. /**
  101415. * Defines the list of supported extensions
  101416. */
  101417. [extension: string]: {
  101418. isBinary: boolean;
  101419. };
  101420. }
  101421. /**
  101422. * Interface used by SceneLoader plugin factory
  101423. */
  101424. export interface ISceneLoaderPluginFactory {
  101425. /**
  101426. * Defines the name of the factory
  101427. */
  101428. name: string;
  101429. /**
  101430. * Function called to create a new plugin
  101431. * @return the new plugin
  101432. */
  101433. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  101434. /**
  101435. * Boolean indicating if the plugin can direct load specific data
  101436. */
  101437. canDirectLoad?: (data: string) => boolean;
  101438. }
  101439. /**
  101440. * Interface used to define a SceneLoader plugin
  101441. */
  101442. export interface ISceneLoaderPlugin {
  101443. /**
  101444. * The friendly name of this plugin.
  101445. */
  101446. name: string;
  101447. /**
  101448. * The file extensions supported by this plugin.
  101449. */
  101450. extensions: string | ISceneLoaderPluginExtensions;
  101451. /**
  101452. * Import meshes into a scene.
  101453. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101454. * @param scene The scene to import into
  101455. * @param data The data to import
  101456. * @param rootUrl The root url for scene and resources
  101457. * @param meshes The meshes array to import into
  101458. * @param particleSystems The particle systems array to import into
  101459. * @param skeletons The skeletons array to import into
  101460. * @param onError The callback when import fails
  101461. * @returns True if successful or false otherwise
  101462. */
  101463. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  101464. /**
  101465. * Load into a scene.
  101466. * @param scene The scene to load into
  101467. * @param data The data to import
  101468. * @param rootUrl The root url for scene and resources
  101469. * @param onError The callback when import fails
  101470. * @returns true if successful or false otherwise
  101471. */
  101472. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  101473. /**
  101474. * The callback that returns true if the data can be directly loaded.
  101475. */
  101476. canDirectLoad?: (data: string) => boolean;
  101477. /**
  101478. * The callback that allows custom handling of the root url based on the response url.
  101479. */
  101480. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  101481. /**
  101482. * Load into an asset container.
  101483. * @param scene The scene to load into
  101484. * @param data The data to import
  101485. * @param rootUrl The root url for scene and resources
  101486. * @param onError The callback when import fails
  101487. * @returns The loaded asset container
  101488. */
  101489. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  101490. }
  101491. /**
  101492. * Interface used to define an async SceneLoader plugin
  101493. */
  101494. export interface ISceneLoaderPluginAsync {
  101495. /**
  101496. * The friendly name of this plugin.
  101497. */
  101498. name: string;
  101499. /**
  101500. * The file extensions supported by this plugin.
  101501. */
  101502. extensions: string | ISceneLoaderPluginExtensions;
  101503. /**
  101504. * Import meshes into a scene.
  101505. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101506. * @param scene The scene to import into
  101507. * @param data The data to import
  101508. * @param rootUrl The root url for scene and resources
  101509. * @param onProgress The callback when the load progresses
  101510. * @param fileName Defines the name of the file to load
  101511. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  101512. */
  101513. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  101514. meshes: AbstractMesh[];
  101515. particleSystems: IParticleSystem[];
  101516. skeletons: Skeleton[];
  101517. animationGroups: AnimationGroup[];
  101518. }>;
  101519. /**
  101520. * Load into a scene.
  101521. * @param scene The scene to load into
  101522. * @param data The data to import
  101523. * @param rootUrl The root url for scene and resources
  101524. * @param onProgress The callback when the load progresses
  101525. * @param fileName Defines the name of the file to load
  101526. * @returns Nothing
  101527. */
  101528. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  101529. /**
  101530. * The callback that returns true if the data can be directly loaded.
  101531. */
  101532. canDirectLoad?: (data: string) => boolean;
  101533. /**
  101534. * The callback that allows custom handling of the root url based on the response url.
  101535. */
  101536. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  101537. /**
  101538. * Load into an asset container.
  101539. * @param scene The scene to load into
  101540. * @param data The data to import
  101541. * @param rootUrl The root url for scene and resources
  101542. * @param onProgress The callback when the load progresses
  101543. * @param fileName Defines the name of the file to load
  101544. * @returns The loaded asset container
  101545. */
  101546. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  101547. }
  101548. /**
  101549. * Class used to load scene from various file formats using registered plugins
  101550. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  101551. */
  101552. export class SceneLoader {
  101553. /**
  101554. * No logging while loading
  101555. */
  101556. static readonly NO_LOGGING: number;
  101557. /**
  101558. * Minimal logging while loading
  101559. */
  101560. static readonly MINIMAL_LOGGING: number;
  101561. /**
  101562. * Summary logging while loading
  101563. */
  101564. static readonly SUMMARY_LOGGING: number;
  101565. /**
  101566. * Detailled logging while loading
  101567. */
  101568. static readonly DETAILED_LOGGING: number;
  101569. /**
  101570. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  101571. */
  101572. static ForceFullSceneLoadingForIncremental: boolean;
  101573. /**
  101574. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  101575. */
  101576. static ShowLoadingScreen: boolean;
  101577. /**
  101578. * Defines the current logging level (while loading the scene)
  101579. * @ignorenaming
  101580. */
  101581. static loggingLevel: number;
  101582. /**
  101583. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  101584. */
  101585. static CleanBoneMatrixWeights: boolean;
  101586. /**
  101587. * Event raised when a plugin is used to load a scene
  101588. */
  101589. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  101590. private static _registeredPlugins;
  101591. private static _getDefaultPlugin;
  101592. private static _getPluginForExtension;
  101593. private static _getPluginForDirectLoad;
  101594. private static _getPluginForFilename;
  101595. private static _getDirectLoad;
  101596. private static _loadData;
  101597. private static _getFileInfo;
  101598. /**
  101599. * Gets a plugin that can load the given extension
  101600. * @param extension defines the extension to load
  101601. * @returns a plugin or null if none works
  101602. */
  101603. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  101604. /**
  101605. * Gets a boolean indicating that the given extension can be loaded
  101606. * @param extension defines the extension to load
  101607. * @returns true if the extension is supported
  101608. */
  101609. static IsPluginForExtensionAvailable(extension: string): boolean;
  101610. /**
  101611. * Adds a new plugin to the list of registered plugins
  101612. * @param plugin defines the plugin to add
  101613. */
  101614. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  101615. /**
  101616. * Import meshes into a scene
  101617. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101618. * @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)
  101619. * @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)
  101620. * @param scene the instance of BABYLON.Scene to append to
  101621. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  101622. * @param onProgress a callback with a progress event for each file being loaded
  101623. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101624. * @param pluginExtension the extension used to determine the plugin
  101625. * @returns The loaded plugin
  101626. */
  101627. 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>;
  101628. /**
  101629. * Import meshes into a scene
  101630. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101631. * @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)
  101632. * @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)
  101633. * @param scene the instance of BABYLON.Scene to append to
  101634. * @param onProgress a callback with a progress event for each file being loaded
  101635. * @param pluginExtension the extension used to determine the plugin
  101636. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  101637. */
  101638. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  101639. meshes: AbstractMesh[];
  101640. particleSystems: IParticleSystem[];
  101641. skeletons: Skeleton[];
  101642. animationGroups: AnimationGroup[];
  101643. }>;
  101644. /**
  101645. * Load a scene
  101646. * @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)
  101647. * @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)
  101648. * @param engine is the instance of BABYLON.Engine to use to create the scene
  101649. * @param onSuccess a callback with the scene when import succeeds
  101650. * @param onProgress a callback with a progress event for each file being loaded
  101651. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101652. * @param pluginExtension the extension used to determine the plugin
  101653. * @returns The loaded plugin
  101654. */
  101655. 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>;
  101656. /**
  101657. * Load a scene
  101658. * @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)
  101659. * @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)
  101660. * @param engine is the instance of BABYLON.Engine to use to create the scene
  101661. * @param onProgress a callback with a progress event for each file being loaded
  101662. * @param pluginExtension the extension used to determine the plugin
  101663. * @returns The loaded scene
  101664. */
  101665. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  101666. /**
  101667. * Append a scene
  101668. * @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)
  101669. * @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)
  101670. * @param scene is the instance of BABYLON.Scene to append to
  101671. * @param onSuccess a callback with the scene when import succeeds
  101672. * @param onProgress a callback with a progress event for each file being loaded
  101673. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101674. * @param pluginExtension the extension used to determine the plugin
  101675. * @returns The loaded plugin
  101676. */
  101677. 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>;
  101678. /**
  101679. * Append a scene
  101680. * @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)
  101681. * @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)
  101682. * @param scene is the instance of BABYLON.Scene to append to
  101683. * @param onProgress a callback with a progress event for each file being loaded
  101684. * @param pluginExtension the extension used to determine the plugin
  101685. * @returns The given scene
  101686. */
  101687. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  101688. /**
  101689. * Load a scene into an asset container
  101690. * @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)
  101691. * @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)
  101692. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  101693. * @param onSuccess a callback with the scene when import succeeds
  101694. * @param onProgress a callback with a progress event for each file being loaded
  101695. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101696. * @param pluginExtension the extension used to determine the plugin
  101697. * @returns The loaded plugin
  101698. */
  101699. 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>;
  101700. /**
  101701. * Load a scene into an asset container
  101702. * @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)
  101703. * @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)
  101704. * @param scene is the instance of Scene to append to
  101705. * @param onProgress a callback with a progress event for each file being loaded
  101706. * @param pluginExtension the extension used to determine the plugin
  101707. * @returns The loaded asset container
  101708. */
  101709. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  101710. }
  101711. }
  101712. declare module BABYLON {
  101713. /**
  101714. * Google Daydream controller
  101715. */
  101716. export class DaydreamController extends WebVRController {
  101717. /**
  101718. * Base Url for the controller model.
  101719. */
  101720. static MODEL_BASE_URL: string;
  101721. /**
  101722. * File name for the controller model.
  101723. */
  101724. static MODEL_FILENAME: string;
  101725. /**
  101726. * Gamepad Id prefix used to identify Daydream Controller.
  101727. */
  101728. static readonly GAMEPAD_ID_PREFIX: string;
  101729. /**
  101730. * Creates a new DaydreamController from a gamepad
  101731. * @param vrGamepad the gamepad that the controller should be created from
  101732. */
  101733. constructor(vrGamepad: any);
  101734. /**
  101735. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101736. * @param scene scene in which to add meshes
  101737. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101738. */
  101739. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101740. /**
  101741. * Called once for each button that changed state since the last frame
  101742. * @param buttonIdx Which button index changed
  101743. * @param state New state of the button
  101744. * @param changes Which properties on the state changed since last frame
  101745. */
  101746. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101747. }
  101748. }
  101749. declare module BABYLON {
  101750. /**
  101751. * Gear VR Controller
  101752. */
  101753. export class GearVRController extends WebVRController {
  101754. /**
  101755. * Base Url for the controller model.
  101756. */
  101757. static MODEL_BASE_URL: string;
  101758. /**
  101759. * File name for the controller model.
  101760. */
  101761. static MODEL_FILENAME: string;
  101762. /**
  101763. * Gamepad Id prefix used to identify this controller.
  101764. */
  101765. static readonly GAMEPAD_ID_PREFIX: string;
  101766. private readonly _buttonIndexToObservableNameMap;
  101767. /**
  101768. * Creates a new GearVRController from a gamepad
  101769. * @param vrGamepad the gamepad that the controller should be created from
  101770. */
  101771. constructor(vrGamepad: any);
  101772. /**
  101773. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101774. * @param scene scene in which to add meshes
  101775. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101776. */
  101777. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101778. /**
  101779. * Called once for each button that changed state since the last frame
  101780. * @param buttonIdx Which button index changed
  101781. * @param state New state of the button
  101782. * @param changes Which properties on the state changed since last frame
  101783. */
  101784. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101785. }
  101786. }
  101787. declare module BABYLON {
  101788. /**
  101789. * Generic Controller
  101790. */
  101791. export class GenericController extends WebVRController {
  101792. /**
  101793. * Base Url for the controller model.
  101794. */
  101795. static readonly MODEL_BASE_URL: string;
  101796. /**
  101797. * File name for the controller model.
  101798. */
  101799. static readonly MODEL_FILENAME: string;
  101800. /**
  101801. * Creates a new GenericController from a gamepad
  101802. * @param vrGamepad the gamepad that the controller should be created from
  101803. */
  101804. constructor(vrGamepad: any);
  101805. /**
  101806. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101807. * @param scene scene in which to add meshes
  101808. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101809. */
  101810. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101811. /**
  101812. * Called once for each button that changed state since the last frame
  101813. * @param buttonIdx Which button index changed
  101814. * @param state New state of the button
  101815. * @param changes Which properties on the state changed since last frame
  101816. */
  101817. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101818. }
  101819. }
  101820. declare module BABYLON {
  101821. /**
  101822. * Oculus Touch Controller
  101823. */
  101824. export class OculusTouchController extends WebVRController {
  101825. /**
  101826. * Base Url for the controller model.
  101827. */
  101828. static MODEL_BASE_URL: string;
  101829. /**
  101830. * File name for the left controller model.
  101831. */
  101832. static MODEL_LEFT_FILENAME: string;
  101833. /**
  101834. * File name for the right controller model.
  101835. */
  101836. static MODEL_RIGHT_FILENAME: string;
  101837. /**
  101838. * Fired when the secondary trigger on this controller is modified
  101839. */
  101840. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  101841. /**
  101842. * Fired when the thumb rest on this controller is modified
  101843. */
  101844. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  101845. /**
  101846. * Creates a new OculusTouchController from a gamepad
  101847. * @param vrGamepad the gamepad that the controller should be created from
  101848. */
  101849. constructor(vrGamepad: any);
  101850. /**
  101851. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101852. * @param scene scene in which to add meshes
  101853. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101854. */
  101855. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101856. /**
  101857. * Fired when the A button on this controller is modified
  101858. */
  101859. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101860. /**
  101861. * Fired when the B button on this controller is modified
  101862. */
  101863. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101864. /**
  101865. * Fired when the X button on this controller is modified
  101866. */
  101867. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101868. /**
  101869. * Fired when the Y button on this controller is modified
  101870. */
  101871. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101872. /**
  101873. * Called once for each button that changed state since the last frame
  101874. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  101875. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  101876. * 2) secondary trigger (same)
  101877. * 3) A (right) X (left), touch, pressed = value
  101878. * 4) B / Y
  101879. * 5) thumb rest
  101880. * @param buttonIdx Which button index changed
  101881. * @param state New state of the button
  101882. * @param changes Which properties on the state changed since last frame
  101883. */
  101884. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101885. }
  101886. }
  101887. declare module BABYLON {
  101888. /**
  101889. * Vive Controller
  101890. */
  101891. export class ViveController extends WebVRController {
  101892. /**
  101893. * Base Url for the controller model.
  101894. */
  101895. static MODEL_BASE_URL: string;
  101896. /**
  101897. * File name for the controller model.
  101898. */
  101899. static MODEL_FILENAME: string;
  101900. /**
  101901. * Creates a new ViveController from a gamepad
  101902. * @param vrGamepad the gamepad that the controller should be created from
  101903. */
  101904. constructor(vrGamepad: any);
  101905. /**
  101906. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101907. * @param scene scene in which to add meshes
  101908. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101909. */
  101910. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101911. /**
  101912. * Fired when the left button on this controller is modified
  101913. */
  101914. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101915. /**
  101916. * Fired when the right button on this controller is modified
  101917. */
  101918. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101919. /**
  101920. * Fired when the menu button on this controller is modified
  101921. */
  101922. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101923. /**
  101924. * Called once for each button that changed state since the last frame
  101925. * Vive mapping:
  101926. * 0: touchpad
  101927. * 1: trigger
  101928. * 2: left AND right buttons
  101929. * 3: menu button
  101930. * @param buttonIdx Which button index changed
  101931. * @param state New state of the button
  101932. * @param changes Which properties on the state changed since last frame
  101933. */
  101934. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101935. }
  101936. }
  101937. declare module BABYLON {
  101938. /**
  101939. * Defines the WindowsMotionController object that the state of the windows motion controller
  101940. */
  101941. export class WindowsMotionController extends WebVRController {
  101942. /**
  101943. * The base url used to load the left and right controller models
  101944. */
  101945. static MODEL_BASE_URL: string;
  101946. /**
  101947. * The name of the left controller model file
  101948. */
  101949. static MODEL_LEFT_FILENAME: string;
  101950. /**
  101951. * The name of the right controller model file
  101952. */
  101953. static MODEL_RIGHT_FILENAME: string;
  101954. /**
  101955. * The controller name prefix for this controller type
  101956. */
  101957. static readonly GAMEPAD_ID_PREFIX: string;
  101958. /**
  101959. * The controller id pattern for this controller type
  101960. */
  101961. private static readonly GAMEPAD_ID_PATTERN;
  101962. private _loadedMeshInfo;
  101963. private readonly _mapping;
  101964. /**
  101965. * Fired when the trackpad on this controller is clicked
  101966. */
  101967. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  101968. /**
  101969. * Fired when the trackpad on this controller is modified
  101970. */
  101971. onTrackpadValuesChangedObservable: Observable<StickValues>;
  101972. /**
  101973. * The current x and y values of this controller's trackpad
  101974. */
  101975. trackpad: StickValues;
  101976. /**
  101977. * Creates a new WindowsMotionController from a gamepad
  101978. * @param vrGamepad the gamepad that the controller should be created from
  101979. */
  101980. constructor(vrGamepad: any);
  101981. /**
  101982. * Fired when the trigger on this controller is modified
  101983. */
  101984. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101985. /**
  101986. * Fired when the menu button on this controller is modified
  101987. */
  101988. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101989. /**
  101990. * Fired when the grip button on this controller is modified
  101991. */
  101992. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101993. /**
  101994. * Fired when the thumbstick button on this controller is modified
  101995. */
  101996. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101997. /**
  101998. * Fired when the touchpad button on this controller is modified
  101999. */
  102000. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102001. /**
  102002. * Fired when the touchpad values on this controller are modified
  102003. */
  102004. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  102005. private _updateTrackpad;
  102006. /**
  102007. * Called once per frame by the engine.
  102008. */
  102009. update(): void;
  102010. /**
  102011. * Called once for each button that changed state since the last frame
  102012. * @param buttonIdx Which button index changed
  102013. * @param state New state of the button
  102014. * @param changes Which properties on the state changed since last frame
  102015. */
  102016. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102017. /**
  102018. * Moves the buttons on the controller mesh based on their current state
  102019. * @param buttonName the name of the button to move
  102020. * @param buttonValue the value of the button which determines the buttons new position
  102021. */
  102022. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  102023. /**
  102024. * Moves the axis on the controller mesh based on its current state
  102025. * @param axis the index of the axis
  102026. * @param axisValue the value of the axis which determines the meshes new position
  102027. * @hidden
  102028. */
  102029. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  102030. /**
  102031. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102032. * @param scene scene in which to add meshes
  102033. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102034. */
  102035. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  102036. /**
  102037. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  102038. * can be transformed by button presses and axes values, based on this._mapping.
  102039. *
  102040. * @param scene scene in which the meshes exist
  102041. * @param meshes list of meshes that make up the controller model to process
  102042. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  102043. */
  102044. private processModel;
  102045. private createMeshInfo;
  102046. /**
  102047. * Gets the ray of the controller in the direction the controller is pointing
  102048. * @param length the length the resulting ray should be
  102049. * @returns a ray in the direction the controller is pointing
  102050. */
  102051. getForwardRay(length?: number): Ray;
  102052. /**
  102053. * Disposes of the controller
  102054. */
  102055. dispose(): void;
  102056. }
  102057. }
  102058. declare module BABYLON {
  102059. /**
  102060. * Single axis scale gizmo
  102061. */
  102062. export class AxisScaleGizmo extends Gizmo {
  102063. private _coloredMaterial;
  102064. /**
  102065. * Drag behavior responsible for the gizmos dragging interactions
  102066. */
  102067. dragBehavior: PointerDragBehavior;
  102068. private _pointerObserver;
  102069. /**
  102070. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102071. */
  102072. snapDistance: number;
  102073. /**
  102074. * Event that fires each time the gizmo snaps to a new location.
  102075. * * snapDistance is the the change in distance
  102076. */
  102077. onSnapObservable: Observable<{
  102078. snapDistance: number;
  102079. }>;
  102080. /**
  102081. * If the scaling operation should be done on all axis (default: false)
  102082. */
  102083. uniformScaling: boolean;
  102084. /**
  102085. * Creates an AxisScaleGizmo
  102086. * @param gizmoLayer The utility layer the gizmo will be added to
  102087. * @param dragAxis The axis which the gizmo will be able to scale on
  102088. * @param color The color of the gizmo
  102089. */
  102090. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  102091. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102092. /**
  102093. * Disposes of the gizmo
  102094. */
  102095. dispose(): void;
  102096. /**
  102097. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  102098. * @param mesh The mesh to replace the default mesh of the gizmo
  102099. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  102100. */
  102101. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  102102. }
  102103. }
  102104. declare module BABYLON {
  102105. /**
  102106. * Bounding box gizmo
  102107. */
  102108. export class BoundingBoxGizmo extends Gizmo {
  102109. private _lineBoundingBox;
  102110. private _rotateSpheresParent;
  102111. private _scaleBoxesParent;
  102112. private _boundingDimensions;
  102113. private _renderObserver;
  102114. private _pointerObserver;
  102115. private _scaleDragSpeed;
  102116. private _tmpQuaternion;
  102117. private _tmpVector;
  102118. private _tmpRotationMatrix;
  102119. /**
  102120. * 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)
  102121. */
  102122. ignoreChildren: boolean;
  102123. /**
  102124. * 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)
  102125. */
  102126. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  102127. /**
  102128. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  102129. */
  102130. rotationSphereSize: number;
  102131. /**
  102132. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  102133. */
  102134. scaleBoxSize: number;
  102135. /**
  102136. * 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)
  102137. */
  102138. fixedDragMeshScreenSize: boolean;
  102139. /**
  102140. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  102141. */
  102142. fixedDragMeshScreenSizeDistanceFactor: number;
  102143. /**
  102144. * Fired when a rotation sphere or scale box is dragged
  102145. */
  102146. onDragStartObservable: Observable<{}>;
  102147. /**
  102148. * Fired when a scale box is dragged
  102149. */
  102150. onScaleBoxDragObservable: Observable<{}>;
  102151. /**
  102152. * Fired when a scale box drag is ended
  102153. */
  102154. onScaleBoxDragEndObservable: Observable<{}>;
  102155. /**
  102156. * Fired when a rotation sphere is dragged
  102157. */
  102158. onRotationSphereDragObservable: Observable<{}>;
  102159. /**
  102160. * Fired when a rotation sphere drag is ended
  102161. */
  102162. onRotationSphereDragEndObservable: Observable<{}>;
  102163. /**
  102164. * 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)
  102165. */
  102166. scalePivot: Nullable<Vector3>;
  102167. /**
  102168. * Mesh used as a pivot to rotate the attached mesh
  102169. */
  102170. private _anchorMesh;
  102171. private _existingMeshScale;
  102172. private _dragMesh;
  102173. private pointerDragBehavior;
  102174. private coloredMaterial;
  102175. private hoverColoredMaterial;
  102176. /**
  102177. * Sets the color of the bounding box gizmo
  102178. * @param color the color to set
  102179. */
  102180. setColor(color: Color3): void;
  102181. /**
  102182. * Creates an BoundingBoxGizmo
  102183. * @param gizmoLayer The utility layer the gizmo will be added to
  102184. * @param color The color of the gizmo
  102185. */
  102186. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  102187. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102188. private _selectNode;
  102189. /**
  102190. * Updates the bounding box information for the Gizmo
  102191. */
  102192. updateBoundingBox(): void;
  102193. private _updateRotationSpheres;
  102194. private _updateScaleBoxes;
  102195. /**
  102196. * Enables rotation on the specified axis and disables rotation on the others
  102197. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  102198. */
  102199. setEnabledRotationAxis(axis: string): void;
  102200. /**
  102201. * Enables/disables scaling
  102202. * @param enable if scaling should be enabled
  102203. */
  102204. setEnabledScaling(enable: boolean): void;
  102205. private _updateDummy;
  102206. /**
  102207. * Enables a pointer drag behavior on the bounding box of the gizmo
  102208. */
  102209. enableDragBehavior(): void;
  102210. /**
  102211. * Disposes of the gizmo
  102212. */
  102213. dispose(): void;
  102214. /**
  102215. * 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)
  102216. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  102217. * @returns the bounding box mesh with the passed in mesh as a child
  102218. */
  102219. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  102220. /**
  102221. * CustomMeshes are not supported by this gizmo
  102222. * @param mesh The mesh to replace the default mesh of the gizmo
  102223. */
  102224. setCustomMesh(mesh: Mesh): void;
  102225. }
  102226. }
  102227. declare module BABYLON {
  102228. /**
  102229. * Single plane rotation gizmo
  102230. */
  102231. export class PlaneRotationGizmo extends Gizmo {
  102232. /**
  102233. * Drag behavior responsible for the gizmos dragging interactions
  102234. */
  102235. dragBehavior: PointerDragBehavior;
  102236. private _pointerObserver;
  102237. /**
  102238. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  102239. */
  102240. snapDistance: number;
  102241. /**
  102242. * Event that fires each time the gizmo snaps to a new location.
  102243. * * snapDistance is the the change in distance
  102244. */
  102245. onSnapObservable: Observable<{
  102246. snapDistance: number;
  102247. }>;
  102248. /**
  102249. * Creates a PlaneRotationGizmo
  102250. * @param gizmoLayer The utility layer the gizmo will be added to
  102251. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  102252. * @param color The color of the gizmo
  102253. * @param tessellation Amount of tessellation to be used when creating rotation circles
  102254. */
  102255. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  102256. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102257. /**
  102258. * Disposes of the gizmo
  102259. */
  102260. dispose(): void;
  102261. }
  102262. }
  102263. declare module BABYLON {
  102264. /**
  102265. * Gizmo that enables rotating a mesh along 3 axis
  102266. */
  102267. export class RotationGizmo extends Gizmo {
  102268. /**
  102269. * Internal gizmo used for interactions on the x axis
  102270. */
  102271. xGizmo: PlaneRotationGizmo;
  102272. /**
  102273. * Internal gizmo used for interactions on the y axis
  102274. */
  102275. yGizmo: PlaneRotationGizmo;
  102276. /**
  102277. * Internal gizmo used for interactions on the z axis
  102278. */
  102279. zGizmo: PlaneRotationGizmo;
  102280. /** Fires an event when any of it's sub gizmos are dragged */
  102281. onDragStartObservable: Observable<{}>;
  102282. /** Fires an event when any of it's sub gizmos are released from dragging */
  102283. onDragEndObservable: Observable<{}>;
  102284. attachedMesh: Nullable<AbstractMesh>;
  102285. /**
  102286. * Creates a RotationGizmo
  102287. * @param gizmoLayer The utility layer the gizmo will be added to
  102288. * @param tessellation Amount of tessellation to be used when creating rotation circles
  102289. */
  102290. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  102291. updateGizmoRotationToMatchAttachedMesh: boolean;
  102292. /**
  102293. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102294. */
  102295. snapDistance: number;
  102296. /**
  102297. * Ratio for the scale of the gizmo (Default: 1)
  102298. */
  102299. scaleRatio: number;
  102300. /**
  102301. * Disposes of the gizmo
  102302. */
  102303. dispose(): void;
  102304. /**
  102305. * CustomMeshes are not supported by this gizmo
  102306. * @param mesh The mesh to replace the default mesh of the gizmo
  102307. */
  102308. setCustomMesh(mesh: Mesh): void;
  102309. }
  102310. }
  102311. declare module BABYLON {
  102312. /**
  102313. * Gizmo that enables dragging a mesh along 3 axis
  102314. */
  102315. export class PositionGizmo extends Gizmo {
  102316. /**
  102317. * Internal gizmo used for interactions on the x axis
  102318. */
  102319. xGizmo: AxisDragGizmo;
  102320. /**
  102321. * Internal gizmo used for interactions on the y axis
  102322. */
  102323. yGizmo: AxisDragGizmo;
  102324. /**
  102325. * Internal gizmo used for interactions on the z axis
  102326. */
  102327. zGizmo: AxisDragGizmo;
  102328. /** Fires an event when any of it's sub gizmos are dragged */
  102329. onDragStartObservable: Observable<{}>;
  102330. /** Fires an event when any of it's sub gizmos are released from dragging */
  102331. onDragEndObservable: Observable<{}>;
  102332. attachedMesh: Nullable<AbstractMesh>;
  102333. /**
  102334. * Creates a PositionGizmo
  102335. * @param gizmoLayer The utility layer the gizmo will be added to
  102336. */
  102337. constructor(gizmoLayer?: UtilityLayerRenderer);
  102338. updateGizmoRotationToMatchAttachedMesh: boolean;
  102339. /**
  102340. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102341. */
  102342. snapDistance: number;
  102343. /**
  102344. * Ratio for the scale of the gizmo (Default: 1)
  102345. */
  102346. scaleRatio: number;
  102347. /**
  102348. * Disposes of the gizmo
  102349. */
  102350. dispose(): void;
  102351. /**
  102352. * CustomMeshes are not supported by this gizmo
  102353. * @param mesh The mesh to replace the default mesh of the gizmo
  102354. */
  102355. setCustomMesh(mesh: Mesh): void;
  102356. }
  102357. }
  102358. declare module BABYLON {
  102359. /**
  102360. * Class containing static functions to help procedurally build meshes
  102361. */
  102362. export class PolyhedronBuilder {
  102363. /**
  102364. * Creates a polyhedron mesh
  102365. * * 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
  102366. * * The parameter `size` (positive float, default 1) sets the polygon size
  102367. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  102368. * * 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`
  102369. * * 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
  102370. * * 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)`)
  102371. * * 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
  102372. * * 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
  102373. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102374. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102376. * @param name defines the name of the mesh
  102377. * @param options defines the options used to create the mesh
  102378. * @param scene defines the hosting scene
  102379. * @returns the polyhedron mesh
  102380. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  102381. */
  102382. static CreatePolyhedron(name: string, options: {
  102383. type?: number;
  102384. size?: number;
  102385. sizeX?: number;
  102386. sizeY?: number;
  102387. sizeZ?: number;
  102388. custom?: any;
  102389. faceUV?: Vector4[];
  102390. faceColors?: Color4[];
  102391. flat?: boolean;
  102392. updatable?: boolean;
  102393. sideOrientation?: number;
  102394. frontUVs?: Vector4;
  102395. backUVs?: Vector4;
  102396. }, scene?: Nullable<Scene>): Mesh;
  102397. }
  102398. }
  102399. declare module BABYLON {
  102400. /**
  102401. * Gizmo that enables scaling a mesh along 3 axis
  102402. */
  102403. export class ScaleGizmo extends Gizmo {
  102404. /**
  102405. * Internal gizmo used for interactions on the x axis
  102406. */
  102407. xGizmo: AxisScaleGizmo;
  102408. /**
  102409. * Internal gizmo used for interactions on the y axis
  102410. */
  102411. yGizmo: AxisScaleGizmo;
  102412. /**
  102413. * Internal gizmo used for interactions on the z axis
  102414. */
  102415. zGizmo: AxisScaleGizmo;
  102416. /**
  102417. * Internal gizmo used to scale all axis equally
  102418. */
  102419. uniformScaleGizmo: AxisScaleGizmo;
  102420. /** Fires an event when any of it's sub gizmos are dragged */
  102421. onDragStartObservable: Observable<{}>;
  102422. /** Fires an event when any of it's sub gizmos are released from dragging */
  102423. onDragEndObservable: Observable<{}>;
  102424. attachedMesh: Nullable<AbstractMesh>;
  102425. /**
  102426. * Creates a ScaleGizmo
  102427. * @param gizmoLayer The utility layer the gizmo will be added to
  102428. */
  102429. constructor(gizmoLayer?: UtilityLayerRenderer);
  102430. updateGizmoRotationToMatchAttachedMesh: boolean;
  102431. /**
  102432. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102433. */
  102434. snapDistance: number;
  102435. /**
  102436. * Ratio for the scale of the gizmo (Default: 1)
  102437. */
  102438. scaleRatio: number;
  102439. /**
  102440. * Disposes of the gizmo
  102441. */
  102442. dispose(): void;
  102443. }
  102444. }
  102445. declare module BABYLON {
  102446. /**
  102447. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  102448. */
  102449. export class GizmoManager implements IDisposable {
  102450. private scene;
  102451. /**
  102452. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  102453. */
  102454. gizmos: {
  102455. positionGizmo: Nullable<PositionGizmo>;
  102456. rotationGizmo: Nullable<RotationGizmo>;
  102457. scaleGizmo: Nullable<ScaleGizmo>;
  102458. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  102459. };
  102460. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  102461. clearGizmoOnEmptyPointerEvent: boolean;
  102462. /** Fires an event when the manager is attached to a mesh */
  102463. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  102464. private _gizmosEnabled;
  102465. private _pointerObserver;
  102466. private _attachedMesh;
  102467. private _boundingBoxColor;
  102468. private _defaultUtilityLayer;
  102469. private _defaultKeepDepthUtilityLayer;
  102470. /**
  102471. * When bounding box gizmo is enabled, this can be used to track drag/end events
  102472. */
  102473. boundingBoxDragBehavior: SixDofDragBehavior;
  102474. /**
  102475. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  102476. */
  102477. attachableMeshes: Nullable<Array<AbstractMesh>>;
  102478. /**
  102479. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  102480. */
  102481. usePointerToAttachGizmos: boolean;
  102482. /**
  102483. * Instatiates a gizmo manager
  102484. * @param scene the scene to overlay the gizmos on top of
  102485. */
  102486. constructor(scene: Scene);
  102487. /**
  102488. * Attaches a set of gizmos to the specified mesh
  102489. * @param mesh The mesh the gizmo's should be attached to
  102490. */
  102491. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  102492. /**
  102493. * If the position gizmo is enabled
  102494. */
  102495. positionGizmoEnabled: boolean;
  102496. /**
  102497. * If the rotation gizmo is enabled
  102498. */
  102499. rotationGizmoEnabled: boolean;
  102500. /**
  102501. * If the scale gizmo is enabled
  102502. */
  102503. scaleGizmoEnabled: boolean;
  102504. /**
  102505. * If the boundingBox gizmo is enabled
  102506. */
  102507. boundingBoxGizmoEnabled: boolean;
  102508. /**
  102509. * Disposes of the gizmo manager
  102510. */
  102511. dispose(): void;
  102512. }
  102513. }
  102514. declare module BABYLON {
  102515. /**
  102516. * A directional light is defined by a direction (what a surprise!).
  102517. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  102518. * 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.
  102519. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102520. */
  102521. export class DirectionalLight extends ShadowLight {
  102522. private _shadowFrustumSize;
  102523. /**
  102524. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  102525. */
  102526. /**
  102527. * Specifies a fix frustum size for the shadow generation.
  102528. */
  102529. shadowFrustumSize: number;
  102530. private _shadowOrthoScale;
  102531. /**
  102532. * Gets the shadow projection scale against the optimal computed one.
  102533. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102534. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102535. */
  102536. /**
  102537. * Sets the shadow projection scale against the optimal computed one.
  102538. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102539. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102540. */
  102541. shadowOrthoScale: number;
  102542. /**
  102543. * Automatically compute the projection matrix to best fit (including all the casters)
  102544. * on each frame.
  102545. */
  102546. autoUpdateExtends: boolean;
  102547. private _orthoLeft;
  102548. private _orthoRight;
  102549. private _orthoTop;
  102550. private _orthoBottom;
  102551. /**
  102552. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  102553. * The directional light is emitted from everywhere in the given direction.
  102554. * It can cast shadows.
  102555. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102556. * @param name The friendly name of the light
  102557. * @param direction The direction of the light
  102558. * @param scene The scene the light belongs to
  102559. */
  102560. constructor(name: string, direction: Vector3, scene: Scene);
  102561. /**
  102562. * Returns the string "DirectionalLight".
  102563. * @return The class name
  102564. */
  102565. getClassName(): string;
  102566. /**
  102567. * Returns the integer 1.
  102568. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102569. */
  102570. getTypeID(): number;
  102571. /**
  102572. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  102573. * Returns the DirectionalLight Shadow projection matrix.
  102574. */
  102575. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102576. /**
  102577. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  102578. * Returns the DirectionalLight Shadow projection matrix.
  102579. */
  102580. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  102581. /**
  102582. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  102583. * Returns the DirectionalLight Shadow projection matrix.
  102584. */
  102585. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102586. protected _buildUniformLayout(): void;
  102587. /**
  102588. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  102589. * @param effect The effect to update
  102590. * @param lightIndex The index of the light in the effect to update
  102591. * @returns The directional light
  102592. */
  102593. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  102594. /**
  102595. * Gets the minZ used for shadow according to both the scene and the light.
  102596. *
  102597. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102598. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102599. * @param activeCamera The camera we are returning the min for
  102600. * @returns the depth min z
  102601. */
  102602. getDepthMinZ(activeCamera: Camera): number;
  102603. /**
  102604. * Gets the maxZ used for shadow according to both the scene and the light.
  102605. *
  102606. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102607. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102608. * @param activeCamera The camera we are returning the max for
  102609. * @returns the depth max z
  102610. */
  102611. getDepthMaxZ(activeCamera: Camera): number;
  102612. /**
  102613. * Prepares the list of defines specific to the light type.
  102614. * @param defines the list of defines
  102615. * @param lightIndex defines the index of the light for the effect
  102616. */
  102617. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102618. }
  102619. }
  102620. declare module BABYLON {
  102621. /**
  102622. * Class containing static functions to help procedurally build meshes
  102623. */
  102624. export class HemisphereBuilder {
  102625. /**
  102626. * Creates a hemisphere mesh
  102627. * @param name defines the name of the mesh
  102628. * @param options defines the options used to create the mesh
  102629. * @param scene defines the hosting scene
  102630. * @returns the hemisphere mesh
  102631. */
  102632. static CreateHemisphere(name: string, options: {
  102633. segments?: number;
  102634. diameter?: number;
  102635. sideOrientation?: number;
  102636. }, scene: any): Mesh;
  102637. }
  102638. }
  102639. declare module BABYLON {
  102640. /**
  102641. * A spot light is defined by a position, a direction, an angle, and an exponent.
  102642. * These values define a cone of light starting from the position, emitting toward the direction.
  102643. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  102644. * and the exponent defines the speed of the decay of the light with distance (reach).
  102645. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102646. */
  102647. export class SpotLight extends ShadowLight {
  102648. private _angle;
  102649. private _innerAngle;
  102650. private _cosHalfAngle;
  102651. private _lightAngleScale;
  102652. private _lightAngleOffset;
  102653. /**
  102654. * Gets the cone angle of the spot light in Radians.
  102655. */
  102656. /**
  102657. * Sets the cone angle of the spot light in Radians.
  102658. */
  102659. angle: number;
  102660. /**
  102661. * Only used in gltf falloff mode, this defines the angle where
  102662. * the directional falloff will start before cutting at angle which could be seen
  102663. * as outer angle.
  102664. */
  102665. /**
  102666. * Only used in gltf falloff mode, this defines the angle where
  102667. * the directional falloff will start before cutting at angle which could be seen
  102668. * as outer angle.
  102669. */
  102670. innerAngle: number;
  102671. private _shadowAngleScale;
  102672. /**
  102673. * Allows scaling the angle of the light for shadow generation only.
  102674. */
  102675. /**
  102676. * Allows scaling the angle of the light for shadow generation only.
  102677. */
  102678. shadowAngleScale: number;
  102679. /**
  102680. * The light decay speed with the distance from the emission spot.
  102681. */
  102682. exponent: number;
  102683. private _projectionTextureMatrix;
  102684. /**
  102685. * Allows reading the projecton texture
  102686. */
  102687. readonly projectionTextureMatrix: Matrix;
  102688. protected _projectionTextureLightNear: number;
  102689. /**
  102690. * Gets the near clip of the Spotlight for texture projection.
  102691. */
  102692. /**
  102693. * Sets the near clip of the Spotlight for texture projection.
  102694. */
  102695. projectionTextureLightNear: number;
  102696. protected _projectionTextureLightFar: number;
  102697. /**
  102698. * Gets the far clip of the Spotlight for texture projection.
  102699. */
  102700. /**
  102701. * Sets the far clip of the Spotlight for texture projection.
  102702. */
  102703. projectionTextureLightFar: number;
  102704. protected _projectionTextureUpDirection: Vector3;
  102705. /**
  102706. * Gets the Up vector of the Spotlight for texture projection.
  102707. */
  102708. /**
  102709. * Sets the Up vector of the Spotlight for texture projection.
  102710. */
  102711. projectionTextureUpDirection: Vector3;
  102712. private _projectionTexture;
  102713. /**
  102714. * Gets the projection texture of the light.
  102715. */
  102716. /**
  102717. * Sets the projection texture of the light.
  102718. */
  102719. projectionTexture: Nullable<BaseTexture>;
  102720. private _projectionTextureViewLightDirty;
  102721. private _projectionTextureProjectionLightDirty;
  102722. private _projectionTextureDirty;
  102723. private _projectionTextureViewTargetVector;
  102724. private _projectionTextureViewLightMatrix;
  102725. private _projectionTextureProjectionLightMatrix;
  102726. private _projectionTextureScalingMatrix;
  102727. /**
  102728. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  102729. * It can cast shadows.
  102730. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102731. * @param name The light friendly name
  102732. * @param position The position of the spot light in the scene
  102733. * @param direction The direction of the light in the scene
  102734. * @param angle The cone angle of the light in Radians
  102735. * @param exponent The light decay speed with the distance from the emission spot
  102736. * @param scene The scene the lights belongs to
  102737. */
  102738. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  102739. /**
  102740. * Returns the string "SpotLight".
  102741. * @returns the class name
  102742. */
  102743. getClassName(): string;
  102744. /**
  102745. * Returns the integer 2.
  102746. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102747. */
  102748. getTypeID(): number;
  102749. /**
  102750. * Overrides the direction setter to recompute the projection texture view light Matrix.
  102751. */
  102752. protected _setDirection(value: Vector3): void;
  102753. /**
  102754. * Overrides the position setter to recompute the projection texture view light Matrix.
  102755. */
  102756. protected _setPosition(value: Vector3): void;
  102757. /**
  102758. * 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.
  102759. * Returns the SpotLight.
  102760. */
  102761. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102762. protected _computeProjectionTextureViewLightMatrix(): void;
  102763. protected _computeProjectionTextureProjectionLightMatrix(): void;
  102764. /**
  102765. * Main function for light texture projection matrix computing.
  102766. */
  102767. protected _computeProjectionTextureMatrix(): void;
  102768. protected _buildUniformLayout(): void;
  102769. private _computeAngleValues;
  102770. /**
  102771. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  102772. * @param effect The effect to update
  102773. * @param lightIndex The index of the light in the effect to update
  102774. * @returns The spot light
  102775. */
  102776. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  102777. /**
  102778. * Disposes the light and the associated resources.
  102779. */
  102780. dispose(): void;
  102781. /**
  102782. * Prepares the list of defines specific to the light type.
  102783. * @param defines the list of defines
  102784. * @param lightIndex defines the index of the light for the effect
  102785. */
  102786. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102787. }
  102788. }
  102789. declare module BABYLON {
  102790. /**
  102791. * Gizmo that enables viewing a light
  102792. */
  102793. export class LightGizmo extends Gizmo {
  102794. private _lightMesh;
  102795. private _material;
  102796. /**
  102797. * Creates a LightGizmo
  102798. * @param gizmoLayer The utility layer the gizmo will be added to
  102799. */
  102800. constructor(gizmoLayer?: UtilityLayerRenderer);
  102801. private _light;
  102802. /**
  102803. * The light that the gizmo is attached to
  102804. */
  102805. light: Nullable<Light>;
  102806. /**
  102807. * @hidden
  102808. * Updates the gizmo to match the attached mesh's position/rotation
  102809. */
  102810. protected _update(): void;
  102811. private static _Scale;
  102812. /**
  102813. * Creates the lines for a light mesh
  102814. */
  102815. private static _createLightLines;
  102816. private static _CreateHemisphericLightMesh;
  102817. private static _CreatePointLightMesh;
  102818. private static _CreateSpotLightMesh;
  102819. private static _CreateDirectionalLightMesh;
  102820. }
  102821. }
  102822. declare module BABYLON {
  102823. /** @hidden */
  102824. export var backgroundFragmentDeclaration: {
  102825. name: string;
  102826. shader: string;
  102827. };
  102828. }
  102829. declare module BABYLON {
  102830. /** @hidden */
  102831. export var backgroundUboDeclaration: {
  102832. name: string;
  102833. shader: string;
  102834. };
  102835. }
  102836. declare module BABYLON {
  102837. /** @hidden */
  102838. export var backgroundPixelShader: {
  102839. name: string;
  102840. shader: string;
  102841. };
  102842. }
  102843. declare module BABYLON {
  102844. /** @hidden */
  102845. export var backgroundVertexDeclaration: {
  102846. name: string;
  102847. shader: string;
  102848. };
  102849. }
  102850. declare module BABYLON {
  102851. /** @hidden */
  102852. export var backgroundVertexShader: {
  102853. name: string;
  102854. shader: string;
  102855. };
  102856. }
  102857. declare module BABYLON {
  102858. /**
  102859. * Background material used to create an efficient environement around your scene.
  102860. */
  102861. export class BackgroundMaterial extends PushMaterial {
  102862. /**
  102863. * Standard reflectance value at parallel view angle.
  102864. */
  102865. static StandardReflectance0: number;
  102866. /**
  102867. * Standard reflectance value at grazing angle.
  102868. */
  102869. static StandardReflectance90: number;
  102870. protected _primaryColor: Color3;
  102871. /**
  102872. * Key light Color (multiply against the environement texture)
  102873. */
  102874. primaryColor: Color3;
  102875. protected __perceptualColor: Nullable<Color3>;
  102876. /**
  102877. * Experimental Internal Use Only.
  102878. *
  102879. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  102880. * This acts as a helper to set the primary color to a more "human friendly" value.
  102881. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  102882. * output color as close as possible from the chosen value.
  102883. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  102884. * part of lighting setup.)
  102885. */
  102886. _perceptualColor: Nullable<Color3>;
  102887. protected _primaryColorShadowLevel: float;
  102888. /**
  102889. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  102890. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  102891. */
  102892. primaryColorShadowLevel: float;
  102893. protected _primaryColorHighlightLevel: float;
  102894. /**
  102895. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  102896. * The primary color is used at the level chosen to define what the white area would look.
  102897. */
  102898. primaryColorHighlightLevel: float;
  102899. protected _reflectionTexture: Nullable<BaseTexture>;
  102900. /**
  102901. * Reflection Texture used in the material.
  102902. * Should be author in a specific way for the best result (refer to the documentation).
  102903. */
  102904. reflectionTexture: Nullable<BaseTexture>;
  102905. protected _reflectionBlur: float;
  102906. /**
  102907. * Reflection Texture level of blur.
  102908. *
  102909. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  102910. * texture twice.
  102911. */
  102912. reflectionBlur: float;
  102913. protected _diffuseTexture: Nullable<BaseTexture>;
  102914. /**
  102915. * Diffuse Texture used in the material.
  102916. * Should be author in a specific way for the best result (refer to the documentation).
  102917. */
  102918. diffuseTexture: Nullable<BaseTexture>;
  102919. protected _shadowLights: Nullable<IShadowLight[]>;
  102920. /**
  102921. * Specify the list of lights casting shadow on the material.
  102922. * All scene shadow lights will be included if null.
  102923. */
  102924. shadowLights: Nullable<IShadowLight[]>;
  102925. protected _shadowLevel: float;
  102926. /**
  102927. * Helps adjusting the shadow to a softer level if required.
  102928. * 0 means black shadows and 1 means no shadows.
  102929. */
  102930. shadowLevel: float;
  102931. protected _sceneCenter: Vector3;
  102932. /**
  102933. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  102934. * It is usually zero but might be interesting to modify according to your setup.
  102935. */
  102936. sceneCenter: Vector3;
  102937. protected _opacityFresnel: boolean;
  102938. /**
  102939. * This helps specifying that the material is falling off to the sky box at grazing angle.
  102940. * This helps ensuring a nice transition when the camera goes under the ground.
  102941. */
  102942. opacityFresnel: boolean;
  102943. protected _reflectionFresnel: boolean;
  102944. /**
  102945. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  102946. * This helps adding a mirror texture on the ground.
  102947. */
  102948. reflectionFresnel: boolean;
  102949. protected _reflectionFalloffDistance: number;
  102950. /**
  102951. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  102952. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  102953. */
  102954. reflectionFalloffDistance: number;
  102955. protected _reflectionAmount: number;
  102956. /**
  102957. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  102958. */
  102959. reflectionAmount: number;
  102960. protected _reflectionReflectance0: number;
  102961. /**
  102962. * This specifies the weight of the reflection at grazing angle.
  102963. */
  102964. reflectionReflectance0: number;
  102965. protected _reflectionReflectance90: number;
  102966. /**
  102967. * This specifies the weight of the reflection at a perpendicular point of view.
  102968. */
  102969. reflectionReflectance90: number;
  102970. /**
  102971. * Sets the reflection reflectance fresnel values according to the default standard
  102972. * empirically know to work well :-)
  102973. */
  102974. reflectionStandardFresnelWeight: number;
  102975. protected _useRGBColor: boolean;
  102976. /**
  102977. * Helps to directly use the maps channels instead of their level.
  102978. */
  102979. useRGBColor: boolean;
  102980. protected _enableNoise: boolean;
  102981. /**
  102982. * This helps reducing the banding effect that could occur on the background.
  102983. */
  102984. enableNoise: boolean;
  102985. /**
  102986. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  102987. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  102988. * Recommended to be keep at 1.0 except for special cases.
  102989. */
  102990. fovMultiplier: number;
  102991. private _fovMultiplier;
  102992. /**
  102993. * Enable the FOV adjustment feature controlled by fovMultiplier.
  102994. */
  102995. useEquirectangularFOV: boolean;
  102996. private _maxSimultaneousLights;
  102997. /**
  102998. * Number of Simultaneous lights allowed on the material.
  102999. */
  103000. maxSimultaneousLights: int;
  103001. /**
  103002. * Default configuration related to image processing available in the Background Material.
  103003. */
  103004. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103005. /**
  103006. * Keep track of the image processing observer to allow dispose and replace.
  103007. */
  103008. private _imageProcessingObserver;
  103009. /**
  103010. * Attaches a new image processing configuration to the PBR Material.
  103011. * @param configuration (if null the scene configuration will be use)
  103012. */
  103013. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103014. /**
  103015. * Gets the image processing configuration used either in this material.
  103016. */
  103017. /**
  103018. * Sets the Default image processing configuration used either in the this material.
  103019. *
  103020. * If sets to null, the scene one is in use.
  103021. */
  103022. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  103023. /**
  103024. * Gets wether the color curves effect is enabled.
  103025. */
  103026. /**
  103027. * Sets wether the color curves effect is enabled.
  103028. */
  103029. cameraColorCurvesEnabled: boolean;
  103030. /**
  103031. * Gets wether the color grading effect is enabled.
  103032. */
  103033. /**
  103034. * Gets wether the color grading effect is enabled.
  103035. */
  103036. cameraColorGradingEnabled: boolean;
  103037. /**
  103038. * Gets wether tonemapping is enabled or not.
  103039. */
  103040. /**
  103041. * Sets wether tonemapping is enabled or not
  103042. */
  103043. cameraToneMappingEnabled: boolean;
  103044. /**
  103045. * The camera exposure used on this material.
  103046. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103047. * This corresponds to a photographic exposure.
  103048. */
  103049. /**
  103050. * The camera exposure used on this material.
  103051. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103052. * This corresponds to a photographic exposure.
  103053. */
  103054. cameraExposure: float;
  103055. /**
  103056. * Gets The camera contrast used on this material.
  103057. */
  103058. /**
  103059. * Sets The camera contrast used on this material.
  103060. */
  103061. cameraContrast: float;
  103062. /**
  103063. * Gets the Color Grading 2D Lookup Texture.
  103064. */
  103065. /**
  103066. * Sets the Color Grading 2D Lookup Texture.
  103067. */
  103068. cameraColorGradingTexture: Nullable<BaseTexture>;
  103069. /**
  103070. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103071. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103072. * 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;
  103073. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103074. */
  103075. /**
  103076. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103077. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103078. * 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;
  103079. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103080. */
  103081. cameraColorCurves: Nullable<ColorCurves>;
  103082. /**
  103083. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  103084. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  103085. */
  103086. switchToBGR: boolean;
  103087. private _renderTargets;
  103088. private _reflectionControls;
  103089. private _white;
  103090. private _primaryShadowColor;
  103091. private _primaryHighlightColor;
  103092. /**
  103093. * Instantiates a Background Material in the given scene
  103094. * @param name The friendly name of the material
  103095. * @param scene The scene to add the material to
  103096. */
  103097. constructor(name: string, scene: Scene);
  103098. /**
  103099. * Gets a boolean indicating that current material needs to register RTT
  103100. */
  103101. readonly hasRenderTargetTextures: boolean;
  103102. /**
  103103. * The entire material has been created in order to prevent overdraw.
  103104. * @returns false
  103105. */
  103106. needAlphaTesting(): boolean;
  103107. /**
  103108. * The entire material has been created in order to prevent overdraw.
  103109. * @returns true if blending is enable
  103110. */
  103111. needAlphaBlending(): boolean;
  103112. /**
  103113. * Checks wether the material is ready to be rendered for a given mesh.
  103114. * @param mesh The mesh to render
  103115. * @param subMesh The submesh to check against
  103116. * @param useInstances Specify wether or not the material is used with instances
  103117. * @returns true if all the dependencies are ready (Textures, Effects...)
  103118. */
  103119. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103120. /**
  103121. * Compute the primary color according to the chosen perceptual color.
  103122. */
  103123. private _computePrimaryColorFromPerceptualColor;
  103124. /**
  103125. * Compute the highlights and shadow colors according to their chosen levels.
  103126. */
  103127. private _computePrimaryColors;
  103128. /**
  103129. * Build the uniform buffer used in the material.
  103130. */
  103131. buildUniformLayout(): void;
  103132. /**
  103133. * Unbind the material.
  103134. */
  103135. unbind(): void;
  103136. /**
  103137. * Bind only the world matrix to the material.
  103138. * @param world The world matrix to bind.
  103139. */
  103140. bindOnlyWorldMatrix(world: Matrix): void;
  103141. /**
  103142. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  103143. * @param world The world matrix to bind.
  103144. * @param subMesh The submesh to bind for.
  103145. */
  103146. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103147. /**
  103148. * Dispose the material.
  103149. * @param forceDisposeEffect Force disposal of the associated effect.
  103150. * @param forceDisposeTextures Force disposal of the associated textures.
  103151. */
  103152. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103153. /**
  103154. * Clones the material.
  103155. * @param name The cloned name.
  103156. * @returns The cloned material.
  103157. */
  103158. clone(name: string): BackgroundMaterial;
  103159. /**
  103160. * Serializes the current material to its JSON representation.
  103161. * @returns The JSON representation.
  103162. */
  103163. serialize(): any;
  103164. /**
  103165. * Gets the class name of the material
  103166. * @returns "BackgroundMaterial"
  103167. */
  103168. getClassName(): string;
  103169. /**
  103170. * Parse a JSON input to create back a background material.
  103171. * @param source The JSON data to parse
  103172. * @param scene The scene to create the parsed material in
  103173. * @param rootUrl The root url of the assets the material depends upon
  103174. * @returns the instantiated BackgroundMaterial.
  103175. */
  103176. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  103177. }
  103178. }
  103179. declare module BABYLON {
  103180. /**
  103181. * Represents the different options available during the creation of
  103182. * a Environment helper.
  103183. *
  103184. * This can control the default ground, skybox and image processing setup of your scene.
  103185. */
  103186. export interface IEnvironmentHelperOptions {
  103187. /**
  103188. * Specifies wether or not to create a ground.
  103189. * True by default.
  103190. */
  103191. createGround: boolean;
  103192. /**
  103193. * Specifies the ground size.
  103194. * 15 by default.
  103195. */
  103196. groundSize: number;
  103197. /**
  103198. * The texture used on the ground for the main color.
  103199. * Comes from the BabylonJS CDN by default.
  103200. *
  103201. * Remarks: Can be either a texture or a url.
  103202. */
  103203. groundTexture: string | BaseTexture;
  103204. /**
  103205. * The color mixed in the ground texture by default.
  103206. * BabylonJS clearColor by default.
  103207. */
  103208. groundColor: Color3;
  103209. /**
  103210. * Specifies the ground opacity.
  103211. * 1 by default.
  103212. */
  103213. groundOpacity: number;
  103214. /**
  103215. * Enables the ground to receive shadows.
  103216. * True by default.
  103217. */
  103218. enableGroundShadow: boolean;
  103219. /**
  103220. * Helps preventing the shadow to be fully black on the ground.
  103221. * 0.5 by default.
  103222. */
  103223. groundShadowLevel: number;
  103224. /**
  103225. * Creates a mirror texture attach to the ground.
  103226. * false by default.
  103227. */
  103228. enableGroundMirror: boolean;
  103229. /**
  103230. * Specifies the ground mirror size ratio.
  103231. * 0.3 by default as the default kernel is 64.
  103232. */
  103233. groundMirrorSizeRatio: number;
  103234. /**
  103235. * Specifies the ground mirror blur kernel size.
  103236. * 64 by default.
  103237. */
  103238. groundMirrorBlurKernel: number;
  103239. /**
  103240. * Specifies the ground mirror visibility amount.
  103241. * 1 by default
  103242. */
  103243. groundMirrorAmount: number;
  103244. /**
  103245. * Specifies the ground mirror reflectance weight.
  103246. * This uses the standard weight of the background material to setup the fresnel effect
  103247. * of the mirror.
  103248. * 1 by default.
  103249. */
  103250. groundMirrorFresnelWeight: number;
  103251. /**
  103252. * Specifies the ground mirror Falloff distance.
  103253. * This can helps reducing the size of the reflection.
  103254. * 0 by Default.
  103255. */
  103256. groundMirrorFallOffDistance: number;
  103257. /**
  103258. * Specifies the ground mirror texture type.
  103259. * Unsigned Int by Default.
  103260. */
  103261. groundMirrorTextureType: number;
  103262. /**
  103263. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  103264. * the shown objects.
  103265. */
  103266. groundYBias: number;
  103267. /**
  103268. * Specifies wether or not to create a skybox.
  103269. * True by default.
  103270. */
  103271. createSkybox: boolean;
  103272. /**
  103273. * Specifies the skybox size.
  103274. * 20 by default.
  103275. */
  103276. skyboxSize: number;
  103277. /**
  103278. * The texture used on the skybox for the main color.
  103279. * Comes from the BabylonJS CDN by default.
  103280. *
  103281. * Remarks: Can be either a texture or a url.
  103282. */
  103283. skyboxTexture: string | BaseTexture;
  103284. /**
  103285. * The color mixed in the skybox texture by default.
  103286. * BabylonJS clearColor by default.
  103287. */
  103288. skyboxColor: Color3;
  103289. /**
  103290. * The background rotation around the Y axis of the scene.
  103291. * This helps aligning the key lights of your scene with the background.
  103292. * 0 by default.
  103293. */
  103294. backgroundYRotation: number;
  103295. /**
  103296. * Compute automatically the size of the elements to best fit with the scene.
  103297. */
  103298. sizeAuto: boolean;
  103299. /**
  103300. * Default position of the rootMesh if autoSize is not true.
  103301. */
  103302. rootPosition: Vector3;
  103303. /**
  103304. * Sets up the image processing in the scene.
  103305. * true by default.
  103306. */
  103307. setupImageProcessing: boolean;
  103308. /**
  103309. * The texture used as your environment texture in the scene.
  103310. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  103311. *
  103312. * Remarks: Can be either a texture or a url.
  103313. */
  103314. environmentTexture: string | BaseTexture;
  103315. /**
  103316. * The value of the exposure to apply to the scene.
  103317. * 0.6 by default if setupImageProcessing is true.
  103318. */
  103319. cameraExposure: number;
  103320. /**
  103321. * The value of the contrast to apply to the scene.
  103322. * 1.6 by default if setupImageProcessing is true.
  103323. */
  103324. cameraContrast: number;
  103325. /**
  103326. * Specifies wether or not tonemapping should be enabled in the scene.
  103327. * true by default if setupImageProcessing is true.
  103328. */
  103329. toneMappingEnabled: boolean;
  103330. }
  103331. /**
  103332. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  103333. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  103334. * It also helps with the default setup of your imageProcessing configuration.
  103335. */
  103336. export class EnvironmentHelper {
  103337. /**
  103338. * Default ground texture URL.
  103339. */
  103340. private static _groundTextureCDNUrl;
  103341. /**
  103342. * Default skybox texture URL.
  103343. */
  103344. private static _skyboxTextureCDNUrl;
  103345. /**
  103346. * Default environment texture URL.
  103347. */
  103348. private static _environmentTextureCDNUrl;
  103349. /**
  103350. * Creates the default options for the helper.
  103351. */
  103352. private static _getDefaultOptions;
  103353. private _rootMesh;
  103354. /**
  103355. * Gets the root mesh created by the helper.
  103356. */
  103357. readonly rootMesh: Mesh;
  103358. private _skybox;
  103359. /**
  103360. * Gets the skybox created by the helper.
  103361. */
  103362. readonly skybox: Nullable<Mesh>;
  103363. private _skyboxTexture;
  103364. /**
  103365. * Gets the skybox texture created by the helper.
  103366. */
  103367. readonly skyboxTexture: Nullable<BaseTexture>;
  103368. private _skyboxMaterial;
  103369. /**
  103370. * Gets the skybox material created by the helper.
  103371. */
  103372. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  103373. private _ground;
  103374. /**
  103375. * Gets the ground mesh created by the helper.
  103376. */
  103377. readonly ground: Nullable<Mesh>;
  103378. private _groundTexture;
  103379. /**
  103380. * Gets the ground texture created by the helper.
  103381. */
  103382. readonly groundTexture: Nullable<BaseTexture>;
  103383. private _groundMirror;
  103384. /**
  103385. * Gets the ground mirror created by the helper.
  103386. */
  103387. readonly groundMirror: Nullable<MirrorTexture>;
  103388. /**
  103389. * Gets the ground mirror render list to helps pushing the meshes
  103390. * you wish in the ground reflection.
  103391. */
  103392. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  103393. private _groundMaterial;
  103394. /**
  103395. * Gets the ground material created by the helper.
  103396. */
  103397. readonly groundMaterial: Nullable<BackgroundMaterial>;
  103398. /**
  103399. * Stores the creation options.
  103400. */
  103401. private readonly _scene;
  103402. private _options;
  103403. /**
  103404. * This observable will be notified with any error during the creation of the environment,
  103405. * mainly texture creation errors.
  103406. */
  103407. onErrorObservable: Observable<{
  103408. message?: string;
  103409. exception?: any;
  103410. }>;
  103411. /**
  103412. * constructor
  103413. * @param options Defines the options we want to customize the helper
  103414. * @param scene The scene to add the material to
  103415. */
  103416. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  103417. /**
  103418. * Updates the background according to the new options
  103419. * @param options
  103420. */
  103421. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  103422. /**
  103423. * Sets the primary color of all the available elements.
  103424. * @param color the main color to affect to the ground and the background
  103425. */
  103426. setMainColor(color: Color3): void;
  103427. /**
  103428. * Setup the image processing according to the specified options.
  103429. */
  103430. private _setupImageProcessing;
  103431. /**
  103432. * Setup the environment texture according to the specified options.
  103433. */
  103434. private _setupEnvironmentTexture;
  103435. /**
  103436. * Setup the background according to the specified options.
  103437. */
  103438. private _setupBackground;
  103439. /**
  103440. * Get the scene sizes according to the setup.
  103441. */
  103442. private _getSceneSize;
  103443. /**
  103444. * Setup the ground according to the specified options.
  103445. */
  103446. private _setupGround;
  103447. /**
  103448. * Setup the ground material according to the specified options.
  103449. */
  103450. private _setupGroundMaterial;
  103451. /**
  103452. * Setup the ground diffuse texture according to the specified options.
  103453. */
  103454. private _setupGroundDiffuseTexture;
  103455. /**
  103456. * Setup the ground mirror texture according to the specified options.
  103457. */
  103458. private _setupGroundMirrorTexture;
  103459. /**
  103460. * Setup the ground to receive the mirror texture.
  103461. */
  103462. private _setupMirrorInGroundMaterial;
  103463. /**
  103464. * Setup the skybox according to the specified options.
  103465. */
  103466. private _setupSkybox;
  103467. /**
  103468. * Setup the skybox material according to the specified options.
  103469. */
  103470. private _setupSkyboxMaterial;
  103471. /**
  103472. * Setup the skybox reflection texture according to the specified options.
  103473. */
  103474. private _setupSkyboxReflectionTexture;
  103475. private _errorHandler;
  103476. /**
  103477. * Dispose all the elements created by the Helper.
  103478. */
  103479. dispose(): void;
  103480. }
  103481. }
  103482. declare module BABYLON {
  103483. /**
  103484. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  103485. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  103486. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  103487. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  103488. */
  103489. export class PhotoDome extends TransformNode {
  103490. private _useDirectMapping;
  103491. /**
  103492. * The texture being displayed on the sphere
  103493. */
  103494. protected _photoTexture: Texture;
  103495. /**
  103496. * Gets or sets the texture being displayed on the sphere
  103497. */
  103498. photoTexture: Texture;
  103499. /**
  103500. * Observable raised when an error occured while loading the 360 image
  103501. */
  103502. onLoadErrorObservable: Observable<string>;
  103503. /**
  103504. * The skybox material
  103505. */
  103506. protected _material: BackgroundMaterial;
  103507. /**
  103508. * The surface used for the skybox
  103509. */
  103510. protected _mesh: Mesh;
  103511. /**
  103512. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103513. * Also see the options.resolution property.
  103514. */
  103515. fovMultiplier: number;
  103516. /**
  103517. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  103518. * @param name Element's name, child elements will append suffixes for their own names.
  103519. * @param urlsOfPhoto defines the url of the photo to display
  103520. * @param options defines an object containing optional or exposed sub element properties
  103521. * @param onError defines a callback called when an error occured while loading the texture
  103522. */
  103523. constructor(name: string, urlOfPhoto: string, options: {
  103524. resolution?: number;
  103525. size?: number;
  103526. useDirectMapping?: boolean;
  103527. faceForward?: boolean;
  103528. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  103529. /**
  103530. * Releases resources associated with this node.
  103531. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103532. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103533. */
  103534. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103535. }
  103536. }
  103537. declare module BABYLON {
  103538. /** @hidden */
  103539. export var rgbdDecodePixelShader: {
  103540. name: string;
  103541. shader: string;
  103542. };
  103543. }
  103544. declare module BABYLON {
  103545. /**
  103546. * Class used to host texture specific utilities
  103547. */
  103548. export class BRDFTextureTools {
  103549. /**
  103550. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  103551. * @param texture the texture to expand.
  103552. */
  103553. private static _ExpandDefaultBRDFTexture;
  103554. /**
  103555. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  103556. * @param scene defines the hosting scene
  103557. * @returns the environment BRDF texture
  103558. */
  103559. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  103560. private static _environmentBRDFBase64Texture;
  103561. }
  103562. }
  103563. declare module BABYLON {
  103564. /**
  103565. * @hidden
  103566. */
  103567. export interface IMaterialClearCoatDefines {
  103568. CLEARCOAT: boolean;
  103569. CLEARCOAT_DEFAULTIOR: boolean;
  103570. CLEARCOAT_TEXTURE: boolean;
  103571. CLEARCOAT_TEXTUREDIRECTUV: number;
  103572. CLEARCOAT_BUMP: boolean;
  103573. CLEARCOAT_BUMPDIRECTUV: number;
  103574. CLEARCOAT_TINT: boolean;
  103575. CLEARCOAT_TINT_TEXTURE: boolean;
  103576. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  103577. /** @hidden */
  103578. _areTexturesDirty: boolean;
  103579. }
  103580. /**
  103581. * Define the code related to the clear coat parameters of the pbr material.
  103582. */
  103583. export class PBRClearCoatConfiguration {
  103584. /**
  103585. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103586. * The default fits with a polyurethane material.
  103587. */
  103588. private static readonly _DefaultIndiceOfRefraction;
  103589. private _isEnabled;
  103590. /**
  103591. * Defines if the clear coat is enabled in the material.
  103592. */
  103593. isEnabled: boolean;
  103594. /**
  103595. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  103596. */
  103597. intensity: number;
  103598. /**
  103599. * Defines the clear coat layer roughness.
  103600. */
  103601. roughness: number;
  103602. private _indiceOfRefraction;
  103603. /**
  103604. * Defines the indice of refraction of the clear coat.
  103605. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103606. * The default fits with a polyurethane material.
  103607. * Changing the default value is more performance intensive.
  103608. */
  103609. indiceOfRefraction: number;
  103610. private _texture;
  103611. /**
  103612. * Stores the clear coat values in a texture.
  103613. */
  103614. texture: Nullable<BaseTexture>;
  103615. private _bumpTexture;
  103616. /**
  103617. * Define the clear coat specific bump texture.
  103618. */
  103619. bumpTexture: Nullable<BaseTexture>;
  103620. private _isTintEnabled;
  103621. /**
  103622. * Defines if the clear coat tint is enabled in the material.
  103623. */
  103624. isTintEnabled: boolean;
  103625. /**
  103626. * Defines the clear coat tint of the material.
  103627. * This is only use if tint is enabled
  103628. */
  103629. tintColor: Color3;
  103630. /**
  103631. * Defines the distance at which the tint color should be found in the
  103632. * clear coat media.
  103633. * This is only use if tint is enabled
  103634. */
  103635. tintColorAtDistance: number;
  103636. /**
  103637. * Defines the clear coat layer thickness.
  103638. * This is only use if tint is enabled
  103639. */
  103640. tintThickness: number;
  103641. private _tintTexture;
  103642. /**
  103643. * Stores the clear tint values in a texture.
  103644. * rgb is tint
  103645. * a is a thickness factor
  103646. */
  103647. tintTexture: Nullable<BaseTexture>;
  103648. /** @hidden */
  103649. private _internalMarkAllSubMeshesAsTexturesDirty;
  103650. /** @hidden */
  103651. _markAllSubMeshesAsTexturesDirty(): void;
  103652. /**
  103653. * Instantiate a new istance of clear coat configuration.
  103654. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103655. */
  103656. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103657. /**
  103658. * Gets wehter the submesh is ready to be used or not.
  103659. * @param defines the list of "defines" to update.
  103660. * @param scene defines the scene the material belongs to.
  103661. * @param engine defines the engine the material belongs to.
  103662. * @param disableBumpMap defines wether the material disables bump or not.
  103663. * @returns - boolean indicating that the submesh is ready or not.
  103664. */
  103665. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  103666. /**
  103667. * Checks to see if a texture is used in the material.
  103668. * @param defines the list of "defines" to update.
  103669. * @param scene defines the scene to the material belongs to.
  103670. */
  103671. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  103672. /**
  103673. * Binds the material data.
  103674. * @param uniformBuffer defines the Uniform buffer to fill in.
  103675. * @param scene defines the scene the material belongs to.
  103676. * @param engine defines the engine the material belongs to.
  103677. * @param disableBumpMap defines wether the material disables bump or not.
  103678. * @param isFrozen defines wether the material is frozen or not.
  103679. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  103680. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  103681. */
  103682. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  103683. /**
  103684. * Checks to see if a texture is used in the material.
  103685. * @param texture - Base texture to use.
  103686. * @returns - Boolean specifying if a texture is used in the material.
  103687. */
  103688. hasTexture(texture: BaseTexture): boolean;
  103689. /**
  103690. * Returns an array of the actively used textures.
  103691. * @param activeTextures Array of BaseTextures
  103692. */
  103693. getActiveTextures(activeTextures: BaseTexture[]): void;
  103694. /**
  103695. * Returns the animatable textures.
  103696. * @param animatables Array of animatable textures.
  103697. */
  103698. getAnimatables(animatables: IAnimatable[]): void;
  103699. /**
  103700. * Disposes the resources of the material.
  103701. * @param forceDisposeTextures - Forces the disposal of all textures.
  103702. */
  103703. dispose(forceDisposeTextures?: boolean): void;
  103704. /**
  103705. * Get the current class name of the texture useful for serialization or dynamic coding.
  103706. * @returns "PBRClearCoatConfiguration"
  103707. */
  103708. getClassName(): string;
  103709. /**
  103710. * Add fallbacks to the effect fallbacks list.
  103711. * @param defines defines the Base texture to use.
  103712. * @param fallbacks defines the current fallback list.
  103713. * @param currentRank defines the current fallback rank.
  103714. * @returns the new fallback rank.
  103715. */
  103716. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103717. /**
  103718. * Add the required uniforms to the current list.
  103719. * @param uniforms defines the current uniform list.
  103720. */
  103721. static AddUniforms(uniforms: string[]): void;
  103722. /**
  103723. * Add the required samplers to the current list.
  103724. * @param samplers defines the current sampler list.
  103725. */
  103726. static AddSamplers(samplers: string[]): void;
  103727. /**
  103728. * Add the required uniforms to the current buffer.
  103729. * @param uniformBuffer defines the current uniform buffer.
  103730. */
  103731. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103732. /**
  103733. * Makes a duplicate of the current configuration into another one.
  103734. * @param clearCoatConfiguration define the config where to copy the info
  103735. */
  103736. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  103737. /**
  103738. * Serializes this clear coat configuration.
  103739. * @returns - An object with the serialized config.
  103740. */
  103741. serialize(): any;
  103742. /**
  103743. * Parses a Clear Coat Configuration from a serialized object.
  103744. * @param source - Serialized object.
  103745. */
  103746. parse(source: any): void;
  103747. }
  103748. }
  103749. declare module BABYLON {
  103750. /**
  103751. * @hidden
  103752. */
  103753. export interface IMaterialAnisotropicDefines {
  103754. ANISOTROPIC: boolean;
  103755. ANISOTROPIC_TEXTURE: boolean;
  103756. ANISOTROPIC_TEXTUREDIRECTUV: number;
  103757. MAINUV1: boolean;
  103758. _areTexturesDirty: boolean;
  103759. _needUVs: boolean;
  103760. }
  103761. /**
  103762. * Define the code related to the anisotropic parameters of the pbr material.
  103763. */
  103764. export class PBRAnisotropicConfiguration {
  103765. private _isEnabled;
  103766. /**
  103767. * Defines if the anisotropy is enabled in the material.
  103768. */
  103769. isEnabled: boolean;
  103770. /**
  103771. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  103772. */
  103773. intensity: number;
  103774. /**
  103775. * Defines if the effect is along the tangents, bitangents or in between.
  103776. * By default, the effect is "strectching" the highlights along the tangents.
  103777. */
  103778. direction: Vector2;
  103779. private _texture;
  103780. /**
  103781. * Stores the anisotropy values in a texture.
  103782. * rg is direction (like normal from -1 to 1)
  103783. * b is a intensity
  103784. */
  103785. texture: Nullable<BaseTexture>;
  103786. /** @hidden */
  103787. private _internalMarkAllSubMeshesAsTexturesDirty;
  103788. /** @hidden */
  103789. _markAllSubMeshesAsTexturesDirty(): void;
  103790. /**
  103791. * Instantiate a new istance of anisotropy configuration.
  103792. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103793. */
  103794. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103795. /**
  103796. * Specifies that the submesh is ready to be used.
  103797. * @param defines the list of "defines" to update.
  103798. * @param scene defines the scene the material belongs to.
  103799. * @returns - boolean indicating that the submesh is ready or not.
  103800. */
  103801. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  103802. /**
  103803. * Checks to see if a texture is used in the material.
  103804. * @param defines the list of "defines" to update.
  103805. * @param mesh the mesh we are preparing the defines for.
  103806. * @param scene defines the scene the material belongs to.
  103807. */
  103808. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  103809. /**
  103810. * Binds the material data.
  103811. * @param uniformBuffer defines the Uniform buffer to fill in.
  103812. * @param scene defines the scene the material belongs to.
  103813. * @param isFrozen defines wether the material is frozen or not.
  103814. */
  103815. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  103816. /**
  103817. * Checks to see if a texture is used in the material.
  103818. * @param texture - Base texture to use.
  103819. * @returns - Boolean specifying if a texture is used in the material.
  103820. */
  103821. hasTexture(texture: BaseTexture): boolean;
  103822. /**
  103823. * Returns an array of the actively used textures.
  103824. * @param activeTextures Array of BaseTextures
  103825. */
  103826. getActiveTextures(activeTextures: BaseTexture[]): void;
  103827. /**
  103828. * Returns the animatable textures.
  103829. * @param animatables Array of animatable textures.
  103830. */
  103831. getAnimatables(animatables: IAnimatable[]): void;
  103832. /**
  103833. * Disposes the resources of the material.
  103834. * @param forceDisposeTextures - Forces the disposal of all textures.
  103835. */
  103836. dispose(forceDisposeTextures?: boolean): void;
  103837. /**
  103838. * Get the current class name of the texture useful for serialization or dynamic coding.
  103839. * @returns "PBRAnisotropicConfiguration"
  103840. */
  103841. getClassName(): string;
  103842. /**
  103843. * Add fallbacks to the effect fallbacks list.
  103844. * @param defines defines the Base texture to use.
  103845. * @param fallbacks defines the current fallback list.
  103846. * @param currentRank defines the current fallback rank.
  103847. * @returns the new fallback rank.
  103848. */
  103849. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103850. /**
  103851. * Add the required uniforms to the current list.
  103852. * @param uniforms defines the current uniform list.
  103853. */
  103854. static AddUniforms(uniforms: string[]): void;
  103855. /**
  103856. * Add the required uniforms to the current buffer.
  103857. * @param uniformBuffer defines the current uniform buffer.
  103858. */
  103859. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103860. /**
  103861. * Add the required samplers to the current list.
  103862. * @param samplers defines the current sampler list.
  103863. */
  103864. static AddSamplers(samplers: string[]): void;
  103865. /**
  103866. * Makes a duplicate of the current configuration into another one.
  103867. * @param anisotropicConfiguration define the config where to copy the info
  103868. */
  103869. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  103870. /**
  103871. * Serializes this anisotropy configuration.
  103872. * @returns - An object with the serialized config.
  103873. */
  103874. serialize(): any;
  103875. /**
  103876. * Parses a anisotropy Configuration from a serialized object.
  103877. * @param source - Serialized object.
  103878. */
  103879. parse(source: any): void;
  103880. }
  103881. }
  103882. declare module BABYLON {
  103883. /**
  103884. * @hidden
  103885. */
  103886. export interface IMaterialBRDFDefines {
  103887. BRDF_V_HEIGHT_CORRELATED: boolean;
  103888. MS_BRDF_ENERGY_CONSERVATION: boolean;
  103889. /** @hidden */
  103890. _areMiscDirty: boolean;
  103891. }
  103892. /**
  103893. * Define the code related to the BRDF parameters of the pbr material.
  103894. */
  103895. export class PBRBRDFConfiguration {
  103896. /**
  103897. * Default value used for the energy conservation.
  103898. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  103899. */
  103900. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  103901. /**
  103902. * Default value used for the Smith Visibility Height Correlated mode.
  103903. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  103904. */
  103905. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  103906. private _useEnergyConservation;
  103907. /**
  103908. * Defines if the material uses energy conservation.
  103909. */
  103910. useEnergyConservation: boolean;
  103911. private _useSmithVisibilityHeightCorrelated;
  103912. /**
  103913. * LEGACY Mode set to false
  103914. * Defines if the material uses height smith correlated visibility term.
  103915. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  103916. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  103917. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  103918. * Not relying on height correlated will also disable energy conservation.
  103919. */
  103920. useSmithVisibilityHeightCorrelated: boolean;
  103921. /** @hidden */
  103922. private _internalMarkAllSubMeshesAsMiscDirty;
  103923. /** @hidden */
  103924. _markAllSubMeshesAsMiscDirty(): void;
  103925. /**
  103926. * Instantiate a new istance of clear coat configuration.
  103927. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  103928. */
  103929. constructor(markAllSubMeshesAsMiscDirty: () => void);
  103930. /**
  103931. * Checks to see if a texture is used in the material.
  103932. * @param defines the list of "defines" to update.
  103933. */
  103934. prepareDefines(defines: IMaterialBRDFDefines): void;
  103935. /**
  103936. * Get the current class name of the texture useful for serialization or dynamic coding.
  103937. * @returns "PBRClearCoatConfiguration"
  103938. */
  103939. getClassName(): string;
  103940. /**
  103941. * Makes a duplicate of the current configuration into another one.
  103942. * @param brdfConfiguration define the config where to copy the info
  103943. */
  103944. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  103945. /**
  103946. * Serializes this BRDF configuration.
  103947. * @returns - An object with the serialized config.
  103948. */
  103949. serialize(): any;
  103950. /**
  103951. * Parses a BRDF Configuration from a serialized object.
  103952. * @param source - Serialized object.
  103953. */
  103954. parse(source: any): void;
  103955. }
  103956. }
  103957. declare module BABYLON {
  103958. /**
  103959. * @hidden
  103960. */
  103961. export interface IMaterialSheenDefines {
  103962. SHEEN: boolean;
  103963. SHEEN_TEXTURE: boolean;
  103964. SHEEN_TEXTUREDIRECTUV: number;
  103965. SHEEN_LINKWITHALBEDO: boolean;
  103966. /** @hidden */
  103967. _areTexturesDirty: boolean;
  103968. }
  103969. /**
  103970. * Define the code related to the Sheen parameters of the pbr material.
  103971. */
  103972. export class PBRSheenConfiguration {
  103973. private _isEnabled;
  103974. /**
  103975. * Defines if the material uses sheen.
  103976. */
  103977. isEnabled: boolean;
  103978. private _linkSheenWithAlbedo;
  103979. /**
  103980. * Defines if the sheen is linked to the sheen color.
  103981. */
  103982. linkSheenWithAlbedo: boolean;
  103983. /**
  103984. * Defines the sheen intensity.
  103985. */
  103986. intensity: number;
  103987. /**
  103988. * Defines the sheen color.
  103989. */
  103990. color: Color3;
  103991. private _texture;
  103992. /**
  103993. * Stores the sheen tint values in a texture.
  103994. * rgb is tint
  103995. * a is a intensity
  103996. */
  103997. texture: Nullable<BaseTexture>;
  103998. /** @hidden */
  103999. private _internalMarkAllSubMeshesAsTexturesDirty;
  104000. /** @hidden */
  104001. _markAllSubMeshesAsTexturesDirty(): void;
  104002. /**
  104003. * Instantiate a new istance of clear coat configuration.
  104004. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104005. */
  104006. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104007. /**
  104008. * Specifies that the submesh is ready to be used.
  104009. * @param defines the list of "defines" to update.
  104010. * @param scene defines the scene the material belongs to.
  104011. * @returns - boolean indicating that the submesh is ready or not.
  104012. */
  104013. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  104014. /**
  104015. * Checks to see if a texture is used in the material.
  104016. * @param defines the list of "defines" to update.
  104017. * @param scene defines the scene the material belongs to.
  104018. */
  104019. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  104020. /**
  104021. * Binds the material data.
  104022. * @param uniformBuffer defines the Uniform buffer to fill in.
  104023. * @param scene defines the scene the material belongs to.
  104024. * @param isFrozen defines wether the material is frozen or not.
  104025. */
  104026. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104027. /**
  104028. * Checks to see if a texture is used in the material.
  104029. * @param texture - Base texture to use.
  104030. * @returns - Boolean specifying if a texture is used in the material.
  104031. */
  104032. hasTexture(texture: BaseTexture): boolean;
  104033. /**
  104034. * Returns an array of the actively used textures.
  104035. * @param activeTextures Array of BaseTextures
  104036. */
  104037. getActiveTextures(activeTextures: BaseTexture[]): void;
  104038. /**
  104039. * Returns the animatable textures.
  104040. * @param animatables Array of animatable textures.
  104041. */
  104042. getAnimatables(animatables: IAnimatable[]): void;
  104043. /**
  104044. * Disposes the resources of the material.
  104045. * @param forceDisposeTextures - Forces the disposal of all textures.
  104046. */
  104047. dispose(forceDisposeTextures?: boolean): void;
  104048. /**
  104049. * Get the current class name of the texture useful for serialization or dynamic coding.
  104050. * @returns "PBRSheenConfiguration"
  104051. */
  104052. getClassName(): string;
  104053. /**
  104054. * Add fallbacks to the effect fallbacks list.
  104055. * @param defines defines the Base texture to use.
  104056. * @param fallbacks defines the current fallback list.
  104057. * @param currentRank defines the current fallback rank.
  104058. * @returns the new fallback rank.
  104059. */
  104060. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104061. /**
  104062. * Add the required uniforms to the current list.
  104063. * @param uniforms defines the current uniform list.
  104064. */
  104065. static AddUniforms(uniforms: string[]): void;
  104066. /**
  104067. * Add the required uniforms to the current buffer.
  104068. * @param uniformBuffer defines the current uniform buffer.
  104069. */
  104070. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104071. /**
  104072. * Add the required samplers to the current list.
  104073. * @param samplers defines the current sampler list.
  104074. */
  104075. static AddSamplers(samplers: string[]): void;
  104076. /**
  104077. * Makes a duplicate of the current configuration into another one.
  104078. * @param sheenConfiguration define the config where to copy the info
  104079. */
  104080. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  104081. /**
  104082. * Serializes this BRDF configuration.
  104083. * @returns - An object with the serialized config.
  104084. */
  104085. serialize(): any;
  104086. /**
  104087. * Parses a Sheen Configuration from a serialized object.
  104088. * @param source - Serialized object.
  104089. */
  104090. parse(source: any): void;
  104091. }
  104092. }
  104093. declare module BABYLON {
  104094. /**
  104095. * @hidden
  104096. */
  104097. export interface IMaterialSubSurfaceDefines {
  104098. SUBSURFACE: boolean;
  104099. SS_REFRACTION: boolean;
  104100. SS_TRANSLUCENCY: boolean;
  104101. SS_SCATERRING: boolean;
  104102. SS_THICKNESSANDMASK_TEXTURE: boolean;
  104103. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104104. SS_REFRACTIONMAP_3D: boolean;
  104105. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104106. SS_LODINREFRACTIONALPHA: boolean;
  104107. SS_GAMMAREFRACTION: boolean;
  104108. SS_RGBDREFRACTION: boolean;
  104109. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104110. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104111. /** @hidden */
  104112. _areTexturesDirty: boolean;
  104113. }
  104114. /**
  104115. * Define the code related to the sub surface parameters of the pbr material.
  104116. */
  104117. export class PBRSubSurfaceConfiguration {
  104118. private _isRefractionEnabled;
  104119. /**
  104120. * Defines if the refraction is enabled in the material.
  104121. */
  104122. isRefractionEnabled: boolean;
  104123. private _isTranslucencyEnabled;
  104124. /**
  104125. * Defines if the translucency is enabled in the material.
  104126. */
  104127. isTranslucencyEnabled: boolean;
  104128. private _isScatteringEnabled;
  104129. /**
  104130. * Defines the refraction intensity of the material.
  104131. * The refraction when enabled replaces the Diffuse part of the material.
  104132. * The intensity helps transitionning between diffuse and refraction.
  104133. */
  104134. refractionIntensity: number;
  104135. /**
  104136. * Defines the translucency intensity of the material.
  104137. * When translucency has been enabled, this defines how much of the "translucency"
  104138. * is addded to the diffuse part of the material.
  104139. */
  104140. translucencyIntensity: number;
  104141. /**
  104142. * Defines the scattering intensity of the material.
  104143. * When scattering has been enabled, this defines how much of the "scattered light"
  104144. * is addded to the diffuse part of the material.
  104145. */
  104146. scatteringIntensity: number;
  104147. private _thicknessTexture;
  104148. /**
  104149. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  104150. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  104151. * 0 would mean minimumThickness
  104152. * 1 would mean maximumThickness
  104153. * The other channels might be use as a mask to vary the different effects intensity.
  104154. */
  104155. thicknessTexture: Nullable<BaseTexture>;
  104156. private _refractionTexture;
  104157. /**
  104158. * Defines the texture to use for refraction.
  104159. */
  104160. refractionTexture: Nullable<BaseTexture>;
  104161. private _indexOfRefraction;
  104162. /**
  104163. * Defines the indice of refraction used in the material.
  104164. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  104165. */
  104166. indexOfRefraction: number;
  104167. private _invertRefractionY;
  104168. /**
  104169. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  104170. */
  104171. invertRefractionY: boolean;
  104172. private _linkRefractionWithTransparency;
  104173. /**
  104174. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  104175. * Materials half opaque for instance using refraction could benefit from this control.
  104176. */
  104177. linkRefractionWithTransparency: boolean;
  104178. /**
  104179. * Defines the minimum thickness stored in the thickness map.
  104180. * If no thickness map is defined, this value will be used to simulate thickness.
  104181. */
  104182. minimumThickness: number;
  104183. /**
  104184. * Defines the maximum thickness stored in the thickness map.
  104185. */
  104186. maximumThickness: number;
  104187. /**
  104188. * Defines the volume tint of the material.
  104189. * This is used for both translucency and scattering.
  104190. */
  104191. tintColor: Color3;
  104192. /**
  104193. * Defines the distance at which the tint color should be found in the media.
  104194. * This is used for refraction only.
  104195. */
  104196. tintColorAtDistance: number;
  104197. /**
  104198. * Defines how far each channel transmit through the media.
  104199. * It is defined as a color to simplify it selection.
  104200. */
  104201. diffusionDistance: Color3;
  104202. private _useMaskFromThicknessTexture;
  104203. /**
  104204. * Stores the intensity of the different subsurface effects in the thickness texture.
  104205. * * the green channel is the translucency intensity.
  104206. * * the blue channel is the scattering intensity.
  104207. * * the alpha channel is the refraction intensity.
  104208. */
  104209. useMaskFromThicknessTexture: boolean;
  104210. /** @hidden */
  104211. private _internalMarkAllSubMeshesAsTexturesDirty;
  104212. /** @hidden */
  104213. _markAllSubMeshesAsTexturesDirty(): void;
  104214. /**
  104215. * Instantiate a new istance of sub surface configuration.
  104216. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104217. */
  104218. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104219. /**
  104220. * Gets wehter the submesh is ready to be used or not.
  104221. * @param defines the list of "defines" to update.
  104222. * @param scene defines the scene the material belongs to.
  104223. * @returns - boolean indicating that the submesh is ready or not.
  104224. */
  104225. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  104226. /**
  104227. * Checks to see if a texture is used in the material.
  104228. * @param defines the list of "defines" to update.
  104229. * @param scene defines the scene to the material belongs to.
  104230. */
  104231. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  104232. /**
  104233. * Binds the material data.
  104234. * @param uniformBuffer defines the Uniform buffer to fill in.
  104235. * @param scene defines the scene the material belongs to.
  104236. * @param engine defines the engine the material belongs to.
  104237. * @param isFrozen defines wether the material is frozen or not.
  104238. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  104239. */
  104240. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  104241. /**
  104242. * Unbinds the material from the mesh.
  104243. * @param activeEffect defines the effect that should be unbound from.
  104244. * @returns true if unbound, otherwise false
  104245. */
  104246. unbind(activeEffect: Effect): boolean;
  104247. /**
  104248. * Returns the texture used for refraction or null if none is used.
  104249. * @param scene defines the scene the material belongs to.
  104250. * @returns - Refraction texture if present. If no refraction texture and refraction
  104251. * is linked with transparency, returns environment texture. Otherwise, returns null.
  104252. */
  104253. private _getRefractionTexture;
  104254. /**
  104255. * Returns true if alpha blending should be disabled.
  104256. */
  104257. readonly disableAlphaBlending: boolean;
  104258. /**
  104259. * Fills the list of render target textures.
  104260. * @param renderTargets the list of render targets to update
  104261. */
  104262. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  104263. /**
  104264. * Checks to see if a texture is used in the material.
  104265. * @param texture - Base texture to use.
  104266. * @returns - Boolean specifying if a texture is used in the material.
  104267. */
  104268. hasTexture(texture: BaseTexture): boolean;
  104269. /**
  104270. * Gets a boolean indicating that current material needs to register RTT
  104271. * @returns true if this uses a render target otherwise false.
  104272. */
  104273. hasRenderTargetTextures(): boolean;
  104274. /**
  104275. * Returns an array of the actively used textures.
  104276. * @param activeTextures Array of BaseTextures
  104277. */
  104278. getActiveTextures(activeTextures: BaseTexture[]): void;
  104279. /**
  104280. * Returns the animatable textures.
  104281. * @param animatables Array of animatable textures.
  104282. */
  104283. getAnimatables(animatables: IAnimatable[]): void;
  104284. /**
  104285. * Disposes the resources of the material.
  104286. * @param forceDisposeTextures - Forces the disposal of all textures.
  104287. */
  104288. dispose(forceDisposeTextures?: boolean): void;
  104289. /**
  104290. * Get the current class name of the texture useful for serialization or dynamic coding.
  104291. * @returns "PBRSubSurfaceConfiguration"
  104292. */
  104293. getClassName(): string;
  104294. /**
  104295. * Add fallbacks to the effect fallbacks list.
  104296. * @param defines defines the Base texture to use.
  104297. * @param fallbacks defines the current fallback list.
  104298. * @param currentRank defines the current fallback rank.
  104299. * @returns the new fallback rank.
  104300. */
  104301. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104302. /**
  104303. * Add the required uniforms to the current list.
  104304. * @param uniforms defines the current uniform list.
  104305. */
  104306. static AddUniforms(uniforms: string[]): void;
  104307. /**
  104308. * Add the required samplers to the current list.
  104309. * @param samplers defines the current sampler list.
  104310. */
  104311. static AddSamplers(samplers: string[]): void;
  104312. /**
  104313. * Add the required uniforms to the current buffer.
  104314. * @param uniformBuffer defines the current uniform buffer.
  104315. */
  104316. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104317. /**
  104318. * Makes a duplicate of the current configuration into another one.
  104319. * @param configuration define the config where to copy the info
  104320. */
  104321. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  104322. /**
  104323. * Serializes this Sub Surface configuration.
  104324. * @returns - An object with the serialized config.
  104325. */
  104326. serialize(): any;
  104327. /**
  104328. * Parses a Sub Surface Configuration from a serialized object.
  104329. * @param source - Serialized object.
  104330. */
  104331. parse(source: any): void;
  104332. }
  104333. }
  104334. declare module BABYLON {
  104335. /** @hidden */
  104336. export var pbrFragmentDeclaration: {
  104337. name: string;
  104338. shader: string;
  104339. };
  104340. }
  104341. declare module BABYLON {
  104342. /** @hidden */
  104343. export var pbrUboDeclaration: {
  104344. name: string;
  104345. shader: string;
  104346. };
  104347. }
  104348. declare module BABYLON {
  104349. /** @hidden */
  104350. export var pbrFragmentExtraDeclaration: {
  104351. name: string;
  104352. shader: string;
  104353. };
  104354. }
  104355. declare module BABYLON {
  104356. /** @hidden */
  104357. export var pbrFragmentSamplersDeclaration: {
  104358. name: string;
  104359. shader: string;
  104360. };
  104361. }
  104362. declare module BABYLON {
  104363. /** @hidden */
  104364. export var pbrHelperFunctions: {
  104365. name: string;
  104366. shader: string;
  104367. };
  104368. }
  104369. declare module BABYLON {
  104370. /** @hidden */
  104371. export var harmonicsFunctions: {
  104372. name: string;
  104373. shader: string;
  104374. };
  104375. }
  104376. declare module BABYLON {
  104377. /** @hidden */
  104378. export var pbrDirectLightingSetupFunctions: {
  104379. name: string;
  104380. shader: string;
  104381. };
  104382. }
  104383. declare module BABYLON {
  104384. /** @hidden */
  104385. export var pbrDirectLightingFalloffFunctions: {
  104386. name: string;
  104387. shader: string;
  104388. };
  104389. }
  104390. declare module BABYLON {
  104391. /** @hidden */
  104392. export var pbrBRDFFunctions: {
  104393. name: string;
  104394. shader: string;
  104395. };
  104396. }
  104397. declare module BABYLON {
  104398. /** @hidden */
  104399. export var pbrDirectLightingFunctions: {
  104400. name: string;
  104401. shader: string;
  104402. };
  104403. }
  104404. declare module BABYLON {
  104405. /** @hidden */
  104406. export var pbrIBLFunctions: {
  104407. name: string;
  104408. shader: string;
  104409. };
  104410. }
  104411. declare module BABYLON {
  104412. /** @hidden */
  104413. export var pbrDebug: {
  104414. name: string;
  104415. shader: string;
  104416. };
  104417. }
  104418. declare module BABYLON {
  104419. /** @hidden */
  104420. export var pbrPixelShader: {
  104421. name: string;
  104422. shader: string;
  104423. };
  104424. }
  104425. declare module BABYLON {
  104426. /** @hidden */
  104427. export var pbrVertexDeclaration: {
  104428. name: string;
  104429. shader: string;
  104430. };
  104431. }
  104432. declare module BABYLON {
  104433. /** @hidden */
  104434. export var pbrVertexShader: {
  104435. name: string;
  104436. shader: string;
  104437. };
  104438. }
  104439. declare module BABYLON {
  104440. /**
  104441. * Manages the defines for the PBR Material.
  104442. * @hidden
  104443. */
  104444. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  104445. PBR: boolean;
  104446. MAINUV1: boolean;
  104447. MAINUV2: boolean;
  104448. UV1: boolean;
  104449. UV2: boolean;
  104450. ALBEDO: boolean;
  104451. ALBEDODIRECTUV: number;
  104452. VERTEXCOLOR: boolean;
  104453. AMBIENT: boolean;
  104454. AMBIENTDIRECTUV: number;
  104455. AMBIENTINGRAYSCALE: boolean;
  104456. OPACITY: boolean;
  104457. VERTEXALPHA: boolean;
  104458. OPACITYDIRECTUV: number;
  104459. OPACITYRGB: boolean;
  104460. ALPHATEST: boolean;
  104461. DEPTHPREPASS: boolean;
  104462. ALPHABLEND: boolean;
  104463. ALPHAFROMALBEDO: boolean;
  104464. ALPHATESTVALUE: string;
  104465. SPECULAROVERALPHA: boolean;
  104466. RADIANCEOVERALPHA: boolean;
  104467. ALPHAFRESNEL: boolean;
  104468. LINEARALPHAFRESNEL: boolean;
  104469. PREMULTIPLYALPHA: boolean;
  104470. EMISSIVE: boolean;
  104471. EMISSIVEDIRECTUV: number;
  104472. REFLECTIVITY: boolean;
  104473. REFLECTIVITYDIRECTUV: number;
  104474. SPECULARTERM: boolean;
  104475. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  104476. MICROSURFACEAUTOMATIC: boolean;
  104477. LODBASEDMICROSFURACE: boolean;
  104478. MICROSURFACEMAP: boolean;
  104479. MICROSURFACEMAPDIRECTUV: number;
  104480. METALLICWORKFLOW: boolean;
  104481. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  104482. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  104483. METALLNESSSTOREINMETALMAPBLUE: boolean;
  104484. AOSTOREINMETALMAPRED: boolean;
  104485. ENVIRONMENTBRDF: boolean;
  104486. ENVIRONMENTBRDF_RGBD: boolean;
  104487. NORMAL: boolean;
  104488. TANGENT: boolean;
  104489. BUMP: boolean;
  104490. BUMPDIRECTUV: number;
  104491. OBJECTSPACE_NORMALMAP: boolean;
  104492. PARALLAX: boolean;
  104493. PARALLAXOCCLUSION: boolean;
  104494. NORMALXYSCALE: boolean;
  104495. LIGHTMAP: boolean;
  104496. LIGHTMAPDIRECTUV: number;
  104497. USELIGHTMAPASSHADOWMAP: boolean;
  104498. GAMMALIGHTMAP: boolean;
  104499. REFLECTION: boolean;
  104500. REFLECTIONMAP_3D: boolean;
  104501. REFLECTIONMAP_SPHERICAL: boolean;
  104502. REFLECTIONMAP_PLANAR: boolean;
  104503. REFLECTIONMAP_CUBIC: boolean;
  104504. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104505. REFLECTIONMAP_PROJECTION: boolean;
  104506. REFLECTIONMAP_SKYBOX: boolean;
  104507. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  104508. REFLECTIONMAP_EXPLICIT: boolean;
  104509. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104510. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104511. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104512. INVERTCUBICMAP: boolean;
  104513. USESPHERICALFROMREFLECTIONMAP: boolean;
  104514. USESPHERICALINVERTEX: boolean;
  104515. REFLECTIONMAP_OPPOSITEZ: boolean;
  104516. LODINREFLECTIONALPHA: boolean;
  104517. GAMMAREFLECTION: boolean;
  104518. RGBDREFLECTION: boolean;
  104519. RADIANCEOCCLUSION: boolean;
  104520. HORIZONOCCLUSION: boolean;
  104521. INSTANCES: boolean;
  104522. NUM_BONE_INFLUENCERS: number;
  104523. BonesPerMesh: number;
  104524. BONETEXTURE: boolean;
  104525. NONUNIFORMSCALING: boolean;
  104526. MORPHTARGETS: boolean;
  104527. MORPHTARGETS_NORMAL: boolean;
  104528. MORPHTARGETS_TANGENT: boolean;
  104529. NUM_MORPH_INFLUENCERS: number;
  104530. IMAGEPROCESSING: boolean;
  104531. VIGNETTE: boolean;
  104532. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104533. VIGNETTEBLENDMODEOPAQUE: boolean;
  104534. TONEMAPPING: boolean;
  104535. TONEMAPPING_ACES: boolean;
  104536. CONTRAST: boolean;
  104537. COLORCURVES: boolean;
  104538. COLORGRADING: boolean;
  104539. COLORGRADING3D: boolean;
  104540. SAMPLER3DGREENDEPTH: boolean;
  104541. SAMPLER3DBGRMAP: boolean;
  104542. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104543. EXPOSURE: boolean;
  104544. MULTIVIEW: boolean;
  104545. USEPHYSICALLIGHTFALLOFF: boolean;
  104546. USEGLTFLIGHTFALLOFF: boolean;
  104547. TWOSIDEDLIGHTING: boolean;
  104548. SHADOWFLOAT: boolean;
  104549. CLIPPLANE: boolean;
  104550. CLIPPLANE2: boolean;
  104551. CLIPPLANE3: boolean;
  104552. CLIPPLANE4: boolean;
  104553. POINTSIZE: boolean;
  104554. FOG: boolean;
  104555. LOGARITHMICDEPTH: boolean;
  104556. FORCENORMALFORWARD: boolean;
  104557. SPECULARAA: boolean;
  104558. CLEARCOAT: boolean;
  104559. CLEARCOAT_DEFAULTIOR: boolean;
  104560. CLEARCOAT_TEXTURE: boolean;
  104561. CLEARCOAT_TEXTUREDIRECTUV: number;
  104562. CLEARCOAT_BUMP: boolean;
  104563. CLEARCOAT_BUMPDIRECTUV: number;
  104564. CLEARCOAT_TINT: boolean;
  104565. CLEARCOAT_TINT_TEXTURE: boolean;
  104566. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  104567. ANISOTROPIC: boolean;
  104568. ANISOTROPIC_TEXTURE: boolean;
  104569. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104570. BRDF_V_HEIGHT_CORRELATED: boolean;
  104571. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104572. SHEEN: boolean;
  104573. SHEEN_TEXTURE: boolean;
  104574. SHEEN_TEXTUREDIRECTUV: number;
  104575. SHEEN_LINKWITHALBEDO: boolean;
  104576. SUBSURFACE: boolean;
  104577. SS_REFRACTION: boolean;
  104578. SS_TRANSLUCENCY: boolean;
  104579. SS_SCATERRING: boolean;
  104580. SS_THICKNESSANDMASK_TEXTURE: boolean;
  104581. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104582. SS_REFRACTIONMAP_3D: boolean;
  104583. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104584. SS_LODINREFRACTIONALPHA: boolean;
  104585. SS_GAMMAREFRACTION: boolean;
  104586. SS_RGBDREFRACTION: boolean;
  104587. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104588. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104589. UNLIT: boolean;
  104590. DEBUGMODE: number;
  104591. /**
  104592. * Initializes the PBR Material defines.
  104593. */
  104594. constructor();
  104595. /**
  104596. * Resets the PBR Material defines.
  104597. */
  104598. reset(): void;
  104599. }
  104600. /**
  104601. * The Physically based material base class of BJS.
  104602. *
  104603. * This offers the main features of a standard PBR material.
  104604. * For more information, please refer to the documentation :
  104605. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  104606. */
  104607. export abstract class PBRBaseMaterial extends PushMaterial {
  104608. /**
  104609. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104610. */
  104611. static readonly PBRMATERIAL_OPAQUE: number;
  104612. /**
  104613. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104614. */
  104615. static readonly PBRMATERIAL_ALPHATEST: number;
  104616. /**
  104617. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104618. */
  104619. static readonly PBRMATERIAL_ALPHABLEND: number;
  104620. /**
  104621. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104622. * They are also discarded below the alpha cutoff threshold to improve performances.
  104623. */
  104624. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  104625. /**
  104626. * Defines the default value of how much AO map is occluding the analytical lights
  104627. * (point spot...).
  104628. */
  104629. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  104630. /**
  104631. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  104632. */
  104633. static readonly LIGHTFALLOFF_PHYSICAL: number;
  104634. /**
  104635. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  104636. * to enhance interoperability with other engines.
  104637. */
  104638. static readonly LIGHTFALLOFF_GLTF: number;
  104639. /**
  104640. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  104641. * to enhance interoperability with other materials.
  104642. */
  104643. static readonly LIGHTFALLOFF_STANDARD: number;
  104644. /**
  104645. * Intensity of the direct lights e.g. the four lights available in your scene.
  104646. * This impacts both the direct diffuse and specular highlights.
  104647. */
  104648. protected _directIntensity: number;
  104649. /**
  104650. * Intensity of the emissive part of the material.
  104651. * This helps controlling the emissive effect without modifying the emissive color.
  104652. */
  104653. protected _emissiveIntensity: number;
  104654. /**
  104655. * Intensity of the environment e.g. how much the environment will light the object
  104656. * either through harmonics for rough material or through the refelction for shiny ones.
  104657. */
  104658. protected _environmentIntensity: number;
  104659. /**
  104660. * This is a special control allowing the reduction of the specular highlights coming from the
  104661. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  104662. */
  104663. protected _specularIntensity: number;
  104664. /**
  104665. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  104666. */
  104667. private _lightingInfos;
  104668. /**
  104669. * Debug Control allowing disabling the bump map on this material.
  104670. */
  104671. protected _disableBumpMap: boolean;
  104672. /**
  104673. * AKA Diffuse Texture in standard nomenclature.
  104674. */
  104675. protected _albedoTexture: Nullable<BaseTexture>;
  104676. /**
  104677. * AKA Occlusion Texture in other nomenclature.
  104678. */
  104679. protected _ambientTexture: Nullable<BaseTexture>;
  104680. /**
  104681. * AKA Occlusion Texture Intensity in other nomenclature.
  104682. */
  104683. protected _ambientTextureStrength: number;
  104684. /**
  104685. * Defines how much the AO map is occluding the analytical lights (point spot...).
  104686. * 1 means it completely occludes it
  104687. * 0 mean it has no impact
  104688. */
  104689. protected _ambientTextureImpactOnAnalyticalLights: number;
  104690. /**
  104691. * Stores the alpha values in a texture.
  104692. */
  104693. protected _opacityTexture: Nullable<BaseTexture>;
  104694. /**
  104695. * Stores the reflection values in a texture.
  104696. */
  104697. protected _reflectionTexture: Nullable<BaseTexture>;
  104698. /**
  104699. * Stores the emissive values in a texture.
  104700. */
  104701. protected _emissiveTexture: Nullable<BaseTexture>;
  104702. /**
  104703. * AKA Specular texture in other nomenclature.
  104704. */
  104705. protected _reflectivityTexture: Nullable<BaseTexture>;
  104706. /**
  104707. * Used to switch from specular/glossiness to metallic/roughness workflow.
  104708. */
  104709. protected _metallicTexture: Nullable<BaseTexture>;
  104710. /**
  104711. * Specifies the metallic scalar of the metallic/roughness workflow.
  104712. * Can also be used to scale the metalness values of the metallic texture.
  104713. */
  104714. protected _metallic: Nullable<number>;
  104715. /**
  104716. * Specifies the roughness scalar of the metallic/roughness workflow.
  104717. * Can also be used to scale the roughness values of the metallic texture.
  104718. */
  104719. protected _roughness: Nullable<number>;
  104720. /**
  104721. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  104722. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  104723. */
  104724. protected _microSurfaceTexture: Nullable<BaseTexture>;
  104725. /**
  104726. * Stores surface normal data used to displace a mesh in a texture.
  104727. */
  104728. protected _bumpTexture: Nullable<BaseTexture>;
  104729. /**
  104730. * Stores the pre-calculated light information of a mesh in a texture.
  104731. */
  104732. protected _lightmapTexture: Nullable<BaseTexture>;
  104733. /**
  104734. * The color of a material in ambient lighting.
  104735. */
  104736. protected _ambientColor: Color3;
  104737. /**
  104738. * AKA Diffuse Color in other nomenclature.
  104739. */
  104740. protected _albedoColor: Color3;
  104741. /**
  104742. * AKA Specular Color in other nomenclature.
  104743. */
  104744. protected _reflectivityColor: Color3;
  104745. /**
  104746. * The color applied when light is reflected from a material.
  104747. */
  104748. protected _reflectionColor: Color3;
  104749. /**
  104750. * The color applied when light is emitted from a material.
  104751. */
  104752. protected _emissiveColor: Color3;
  104753. /**
  104754. * AKA Glossiness in other nomenclature.
  104755. */
  104756. protected _microSurface: number;
  104757. /**
  104758. * Specifies that the material will use the light map as a show map.
  104759. */
  104760. protected _useLightmapAsShadowmap: boolean;
  104761. /**
  104762. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  104763. * makes the reflect vector face the model (under horizon).
  104764. */
  104765. protected _useHorizonOcclusion: boolean;
  104766. /**
  104767. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  104768. * too much the area relying on ambient texture to define their ambient occlusion.
  104769. */
  104770. protected _useRadianceOcclusion: boolean;
  104771. /**
  104772. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  104773. */
  104774. protected _useAlphaFromAlbedoTexture: boolean;
  104775. /**
  104776. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  104777. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104778. */
  104779. protected _useSpecularOverAlpha: boolean;
  104780. /**
  104781. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  104782. */
  104783. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  104784. /**
  104785. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  104786. */
  104787. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  104788. /**
  104789. * Specifies if the metallic texture contains the roughness information in its green channel.
  104790. */
  104791. protected _useRoughnessFromMetallicTextureGreen: boolean;
  104792. /**
  104793. * Specifies if the metallic texture contains the metallness information in its blue channel.
  104794. */
  104795. protected _useMetallnessFromMetallicTextureBlue: boolean;
  104796. /**
  104797. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  104798. */
  104799. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  104800. /**
  104801. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  104802. */
  104803. protected _useAmbientInGrayScale: boolean;
  104804. /**
  104805. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  104806. * The material will try to infer what glossiness each pixel should be.
  104807. */
  104808. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  104809. /**
  104810. * Defines the falloff type used in this material.
  104811. * It by default is Physical.
  104812. */
  104813. protected _lightFalloff: number;
  104814. /**
  104815. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104816. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104817. */
  104818. protected _useRadianceOverAlpha: boolean;
  104819. /**
  104820. * Allows using an object space normal map (instead of tangent space).
  104821. */
  104822. protected _useObjectSpaceNormalMap: boolean;
  104823. /**
  104824. * Allows using the bump map in parallax mode.
  104825. */
  104826. protected _useParallax: boolean;
  104827. /**
  104828. * Allows using the bump map in parallax occlusion mode.
  104829. */
  104830. protected _useParallaxOcclusion: boolean;
  104831. /**
  104832. * Controls the scale bias of the parallax mode.
  104833. */
  104834. protected _parallaxScaleBias: number;
  104835. /**
  104836. * If sets to true, disables all the lights affecting the material.
  104837. */
  104838. protected _disableLighting: boolean;
  104839. /**
  104840. * Number of Simultaneous lights allowed on the material.
  104841. */
  104842. protected _maxSimultaneousLights: number;
  104843. /**
  104844. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  104845. */
  104846. protected _invertNormalMapX: boolean;
  104847. /**
  104848. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  104849. */
  104850. protected _invertNormalMapY: boolean;
  104851. /**
  104852. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104853. */
  104854. protected _twoSidedLighting: boolean;
  104855. /**
  104856. * Defines the alpha limits in alpha test mode.
  104857. */
  104858. protected _alphaCutOff: number;
  104859. /**
  104860. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  104861. */
  104862. protected _forceAlphaTest: boolean;
  104863. /**
  104864. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104865. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  104866. */
  104867. protected _useAlphaFresnel: boolean;
  104868. /**
  104869. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104870. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  104871. */
  104872. protected _useLinearAlphaFresnel: boolean;
  104873. /**
  104874. * The transparency mode of the material.
  104875. */
  104876. protected _transparencyMode: Nullable<number>;
  104877. /**
  104878. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  104879. * from cos thetav and roughness:
  104880. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  104881. */
  104882. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  104883. /**
  104884. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  104885. */
  104886. protected _forceIrradianceInFragment: boolean;
  104887. /**
  104888. * Force normal to face away from face.
  104889. */
  104890. protected _forceNormalForward: boolean;
  104891. /**
  104892. * Enables specular anti aliasing in the PBR shader.
  104893. * It will both interacts on the Geometry for analytical and IBL lighting.
  104894. * It also prefilter the roughness map based on the bump values.
  104895. */
  104896. protected _enableSpecularAntiAliasing: boolean;
  104897. /**
  104898. * Default configuration related to image processing available in the PBR Material.
  104899. */
  104900. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104901. /**
  104902. * Keep track of the image processing observer to allow dispose and replace.
  104903. */
  104904. private _imageProcessingObserver;
  104905. /**
  104906. * Attaches a new image processing configuration to the PBR Material.
  104907. * @param configuration
  104908. */
  104909. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104910. /**
  104911. * Stores the available render targets.
  104912. */
  104913. private _renderTargets;
  104914. /**
  104915. * Sets the global ambient color for the material used in lighting calculations.
  104916. */
  104917. private _globalAmbientColor;
  104918. /**
  104919. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  104920. */
  104921. private _useLogarithmicDepth;
  104922. /**
  104923. * If set to true, no lighting calculations will be applied.
  104924. */
  104925. private _unlit;
  104926. private _debugMode;
  104927. /**
  104928. * @hidden
  104929. * This is reserved for the inspector.
  104930. * Defines the material debug mode.
  104931. * It helps seeing only some components of the material while troubleshooting.
  104932. */
  104933. debugMode: number;
  104934. /**
  104935. * @hidden
  104936. * This is reserved for the inspector.
  104937. * Specify from where on screen the debug mode should start.
  104938. * The value goes from -1 (full screen) to 1 (not visible)
  104939. * It helps with side by side comparison against the final render
  104940. * This defaults to -1
  104941. */
  104942. private debugLimit;
  104943. /**
  104944. * @hidden
  104945. * This is reserved for the inspector.
  104946. * As the default viewing range might not be enough (if the ambient is really small for instance)
  104947. * You can use the factor to better multiply the final value.
  104948. */
  104949. private debugFactor;
  104950. /**
  104951. * Defines the clear coat layer parameters for the material.
  104952. */
  104953. readonly clearCoat: PBRClearCoatConfiguration;
  104954. /**
  104955. * Defines the anisotropic parameters for the material.
  104956. */
  104957. readonly anisotropy: PBRAnisotropicConfiguration;
  104958. /**
  104959. * Defines the BRDF parameters for the material.
  104960. */
  104961. readonly brdf: PBRBRDFConfiguration;
  104962. /**
  104963. * Defines the Sheen parameters for the material.
  104964. */
  104965. readonly sheen: PBRSheenConfiguration;
  104966. /**
  104967. * Defines the SubSurface parameters for the material.
  104968. */
  104969. readonly subSurface: PBRSubSurfaceConfiguration;
  104970. /**
  104971. * Custom callback helping to override the default shader used in the material.
  104972. */
  104973. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  104974. /**
  104975. * Instantiates a new PBRMaterial instance.
  104976. *
  104977. * @param name The material name
  104978. * @param scene The scene the material will be use in.
  104979. */
  104980. constructor(name: string, scene: Scene);
  104981. /**
  104982. * Gets a boolean indicating that current material needs to register RTT
  104983. */
  104984. readonly hasRenderTargetTextures: boolean;
  104985. /**
  104986. * Gets the name of the material class.
  104987. */
  104988. getClassName(): string;
  104989. /**
  104990. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  104991. */
  104992. /**
  104993. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  104994. */
  104995. useLogarithmicDepth: boolean;
  104996. /**
  104997. * Gets the current transparency mode.
  104998. */
  104999. /**
  105000. * Sets the transparency mode of the material.
  105001. *
  105002. * | Value | Type | Description |
  105003. * | ----- | ----------------------------------- | ----------- |
  105004. * | 0 | OPAQUE | |
  105005. * | 1 | ALPHATEST | |
  105006. * | 2 | ALPHABLEND | |
  105007. * | 3 | ALPHATESTANDBLEND | |
  105008. *
  105009. */
  105010. transparencyMode: Nullable<number>;
  105011. /**
  105012. * Returns true if alpha blending should be disabled.
  105013. */
  105014. private readonly _disableAlphaBlending;
  105015. /**
  105016. * Specifies whether or not this material should be rendered in alpha blend mode.
  105017. */
  105018. needAlphaBlending(): boolean;
  105019. /**
  105020. * Specifies if the mesh will require alpha blending.
  105021. * @param mesh - BJS mesh.
  105022. */
  105023. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  105024. /**
  105025. * Specifies whether or not this material should be rendered in alpha test mode.
  105026. */
  105027. needAlphaTesting(): boolean;
  105028. /**
  105029. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  105030. */
  105031. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  105032. /**
  105033. * Gets the texture used for the alpha test.
  105034. */
  105035. getAlphaTestTexture(): Nullable<BaseTexture>;
  105036. /**
  105037. * Specifies that the submesh is ready to be used.
  105038. * @param mesh - BJS mesh.
  105039. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  105040. * @param useInstances - Specifies that instances should be used.
  105041. * @returns - boolean indicating that the submesh is ready or not.
  105042. */
  105043. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105044. /**
  105045. * Specifies if the material uses metallic roughness workflow.
  105046. * @returns boolean specifiying if the material uses metallic roughness workflow.
  105047. */
  105048. isMetallicWorkflow(): boolean;
  105049. private _prepareEffect;
  105050. private _prepareDefines;
  105051. /**
  105052. * Force shader compilation
  105053. */
  105054. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  105055. clipPlane: boolean;
  105056. }>): void;
  105057. /**
  105058. * Initializes the uniform buffer layout for the shader.
  105059. */
  105060. buildUniformLayout(): void;
  105061. /**
  105062. * Unbinds the material from the mesh
  105063. */
  105064. unbind(): void;
  105065. /**
  105066. * Binds the submesh data.
  105067. * @param world - The world matrix.
  105068. * @param mesh - The BJS mesh.
  105069. * @param subMesh - A submesh of the BJS mesh.
  105070. */
  105071. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105072. /**
  105073. * Returns the animatable textures.
  105074. * @returns - Array of animatable textures.
  105075. */
  105076. getAnimatables(): IAnimatable[];
  105077. /**
  105078. * Returns the texture used for reflections.
  105079. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  105080. */
  105081. private _getReflectionTexture;
  105082. /**
  105083. * Returns an array of the actively used textures.
  105084. * @returns - Array of BaseTextures
  105085. */
  105086. getActiveTextures(): BaseTexture[];
  105087. /**
  105088. * Checks to see if a texture is used in the material.
  105089. * @param texture - Base texture to use.
  105090. * @returns - Boolean specifying if a texture is used in the material.
  105091. */
  105092. hasTexture(texture: BaseTexture): boolean;
  105093. /**
  105094. * Disposes the resources of the material.
  105095. * @param forceDisposeEffect - Forces the disposal of effects.
  105096. * @param forceDisposeTextures - Forces the disposal of all textures.
  105097. */
  105098. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105099. }
  105100. }
  105101. declare module BABYLON {
  105102. /**
  105103. * The Physically based material of BJS.
  105104. *
  105105. * This offers the main features of a standard PBR material.
  105106. * For more information, please refer to the documentation :
  105107. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  105108. */
  105109. export class PBRMaterial extends PBRBaseMaterial {
  105110. /**
  105111. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  105112. */
  105113. static readonly PBRMATERIAL_OPAQUE: number;
  105114. /**
  105115. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  105116. */
  105117. static readonly PBRMATERIAL_ALPHATEST: number;
  105118. /**
  105119. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105120. */
  105121. static readonly PBRMATERIAL_ALPHABLEND: number;
  105122. /**
  105123. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105124. * They are also discarded below the alpha cutoff threshold to improve performances.
  105125. */
  105126. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  105127. /**
  105128. * Defines the default value of how much AO map is occluding the analytical lights
  105129. * (point spot...).
  105130. */
  105131. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  105132. /**
  105133. * Intensity of the direct lights e.g. the four lights available in your scene.
  105134. * This impacts both the direct diffuse and specular highlights.
  105135. */
  105136. directIntensity: number;
  105137. /**
  105138. * Intensity of the emissive part of the material.
  105139. * This helps controlling the emissive effect without modifying the emissive color.
  105140. */
  105141. emissiveIntensity: number;
  105142. /**
  105143. * Intensity of the environment e.g. how much the environment will light the object
  105144. * either through harmonics for rough material or through the refelction for shiny ones.
  105145. */
  105146. environmentIntensity: number;
  105147. /**
  105148. * This is a special control allowing the reduction of the specular highlights coming from the
  105149. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  105150. */
  105151. specularIntensity: number;
  105152. /**
  105153. * Debug Control allowing disabling the bump map on this material.
  105154. */
  105155. disableBumpMap: boolean;
  105156. /**
  105157. * AKA Diffuse Texture in standard nomenclature.
  105158. */
  105159. albedoTexture: BaseTexture;
  105160. /**
  105161. * AKA Occlusion Texture in other nomenclature.
  105162. */
  105163. ambientTexture: BaseTexture;
  105164. /**
  105165. * AKA Occlusion Texture Intensity in other nomenclature.
  105166. */
  105167. ambientTextureStrength: number;
  105168. /**
  105169. * Defines how much the AO map is occluding the analytical lights (point spot...).
  105170. * 1 means it completely occludes it
  105171. * 0 mean it has no impact
  105172. */
  105173. ambientTextureImpactOnAnalyticalLights: number;
  105174. /**
  105175. * Stores the alpha values in a texture.
  105176. */
  105177. opacityTexture: BaseTexture;
  105178. /**
  105179. * Stores the reflection values in a texture.
  105180. */
  105181. reflectionTexture: Nullable<BaseTexture>;
  105182. /**
  105183. * Stores the emissive values in a texture.
  105184. */
  105185. emissiveTexture: BaseTexture;
  105186. /**
  105187. * AKA Specular texture in other nomenclature.
  105188. */
  105189. reflectivityTexture: BaseTexture;
  105190. /**
  105191. * Used to switch from specular/glossiness to metallic/roughness workflow.
  105192. */
  105193. metallicTexture: BaseTexture;
  105194. /**
  105195. * Specifies the metallic scalar of the metallic/roughness workflow.
  105196. * Can also be used to scale the metalness values of the metallic texture.
  105197. */
  105198. metallic: Nullable<number>;
  105199. /**
  105200. * Specifies the roughness scalar of the metallic/roughness workflow.
  105201. * Can also be used to scale the roughness values of the metallic texture.
  105202. */
  105203. roughness: Nullable<number>;
  105204. /**
  105205. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  105206. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  105207. */
  105208. microSurfaceTexture: BaseTexture;
  105209. /**
  105210. * Stores surface normal data used to displace a mesh in a texture.
  105211. */
  105212. bumpTexture: BaseTexture;
  105213. /**
  105214. * Stores the pre-calculated light information of a mesh in a texture.
  105215. */
  105216. lightmapTexture: BaseTexture;
  105217. /**
  105218. * Stores the refracted light information in a texture.
  105219. */
  105220. refractionTexture: Nullable<BaseTexture>;
  105221. /**
  105222. * The color of a material in ambient lighting.
  105223. */
  105224. ambientColor: Color3;
  105225. /**
  105226. * AKA Diffuse Color in other nomenclature.
  105227. */
  105228. albedoColor: Color3;
  105229. /**
  105230. * AKA Specular Color in other nomenclature.
  105231. */
  105232. reflectivityColor: Color3;
  105233. /**
  105234. * The color reflected from the material.
  105235. */
  105236. reflectionColor: Color3;
  105237. /**
  105238. * The color emitted from the material.
  105239. */
  105240. emissiveColor: Color3;
  105241. /**
  105242. * AKA Glossiness in other nomenclature.
  105243. */
  105244. microSurface: number;
  105245. /**
  105246. * source material index of refraction (IOR)' / 'destination material IOR.
  105247. */
  105248. indexOfRefraction: number;
  105249. /**
  105250. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  105251. */
  105252. invertRefractionY: boolean;
  105253. /**
  105254. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  105255. * Materials half opaque for instance using refraction could benefit from this control.
  105256. */
  105257. linkRefractionWithTransparency: boolean;
  105258. /**
  105259. * If true, the light map contains occlusion information instead of lighting info.
  105260. */
  105261. useLightmapAsShadowmap: boolean;
  105262. /**
  105263. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  105264. */
  105265. useAlphaFromAlbedoTexture: boolean;
  105266. /**
  105267. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105268. */
  105269. forceAlphaTest: boolean;
  105270. /**
  105271. * Defines the alpha limits in alpha test mode.
  105272. */
  105273. alphaCutOff: number;
  105274. /**
  105275. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  105276. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105277. */
  105278. useSpecularOverAlpha: boolean;
  105279. /**
  105280. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  105281. */
  105282. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  105283. /**
  105284. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  105285. */
  105286. useRoughnessFromMetallicTextureAlpha: boolean;
  105287. /**
  105288. * Specifies if the metallic texture contains the roughness information in its green channel.
  105289. */
  105290. useRoughnessFromMetallicTextureGreen: boolean;
  105291. /**
  105292. * Specifies if the metallic texture contains the metallness information in its blue channel.
  105293. */
  105294. useMetallnessFromMetallicTextureBlue: boolean;
  105295. /**
  105296. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  105297. */
  105298. useAmbientOcclusionFromMetallicTextureRed: boolean;
  105299. /**
  105300. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  105301. */
  105302. useAmbientInGrayScale: boolean;
  105303. /**
  105304. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  105305. * The material will try to infer what glossiness each pixel should be.
  105306. */
  105307. useAutoMicroSurfaceFromReflectivityMap: boolean;
  105308. /**
  105309. * BJS is using an harcoded light falloff based on a manually sets up range.
  105310. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105311. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105312. */
  105313. /**
  105314. * BJS is using an harcoded light falloff based on a manually sets up range.
  105315. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105316. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105317. */
  105318. usePhysicalLightFalloff: boolean;
  105319. /**
  105320. * In order to support the falloff compatibility with gltf, a special mode has been added
  105321. * to reproduce the gltf light falloff.
  105322. */
  105323. /**
  105324. * In order to support the falloff compatibility with gltf, a special mode has been added
  105325. * to reproduce the gltf light falloff.
  105326. */
  105327. useGLTFLightFalloff: boolean;
  105328. /**
  105329. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105330. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105331. */
  105332. useRadianceOverAlpha: boolean;
  105333. /**
  105334. * Allows using an object space normal map (instead of tangent space).
  105335. */
  105336. useObjectSpaceNormalMap: boolean;
  105337. /**
  105338. * Allows using the bump map in parallax mode.
  105339. */
  105340. useParallax: boolean;
  105341. /**
  105342. * Allows using the bump map in parallax occlusion mode.
  105343. */
  105344. useParallaxOcclusion: boolean;
  105345. /**
  105346. * Controls the scale bias of the parallax mode.
  105347. */
  105348. parallaxScaleBias: number;
  105349. /**
  105350. * If sets to true, disables all the lights affecting the material.
  105351. */
  105352. disableLighting: boolean;
  105353. /**
  105354. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  105355. */
  105356. forceIrradianceInFragment: boolean;
  105357. /**
  105358. * Number of Simultaneous lights allowed on the material.
  105359. */
  105360. maxSimultaneousLights: number;
  105361. /**
  105362. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105363. */
  105364. invertNormalMapX: boolean;
  105365. /**
  105366. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105367. */
  105368. invertNormalMapY: boolean;
  105369. /**
  105370. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105371. */
  105372. twoSidedLighting: boolean;
  105373. /**
  105374. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105375. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  105376. */
  105377. useAlphaFresnel: boolean;
  105378. /**
  105379. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105380. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  105381. */
  105382. useLinearAlphaFresnel: boolean;
  105383. /**
  105384. * Let user defines the brdf lookup texture used for IBL.
  105385. * A default 8bit version is embedded but you could point at :
  105386. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  105387. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  105388. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  105389. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  105390. */
  105391. environmentBRDFTexture: Nullable<BaseTexture>;
  105392. /**
  105393. * Force normal to face away from face.
  105394. */
  105395. forceNormalForward: boolean;
  105396. /**
  105397. * Enables specular anti aliasing in the PBR shader.
  105398. * It will both interacts on the Geometry for analytical and IBL lighting.
  105399. * It also prefilter the roughness map based on the bump values.
  105400. */
  105401. enableSpecularAntiAliasing: boolean;
  105402. /**
  105403. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  105404. * makes the reflect vector face the model (under horizon).
  105405. */
  105406. useHorizonOcclusion: boolean;
  105407. /**
  105408. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  105409. * too much the area relying on ambient texture to define their ambient occlusion.
  105410. */
  105411. useRadianceOcclusion: boolean;
  105412. /**
  105413. * If set to true, no lighting calculations will be applied.
  105414. */
  105415. unlit: boolean;
  105416. /**
  105417. * Gets the image processing configuration used either in this material.
  105418. */
  105419. /**
  105420. * Sets the Default image processing configuration used either in the this material.
  105421. *
  105422. * If sets to null, the scene one is in use.
  105423. */
  105424. imageProcessingConfiguration: ImageProcessingConfiguration;
  105425. /**
  105426. * Gets wether the color curves effect is enabled.
  105427. */
  105428. /**
  105429. * Sets wether the color curves effect is enabled.
  105430. */
  105431. cameraColorCurvesEnabled: boolean;
  105432. /**
  105433. * Gets wether the color grading effect is enabled.
  105434. */
  105435. /**
  105436. * Gets wether the color grading effect is enabled.
  105437. */
  105438. cameraColorGradingEnabled: boolean;
  105439. /**
  105440. * Gets wether tonemapping is enabled or not.
  105441. */
  105442. /**
  105443. * Sets wether tonemapping is enabled or not
  105444. */
  105445. cameraToneMappingEnabled: boolean;
  105446. /**
  105447. * The camera exposure used on this material.
  105448. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105449. * This corresponds to a photographic exposure.
  105450. */
  105451. /**
  105452. * The camera exposure used on this material.
  105453. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105454. * This corresponds to a photographic exposure.
  105455. */
  105456. cameraExposure: number;
  105457. /**
  105458. * Gets The camera contrast used on this material.
  105459. */
  105460. /**
  105461. * Sets The camera contrast used on this material.
  105462. */
  105463. cameraContrast: number;
  105464. /**
  105465. * Gets the Color Grading 2D Lookup Texture.
  105466. */
  105467. /**
  105468. * Sets the Color Grading 2D Lookup Texture.
  105469. */
  105470. cameraColorGradingTexture: Nullable<BaseTexture>;
  105471. /**
  105472. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105473. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105474. * 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;
  105475. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105476. */
  105477. /**
  105478. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105479. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105480. * 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;
  105481. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105482. */
  105483. cameraColorCurves: Nullable<ColorCurves>;
  105484. /**
  105485. * Instantiates a new PBRMaterial instance.
  105486. *
  105487. * @param name The material name
  105488. * @param scene The scene the material will be use in.
  105489. */
  105490. constructor(name: string, scene: Scene);
  105491. /**
  105492. * Returns the name of this material class.
  105493. */
  105494. getClassName(): string;
  105495. /**
  105496. * Makes a duplicate of the current material.
  105497. * @param name - name to use for the new material.
  105498. */
  105499. clone(name: string): PBRMaterial;
  105500. /**
  105501. * Serializes this PBR Material.
  105502. * @returns - An object with the serialized material.
  105503. */
  105504. serialize(): any;
  105505. /**
  105506. * Parses a PBR Material from a serialized object.
  105507. * @param source - Serialized object.
  105508. * @param scene - BJS scene instance.
  105509. * @param rootUrl - url for the scene object
  105510. * @returns - PBRMaterial
  105511. */
  105512. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  105513. }
  105514. }
  105515. declare module BABYLON {
  105516. /**
  105517. * Direct draw surface info
  105518. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  105519. */
  105520. export interface DDSInfo {
  105521. /**
  105522. * Width of the texture
  105523. */
  105524. width: number;
  105525. /**
  105526. * Width of the texture
  105527. */
  105528. height: number;
  105529. /**
  105530. * Number of Mipmaps for the texture
  105531. * @see https://en.wikipedia.org/wiki/Mipmap
  105532. */
  105533. mipmapCount: number;
  105534. /**
  105535. * If the textures format is a known fourCC format
  105536. * @see https://www.fourcc.org/
  105537. */
  105538. isFourCC: boolean;
  105539. /**
  105540. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  105541. */
  105542. isRGB: boolean;
  105543. /**
  105544. * If the texture is a lumincance format
  105545. */
  105546. isLuminance: boolean;
  105547. /**
  105548. * If this is a cube texture
  105549. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  105550. */
  105551. isCube: boolean;
  105552. /**
  105553. * If the texture is a compressed format eg. FOURCC_DXT1
  105554. */
  105555. isCompressed: boolean;
  105556. /**
  105557. * The dxgiFormat of the texture
  105558. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  105559. */
  105560. dxgiFormat: number;
  105561. /**
  105562. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  105563. */
  105564. textureType: number;
  105565. /**
  105566. * Sphericle polynomial created for the dds texture
  105567. */
  105568. sphericalPolynomial?: SphericalPolynomial;
  105569. }
  105570. /**
  105571. * Class used to provide DDS decompression tools
  105572. */
  105573. export class DDSTools {
  105574. /**
  105575. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  105576. */
  105577. static StoreLODInAlphaChannel: boolean;
  105578. /**
  105579. * Gets DDS information from an array buffer
  105580. * @param arrayBuffer defines the array buffer to read data from
  105581. * @returns the DDS information
  105582. */
  105583. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  105584. private static _FloatView;
  105585. private static _Int32View;
  105586. private static _ToHalfFloat;
  105587. private static _FromHalfFloat;
  105588. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  105589. private static _GetHalfFloatRGBAArrayBuffer;
  105590. private static _GetFloatRGBAArrayBuffer;
  105591. private static _GetFloatAsUIntRGBAArrayBuffer;
  105592. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  105593. private static _GetRGBAArrayBuffer;
  105594. private static _ExtractLongWordOrder;
  105595. private static _GetRGBArrayBuffer;
  105596. private static _GetLuminanceArrayBuffer;
  105597. /**
  105598. * Uploads DDS Levels to a Babylon Texture
  105599. * @hidden
  105600. */
  105601. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  105602. }
  105603. interface Engine {
  105604. /**
  105605. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  105606. * @param rootUrl defines the url where the file to load is located
  105607. * @param scene defines the current scene
  105608. * @param lodScale defines scale to apply to the mip map selection
  105609. * @param lodOffset defines offset to apply to the mip map selection
  105610. * @param onLoad defines an optional callback raised when the texture is loaded
  105611. * @param onError defines an optional callback raised if there is an issue to load the texture
  105612. * @param format defines the format of the data
  105613. * @param forcedExtension defines the extension to use to pick the right loader
  105614. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  105615. * @returns the cube texture as an InternalTexture
  105616. */
  105617. 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;
  105618. }
  105619. }
  105620. declare module BABYLON {
  105621. /**
  105622. * Implementation of the DDS Texture Loader.
  105623. * @hidden
  105624. */
  105625. export class _DDSTextureLoader implements IInternalTextureLoader {
  105626. /**
  105627. * Defines wether the loader supports cascade loading the different faces.
  105628. */
  105629. readonly supportCascades: boolean;
  105630. /**
  105631. * This returns if the loader support the current file information.
  105632. * @param extension defines the file extension of the file being loaded
  105633. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105634. * @param fallback defines the fallback internal texture if any
  105635. * @param isBase64 defines whether the texture is encoded as a base64
  105636. * @param isBuffer defines whether the texture data are stored as a buffer
  105637. * @returns true if the loader can load the specified file
  105638. */
  105639. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105640. /**
  105641. * Transform the url before loading if required.
  105642. * @param rootUrl the url of the texture
  105643. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105644. * @returns the transformed texture
  105645. */
  105646. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105647. /**
  105648. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105649. * @param rootUrl the url of the texture
  105650. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105651. * @returns the fallback texture
  105652. */
  105653. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105654. /**
  105655. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105656. * @param data contains the texture data
  105657. * @param texture defines the BabylonJS internal texture
  105658. * @param createPolynomials will be true if polynomials have been requested
  105659. * @param onLoad defines the callback to trigger once the texture is ready
  105660. * @param onError defines the callback to trigger in case of error
  105661. */
  105662. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105663. /**
  105664. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105665. * @param data contains the texture data
  105666. * @param texture defines the BabylonJS internal texture
  105667. * @param callback defines the method to call once ready to upload
  105668. */
  105669. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  105670. }
  105671. }
  105672. declare module BABYLON {
  105673. /** @hidden */
  105674. export var rgbdEncodePixelShader: {
  105675. name: string;
  105676. shader: string;
  105677. };
  105678. }
  105679. declare module BABYLON {
  105680. /**
  105681. * Raw texture data and descriptor sufficient for WebGL texture upload
  105682. */
  105683. export interface EnvironmentTextureInfo {
  105684. /**
  105685. * Version of the environment map
  105686. */
  105687. version: number;
  105688. /**
  105689. * Width of image
  105690. */
  105691. width: number;
  105692. /**
  105693. * Irradiance information stored in the file.
  105694. */
  105695. irradiance: any;
  105696. /**
  105697. * Specular information stored in the file.
  105698. */
  105699. specular: any;
  105700. }
  105701. /**
  105702. * Sets of helpers addressing the serialization and deserialization of environment texture
  105703. * stored in a BabylonJS env file.
  105704. * Those files are usually stored as .env files.
  105705. */
  105706. export class EnvironmentTextureTools {
  105707. /**
  105708. * Magic number identifying the env file.
  105709. */
  105710. private static _MagicBytes;
  105711. /**
  105712. * Gets the environment info from an env file.
  105713. * @param data The array buffer containing the .env bytes.
  105714. * @returns the environment file info (the json header) if successfully parsed.
  105715. */
  105716. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  105717. /**
  105718. * Creates an environment texture from a loaded cube texture.
  105719. * @param texture defines the cube texture to convert in env file
  105720. * @return a promise containing the environment data if succesfull.
  105721. */
  105722. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  105723. /**
  105724. * Creates a JSON representation of the spherical data.
  105725. * @param texture defines the texture containing the polynomials
  105726. * @return the JSON representation of the spherical info
  105727. */
  105728. private static _CreateEnvTextureIrradiance;
  105729. /**
  105730. * Uploads the texture info contained in the env file to the GPU.
  105731. * @param texture defines the internal texture to upload to
  105732. * @param arrayBuffer defines the buffer cotaining the data to load
  105733. * @param info defines the texture info retrieved through the GetEnvInfo method
  105734. * @returns a promise
  105735. */
  105736. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  105737. /**
  105738. * Uploads the levels of image data to the GPU.
  105739. * @param texture defines the internal texture to upload to
  105740. * @param imageData defines the array buffer views of image data [mipmap][face]
  105741. * @returns a promise
  105742. */
  105743. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  105744. /**
  105745. * Uploads spherical polynomials information to the texture.
  105746. * @param texture defines the texture we are trying to upload the information to
  105747. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  105748. */
  105749. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  105750. /** @hidden */
  105751. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  105752. }
  105753. }
  105754. declare module BABYLON {
  105755. /**
  105756. * Implementation of the ENV Texture Loader.
  105757. * @hidden
  105758. */
  105759. export class _ENVTextureLoader implements IInternalTextureLoader {
  105760. /**
  105761. * Defines wether the loader supports cascade loading the different faces.
  105762. */
  105763. readonly supportCascades: boolean;
  105764. /**
  105765. * This returns if the loader support the current file information.
  105766. * @param extension defines the file extension of the file being loaded
  105767. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105768. * @param fallback defines the fallback internal texture if any
  105769. * @param isBase64 defines whether the texture is encoded as a base64
  105770. * @param isBuffer defines whether the texture data are stored as a buffer
  105771. * @returns true if the loader can load the specified file
  105772. */
  105773. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105774. /**
  105775. * Transform the url before loading if required.
  105776. * @param rootUrl the url of the texture
  105777. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105778. * @returns the transformed texture
  105779. */
  105780. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105781. /**
  105782. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105783. * @param rootUrl the url of the texture
  105784. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105785. * @returns the fallback texture
  105786. */
  105787. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105788. /**
  105789. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105790. * @param data contains the texture data
  105791. * @param texture defines the BabylonJS internal texture
  105792. * @param createPolynomials will be true if polynomials have been requested
  105793. * @param onLoad defines the callback to trigger once the texture is ready
  105794. * @param onError defines the callback to trigger in case of error
  105795. */
  105796. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105797. /**
  105798. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105799. * @param data contains the texture data
  105800. * @param texture defines the BabylonJS internal texture
  105801. * @param callback defines the method to call once ready to upload
  105802. */
  105803. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  105804. }
  105805. }
  105806. declare module BABYLON {
  105807. /**
  105808. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  105809. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  105810. */
  105811. export class KhronosTextureContainer {
  105812. /** contents of the KTX container file */
  105813. arrayBuffer: any;
  105814. private static HEADER_LEN;
  105815. private static COMPRESSED_2D;
  105816. private static COMPRESSED_3D;
  105817. private static TEX_2D;
  105818. private static TEX_3D;
  105819. /**
  105820. * Gets the openGL type
  105821. */
  105822. glType: number;
  105823. /**
  105824. * Gets the openGL type size
  105825. */
  105826. glTypeSize: number;
  105827. /**
  105828. * Gets the openGL format
  105829. */
  105830. glFormat: number;
  105831. /**
  105832. * Gets the openGL internal format
  105833. */
  105834. glInternalFormat: number;
  105835. /**
  105836. * Gets the base internal format
  105837. */
  105838. glBaseInternalFormat: number;
  105839. /**
  105840. * Gets image width in pixel
  105841. */
  105842. pixelWidth: number;
  105843. /**
  105844. * Gets image height in pixel
  105845. */
  105846. pixelHeight: number;
  105847. /**
  105848. * Gets image depth in pixels
  105849. */
  105850. pixelDepth: number;
  105851. /**
  105852. * Gets the number of array elements
  105853. */
  105854. numberOfArrayElements: number;
  105855. /**
  105856. * Gets the number of faces
  105857. */
  105858. numberOfFaces: number;
  105859. /**
  105860. * Gets the number of mipmap levels
  105861. */
  105862. numberOfMipmapLevels: number;
  105863. /**
  105864. * Gets the bytes of key value data
  105865. */
  105866. bytesOfKeyValueData: number;
  105867. /**
  105868. * Gets the load type
  105869. */
  105870. loadType: number;
  105871. /**
  105872. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  105873. */
  105874. isInvalid: boolean;
  105875. /**
  105876. * Creates a new KhronosTextureContainer
  105877. * @param arrayBuffer contents of the KTX container file
  105878. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  105879. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  105880. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  105881. */
  105882. constructor(
  105883. /** contents of the KTX container file */
  105884. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  105885. /**
  105886. * Uploads KTX content to a Babylon Texture.
  105887. * It is assumed that the texture has already been created & is currently bound
  105888. * @hidden
  105889. */
  105890. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  105891. private _upload2DCompressedLevels;
  105892. }
  105893. }
  105894. declare module BABYLON {
  105895. /**
  105896. * Implementation of the KTX Texture Loader.
  105897. * @hidden
  105898. */
  105899. export class _KTXTextureLoader implements IInternalTextureLoader {
  105900. /**
  105901. * Defines wether the loader supports cascade loading the different faces.
  105902. */
  105903. readonly supportCascades: boolean;
  105904. /**
  105905. * This returns if the loader support the current file information.
  105906. * @param extension defines the file extension of the file being loaded
  105907. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105908. * @param fallback defines the fallback internal texture if any
  105909. * @param isBase64 defines whether the texture is encoded as a base64
  105910. * @param isBuffer defines whether the texture data are stored as a buffer
  105911. * @returns true if the loader can load the specified file
  105912. */
  105913. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105914. /**
  105915. * Transform the url before loading if required.
  105916. * @param rootUrl the url of the texture
  105917. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105918. * @returns the transformed texture
  105919. */
  105920. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105921. /**
  105922. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105923. * @param rootUrl the url of the texture
  105924. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105925. * @returns the fallback texture
  105926. */
  105927. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105928. /**
  105929. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105930. * @param data contains the texture data
  105931. * @param texture defines the BabylonJS internal texture
  105932. * @param createPolynomials will be true if polynomials have been requested
  105933. * @param onLoad defines the callback to trigger once the texture is ready
  105934. * @param onError defines the callback to trigger in case of error
  105935. */
  105936. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105937. /**
  105938. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105939. * @param data contains the texture data
  105940. * @param texture defines the BabylonJS internal texture
  105941. * @param callback defines the method to call once ready to upload
  105942. */
  105943. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  105944. }
  105945. }
  105946. declare module BABYLON {
  105947. /** @hidden */
  105948. export var _forceSceneHelpersToBundle: boolean;
  105949. interface Scene {
  105950. /**
  105951. * Creates a default light for the scene.
  105952. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  105953. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  105954. */
  105955. createDefaultLight(replace?: boolean): void;
  105956. /**
  105957. * Creates a default camera for the scene.
  105958. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  105959. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  105960. * @param replace has default false, when true replaces the active camera in the scene
  105961. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  105962. */
  105963. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  105964. /**
  105965. * Creates a default camera and a default light.
  105966. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  105967. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  105968. * @param replace has the default false, when true replaces the active camera/light in the scene
  105969. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  105970. */
  105971. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  105972. /**
  105973. * Creates a new sky box
  105974. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  105975. * @param environmentTexture defines the texture to use as environment texture
  105976. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  105977. * @param scale defines the overall scale of the skybox
  105978. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  105979. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  105980. * @returns a new mesh holding the sky box
  105981. */
  105982. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  105983. /**
  105984. * Creates a new environment
  105985. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  105986. * @param options defines the options you can use to configure the environment
  105987. * @returns the new EnvironmentHelper
  105988. */
  105989. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  105990. /**
  105991. * Creates a new VREXperienceHelper
  105992. * @see http://doc.babylonjs.com/how_to/webvr_helper
  105993. * @param webVROptions defines the options used to create the new VREXperienceHelper
  105994. * @returns a new VREXperienceHelper
  105995. */
  105996. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  105997. /**
  105998. * Creates a new XREXperienceHelper
  105999. * @see http://doc.babylonjs.com/how_to/webxr
  106000. * @returns a promise for a new XREXperienceHelper
  106001. */
  106002. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  106003. }
  106004. }
  106005. declare module BABYLON {
  106006. /**
  106007. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  106008. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  106009. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  106010. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  106011. */
  106012. export class VideoDome extends TransformNode {
  106013. /**
  106014. * Define the video source as a Monoscopic panoramic 360 video.
  106015. */
  106016. static readonly MODE_MONOSCOPIC: number;
  106017. /**
  106018. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  106019. */
  106020. static readonly MODE_TOPBOTTOM: number;
  106021. /**
  106022. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  106023. */
  106024. static readonly MODE_SIDEBYSIDE: number;
  106025. private _useDirectMapping;
  106026. /**
  106027. * The video texture being displayed on the sphere
  106028. */
  106029. protected _videoTexture: VideoTexture;
  106030. /**
  106031. * Gets the video texture being displayed on the sphere
  106032. */
  106033. readonly videoTexture: VideoTexture;
  106034. /**
  106035. * The skybox material
  106036. */
  106037. protected _material: BackgroundMaterial;
  106038. /**
  106039. * The surface used for the skybox
  106040. */
  106041. protected _mesh: Mesh;
  106042. /**
  106043. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106044. * Also see the options.resolution property.
  106045. */
  106046. fovMultiplier: number;
  106047. private _videoMode;
  106048. /**
  106049. * Gets or set the current video mode for the video. It can be:
  106050. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  106051. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  106052. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  106053. */
  106054. videoMode: number;
  106055. /**
  106056. * Oberserver used in Stereoscopic VR Mode.
  106057. */
  106058. private _onBeforeCameraRenderObserver;
  106059. /**
  106060. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  106061. * @param name Element's name, child elements will append suffixes for their own names.
  106062. * @param urlsOrVideo defines the url(s) or the video element to use
  106063. * @param options An object containing optional or exposed sub element properties
  106064. */
  106065. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  106066. resolution?: number;
  106067. clickToPlay?: boolean;
  106068. autoPlay?: boolean;
  106069. loop?: boolean;
  106070. size?: number;
  106071. poster?: string;
  106072. faceForward?: boolean;
  106073. useDirectMapping?: boolean;
  106074. }, scene: Scene);
  106075. private _changeVideoMode;
  106076. /**
  106077. * Releases resources associated with this node.
  106078. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106079. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106080. */
  106081. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106082. }
  106083. }
  106084. declare module BABYLON {
  106085. /**
  106086. * This class can be used to get instrumentation data from a Babylon engine
  106087. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106088. */
  106089. export class EngineInstrumentation implements IDisposable {
  106090. /**
  106091. * Define the instrumented engine.
  106092. */
  106093. engine: Engine;
  106094. private _captureGPUFrameTime;
  106095. private _gpuFrameTimeToken;
  106096. private _gpuFrameTime;
  106097. private _captureShaderCompilationTime;
  106098. private _shaderCompilationTime;
  106099. private _onBeginFrameObserver;
  106100. private _onEndFrameObserver;
  106101. private _onBeforeShaderCompilationObserver;
  106102. private _onAfterShaderCompilationObserver;
  106103. /**
  106104. * Gets the perf counter used for GPU frame time
  106105. */
  106106. readonly gpuFrameTimeCounter: PerfCounter;
  106107. /**
  106108. * Gets the GPU frame time capture status
  106109. */
  106110. /**
  106111. * Enable or disable the GPU frame time capture
  106112. */
  106113. captureGPUFrameTime: boolean;
  106114. /**
  106115. * Gets the perf counter used for shader compilation time
  106116. */
  106117. readonly shaderCompilationTimeCounter: PerfCounter;
  106118. /**
  106119. * Gets the shader compilation time capture status
  106120. */
  106121. /**
  106122. * Enable or disable the shader compilation time capture
  106123. */
  106124. captureShaderCompilationTime: boolean;
  106125. /**
  106126. * Instantiates a new engine instrumentation.
  106127. * This class can be used to get instrumentation data from a Babylon engine
  106128. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106129. * @param engine Defines the engine to instrument
  106130. */
  106131. constructor(
  106132. /**
  106133. * Define the instrumented engine.
  106134. */
  106135. engine: Engine);
  106136. /**
  106137. * Dispose and release associated resources.
  106138. */
  106139. dispose(): void;
  106140. }
  106141. }
  106142. declare module BABYLON {
  106143. /**
  106144. * This class can be used to get instrumentation data from a Babylon engine
  106145. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  106146. */
  106147. export class SceneInstrumentation implements IDisposable {
  106148. /**
  106149. * Defines the scene to instrument
  106150. */
  106151. scene: Scene;
  106152. private _captureActiveMeshesEvaluationTime;
  106153. private _activeMeshesEvaluationTime;
  106154. private _captureRenderTargetsRenderTime;
  106155. private _renderTargetsRenderTime;
  106156. private _captureFrameTime;
  106157. private _frameTime;
  106158. private _captureRenderTime;
  106159. private _renderTime;
  106160. private _captureInterFrameTime;
  106161. private _interFrameTime;
  106162. private _captureParticlesRenderTime;
  106163. private _particlesRenderTime;
  106164. private _captureSpritesRenderTime;
  106165. private _spritesRenderTime;
  106166. private _capturePhysicsTime;
  106167. private _physicsTime;
  106168. private _captureAnimationsTime;
  106169. private _animationsTime;
  106170. private _captureCameraRenderTime;
  106171. private _cameraRenderTime;
  106172. private _onBeforeActiveMeshesEvaluationObserver;
  106173. private _onAfterActiveMeshesEvaluationObserver;
  106174. private _onBeforeRenderTargetsRenderObserver;
  106175. private _onAfterRenderTargetsRenderObserver;
  106176. private _onAfterRenderObserver;
  106177. private _onBeforeDrawPhaseObserver;
  106178. private _onAfterDrawPhaseObserver;
  106179. private _onBeforeAnimationsObserver;
  106180. private _onBeforeParticlesRenderingObserver;
  106181. private _onAfterParticlesRenderingObserver;
  106182. private _onBeforeSpritesRenderingObserver;
  106183. private _onAfterSpritesRenderingObserver;
  106184. private _onBeforePhysicsObserver;
  106185. private _onAfterPhysicsObserver;
  106186. private _onAfterAnimationsObserver;
  106187. private _onBeforeCameraRenderObserver;
  106188. private _onAfterCameraRenderObserver;
  106189. /**
  106190. * Gets the perf counter used for active meshes evaluation time
  106191. */
  106192. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  106193. /**
  106194. * Gets the active meshes evaluation time capture status
  106195. */
  106196. /**
  106197. * Enable or disable the active meshes evaluation time capture
  106198. */
  106199. captureActiveMeshesEvaluationTime: boolean;
  106200. /**
  106201. * Gets the perf counter used for render targets render time
  106202. */
  106203. readonly renderTargetsRenderTimeCounter: PerfCounter;
  106204. /**
  106205. * Gets the render targets render time capture status
  106206. */
  106207. /**
  106208. * Enable or disable the render targets render time capture
  106209. */
  106210. captureRenderTargetsRenderTime: boolean;
  106211. /**
  106212. * Gets the perf counter used for particles render time
  106213. */
  106214. readonly particlesRenderTimeCounter: PerfCounter;
  106215. /**
  106216. * Gets the particles render time capture status
  106217. */
  106218. /**
  106219. * Enable or disable the particles render time capture
  106220. */
  106221. captureParticlesRenderTime: boolean;
  106222. /**
  106223. * Gets the perf counter used for sprites render time
  106224. */
  106225. readonly spritesRenderTimeCounter: PerfCounter;
  106226. /**
  106227. * Gets the sprites render time capture status
  106228. */
  106229. /**
  106230. * Enable or disable the sprites render time capture
  106231. */
  106232. captureSpritesRenderTime: boolean;
  106233. /**
  106234. * Gets the perf counter used for physics time
  106235. */
  106236. readonly physicsTimeCounter: PerfCounter;
  106237. /**
  106238. * Gets the physics time capture status
  106239. */
  106240. /**
  106241. * Enable or disable the physics time capture
  106242. */
  106243. capturePhysicsTime: boolean;
  106244. /**
  106245. * Gets the perf counter used for animations time
  106246. */
  106247. readonly animationsTimeCounter: PerfCounter;
  106248. /**
  106249. * Gets the animations time capture status
  106250. */
  106251. /**
  106252. * Enable or disable the animations time capture
  106253. */
  106254. captureAnimationsTime: boolean;
  106255. /**
  106256. * Gets the perf counter used for frame time capture
  106257. */
  106258. readonly frameTimeCounter: PerfCounter;
  106259. /**
  106260. * Gets the frame time capture status
  106261. */
  106262. /**
  106263. * Enable or disable the frame time capture
  106264. */
  106265. captureFrameTime: boolean;
  106266. /**
  106267. * Gets the perf counter used for inter-frames time capture
  106268. */
  106269. readonly interFrameTimeCounter: PerfCounter;
  106270. /**
  106271. * Gets the inter-frames time capture status
  106272. */
  106273. /**
  106274. * Enable or disable the inter-frames time capture
  106275. */
  106276. captureInterFrameTime: boolean;
  106277. /**
  106278. * Gets the perf counter used for render time capture
  106279. */
  106280. readonly renderTimeCounter: PerfCounter;
  106281. /**
  106282. * Gets the render time capture status
  106283. */
  106284. /**
  106285. * Enable or disable the render time capture
  106286. */
  106287. captureRenderTime: boolean;
  106288. /**
  106289. * Gets the perf counter used for camera render time capture
  106290. */
  106291. readonly cameraRenderTimeCounter: PerfCounter;
  106292. /**
  106293. * Gets the camera render time capture status
  106294. */
  106295. /**
  106296. * Enable or disable the camera render time capture
  106297. */
  106298. captureCameraRenderTime: boolean;
  106299. /**
  106300. * Gets the perf counter used for draw calls
  106301. */
  106302. readonly drawCallsCounter: PerfCounter;
  106303. /**
  106304. * Instantiates a new scene instrumentation.
  106305. * This class can be used to get instrumentation data from a Babylon engine
  106306. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  106307. * @param scene Defines the scene to instrument
  106308. */
  106309. constructor(
  106310. /**
  106311. * Defines the scene to instrument
  106312. */
  106313. scene: Scene);
  106314. /**
  106315. * Dispose and release associated resources.
  106316. */
  106317. dispose(): void;
  106318. }
  106319. }
  106320. declare module BABYLON {
  106321. /** @hidden */
  106322. export var glowMapGenerationPixelShader: {
  106323. name: string;
  106324. shader: string;
  106325. };
  106326. }
  106327. declare module BABYLON {
  106328. /** @hidden */
  106329. export var glowMapGenerationVertexShader: {
  106330. name: string;
  106331. shader: string;
  106332. };
  106333. }
  106334. declare module BABYLON {
  106335. /**
  106336. * Effect layer options. This helps customizing the behaviour
  106337. * of the effect layer.
  106338. */
  106339. export interface IEffectLayerOptions {
  106340. /**
  106341. * Multiplication factor apply to the canvas size to compute the render target size
  106342. * used to generated the objects (the smaller the faster).
  106343. */
  106344. mainTextureRatio: number;
  106345. /**
  106346. * Enforces a fixed size texture to ensure effect stability across devices.
  106347. */
  106348. mainTextureFixedSize?: number;
  106349. /**
  106350. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  106351. */
  106352. alphaBlendingMode: number;
  106353. /**
  106354. * The camera attached to the layer.
  106355. */
  106356. camera: Nullable<Camera>;
  106357. /**
  106358. * The rendering group to draw the layer in.
  106359. */
  106360. renderingGroupId: number;
  106361. }
  106362. /**
  106363. * The effect layer Helps adding post process effect blended with the main pass.
  106364. *
  106365. * This can be for instance use to generate glow or higlight effects on the scene.
  106366. *
  106367. * The effect layer class can not be used directly and is intented to inherited from to be
  106368. * customized per effects.
  106369. */
  106370. export abstract class EffectLayer {
  106371. private _vertexBuffers;
  106372. private _indexBuffer;
  106373. private _cachedDefines;
  106374. private _effectLayerMapGenerationEffect;
  106375. private _effectLayerOptions;
  106376. private _mergeEffect;
  106377. protected _scene: Scene;
  106378. protected _engine: Engine;
  106379. protected _maxSize: number;
  106380. protected _mainTextureDesiredSize: ISize;
  106381. protected _mainTexture: RenderTargetTexture;
  106382. protected _shouldRender: boolean;
  106383. protected _postProcesses: PostProcess[];
  106384. protected _textures: BaseTexture[];
  106385. protected _emissiveTextureAndColor: {
  106386. texture: Nullable<BaseTexture>;
  106387. color: Color4;
  106388. };
  106389. /**
  106390. * The name of the layer
  106391. */
  106392. name: string;
  106393. /**
  106394. * The clear color of the texture used to generate the glow map.
  106395. */
  106396. neutralColor: Color4;
  106397. /**
  106398. * Specifies wether the highlight layer is enabled or not.
  106399. */
  106400. isEnabled: boolean;
  106401. /**
  106402. * Gets the camera attached to the layer.
  106403. */
  106404. readonly camera: Nullable<Camera>;
  106405. /**
  106406. * Gets the rendering group id the layer should render in.
  106407. */
  106408. readonly renderingGroupId: number;
  106409. /**
  106410. * An event triggered when the effect layer has been disposed.
  106411. */
  106412. onDisposeObservable: Observable<EffectLayer>;
  106413. /**
  106414. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  106415. */
  106416. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  106417. /**
  106418. * An event triggered when the generated texture is being merged in the scene.
  106419. */
  106420. onBeforeComposeObservable: Observable<EffectLayer>;
  106421. /**
  106422. * An event triggered when the generated texture has been merged in the scene.
  106423. */
  106424. onAfterComposeObservable: Observable<EffectLayer>;
  106425. /**
  106426. * An event triggered when the efffect layer changes its size.
  106427. */
  106428. onSizeChangedObservable: Observable<EffectLayer>;
  106429. /** @hidden */
  106430. static _SceneComponentInitialization: (scene: Scene) => void;
  106431. /**
  106432. * Instantiates a new effect Layer and references it in the scene.
  106433. * @param name The name of the layer
  106434. * @param scene The scene to use the layer in
  106435. */
  106436. constructor(
  106437. /** The Friendly of the effect in the scene */
  106438. name: string, scene: Scene);
  106439. /**
  106440. * Get the effect name of the layer.
  106441. * @return The effect name
  106442. */
  106443. abstract getEffectName(): string;
  106444. /**
  106445. * Checks for the readiness of the element composing the layer.
  106446. * @param subMesh the mesh to check for
  106447. * @param useInstances specify wether or not to use instances to render the mesh
  106448. * @return true if ready otherwise, false
  106449. */
  106450. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106451. /**
  106452. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106453. * @returns true if the effect requires stencil during the main canvas render pass.
  106454. */
  106455. abstract needStencil(): boolean;
  106456. /**
  106457. * Create the merge effect. This is the shader use to blit the information back
  106458. * to the main canvas at the end of the scene rendering.
  106459. * @returns The effect containing the shader used to merge the effect on the main canvas
  106460. */
  106461. protected abstract _createMergeEffect(): Effect;
  106462. /**
  106463. * Creates the render target textures and post processes used in the effect layer.
  106464. */
  106465. protected abstract _createTextureAndPostProcesses(): void;
  106466. /**
  106467. * Implementation specific of rendering the generating effect on the main canvas.
  106468. * @param effect The effect used to render through
  106469. */
  106470. protected abstract _internalRender(effect: Effect): void;
  106471. /**
  106472. * Sets the required values for both the emissive texture and and the main color.
  106473. */
  106474. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106475. /**
  106476. * Free any resources and references associated to a mesh.
  106477. * Internal use
  106478. * @param mesh The mesh to free.
  106479. */
  106480. abstract _disposeMesh(mesh: Mesh): void;
  106481. /**
  106482. * Serializes this layer (Glow or Highlight for example)
  106483. * @returns a serialized layer object
  106484. */
  106485. abstract serialize?(): any;
  106486. /**
  106487. * Initializes the effect layer with the required options.
  106488. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  106489. */
  106490. protected _init(options: Partial<IEffectLayerOptions>): void;
  106491. /**
  106492. * Generates the index buffer of the full screen quad blending to the main canvas.
  106493. */
  106494. private _generateIndexBuffer;
  106495. /**
  106496. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  106497. */
  106498. private _genrateVertexBuffer;
  106499. /**
  106500. * Sets the main texture desired size which is the closest power of two
  106501. * of the engine canvas size.
  106502. */
  106503. private _setMainTextureSize;
  106504. /**
  106505. * Creates the main texture for the effect layer.
  106506. */
  106507. protected _createMainTexture(): void;
  106508. /**
  106509. * Adds specific effects defines.
  106510. * @param defines The defines to add specifics to.
  106511. */
  106512. protected _addCustomEffectDefines(defines: string[]): void;
  106513. /**
  106514. * Checks for the readiness of the element composing the layer.
  106515. * @param subMesh the mesh to check for
  106516. * @param useInstances specify wether or not to use instances to render the mesh
  106517. * @param emissiveTexture the associated emissive texture used to generate the glow
  106518. * @return true if ready otherwise, false
  106519. */
  106520. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  106521. /**
  106522. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  106523. */
  106524. render(): void;
  106525. /**
  106526. * Determine if a given mesh will be used in the current effect.
  106527. * @param mesh mesh to test
  106528. * @returns true if the mesh will be used
  106529. */
  106530. hasMesh(mesh: AbstractMesh): boolean;
  106531. /**
  106532. * Returns true if the layer contains information to display, otherwise false.
  106533. * @returns true if the glow layer should be rendered
  106534. */
  106535. shouldRender(): boolean;
  106536. /**
  106537. * Returns true if the mesh should render, otherwise false.
  106538. * @param mesh The mesh to render
  106539. * @returns true if it should render otherwise false
  106540. */
  106541. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  106542. /**
  106543. * Returns true if the mesh can be rendered, otherwise false.
  106544. * @param mesh The mesh to render
  106545. * @param material The material used on the mesh
  106546. * @returns true if it can be rendered otherwise false
  106547. */
  106548. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  106549. /**
  106550. * Returns true if the mesh should render, otherwise false.
  106551. * @param mesh The mesh to render
  106552. * @returns true if it should render otherwise false
  106553. */
  106554. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  106555. /**
  106556. * Renders the submesh passed in parameter to the generation map.
  106557. */
  106558. protected _renderSubMesh(subMesh: SubMesh): void;
  106559. /**
  106560. * Rebuild the required buffers.
  106561. * @hidden Internal use only.
  106562. */
  106563. _rebuild(): void;
  106564. /**
  106565. * Dispose only the render target textures and post process.
  106566. */
  106567. private _disposeTextureAndPostProcesses;
  106568. /**
  106569. * Dispose the highlight layer and free resources.
  106570. */
  106571. dispose(): void;
  106572. /**
  106573. * Gets the class name of the effect layer
  106574. * @returns the string with the class name of the effect layer
  106575. */
  106576. getClassName(): string;
  106577. /**
  106578. * Creates an effect layer from parsed effect layer data
  106579. * @param parsedEffectLayer defines effect layer data
  106580. * @param scene defines the current scene
  106581. * @param rootUrl defines the root URL containing the effect layer information
  106582. * @returns a parsed effect Layer
  106583. */
  106584. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  106585. }
  106586. }
  106587. declare module BABYLON {
  106588. interface AbstractScene {
  106589. /**
  106590. * The list of effect layers (highlights/glow) added to the scene
  106591. * @see http://doc.babylonjs.com/how_to/highlight_layer
  106592. * @see http://doc.babylonjs.com/how_to/glow_layer
  106593. */
  106594. effectLayers: Array<EffectLayer>;
  106595. /**
  106596. * Removes the given effect layer from this scene.
  106597. * @param toRemove defines the effect layer to remove
  106598. * @returns the index of the removed effect layer
  106599. */
  106600. removeEffectLayer(toRemove: EffectLayer): number;
  106601. /**
  106602. * Adds the given effect layer to this scene
  106603. * @param newEffectLayer defines the effect layer to add
  106604. */
  106605. addEffectLayer(newEffectLayer: EffectLayer): void;
  106606. }
  106607. /**
  106608. * Defines the layer scene component responsible to manage any effect layers
  106609. * in a given scene.
  106610. */
  106611. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  106612. /**
  106613. * The component name helpfull to identify the component in the list of scene components.
  106614. */
  106615. readonly name: string;
  106616. /**
  106617. * The scene the component belongs to.
  106618. */
  106619. scene: Scene;
  106620. private _engine;
  106621. private _renderEffects;
  106622. private _needStencil;
  106623. private _previousStencilState;
  106624. /**
  106625. * Creates a new instance of the component for the given scene
  106626. * @param scene Defines the scene to register the component in
  106627. */
  106628. constructor(scene: Scene);
  106629. /**
  106630. * Registers the component in a given scene
  106631. */
  106632. register(): void;
  106633. /**
  106634. * Rebuilds the elements related to this component in case of
  106635. * context lost for instance.
  106636. */
  106637. rebuild(): void;
  106638. /**
  106639. * Serializes the component data to the specified json object
  106640. * @param serializationObject The object to serialize to
  106641. */
  106642. serialize(serializationObject: any): void;
  106643. /**
  106644. * Adds all the element from the container to the scene
  106645. * @param container the container holding the elements
  106646. */
  106647. addFromContainer(container: AbstractScene): void;
  106648. /**
  106649. * Removes all the elements in the container from the scene
  106650. * @param container contains the elements to remove
  106651. * @param dispose if the removed element should be disposed (default: false)
  106652. */
  106653. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106654. /**
  106655. * Disposes the component and the associated ressources.
  106656. */
  106657. dispose(): void;
  106658. private _isReadyForMesh;
  106659. private _renderMainTexture;
  106660. private _setStencil;
  106661. private _setStencilBack;
  106662. private _draw;
  106663. private _drawCamera;
  106664. private _drawRenderingGroup;
  106665. }
  106666. }
  106667. declare module BABYLON {
  106668. /** @hidden */
  106669. export var glowMapMergePixelShader: {
  106670. name: string;
  106671. shader: string;
  106672. };
  106673. }
  106674. declare module BABYLON {
  106675. /** @hidden */
  106676. export var glowMapMergeVertexShader: {
  106677. name: string;
  106678. shader: string;
  106679. };
  106680. }
  106681. declare module BABYLON {
  106682. interface AbstractScene {
  106683. /**
  106684. * Return a the first highlight layer of the scene with a given name.
  106685. * @param name The name of the highlight layer to look for.
  106686. * @return The highlight layer if found otherwise null.
  106687. */
  106688. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  106689. }
  106690. /**
  106691. * Glow layer options. This helps customizing the behaviour
  106692. * of the glow layer.
  106693. */
  106694. export interface IGlowLayerOptions {
  106695. /**
  106696. * Multiplication factor apply to the canvas size to compute the render target size
  106697. * used to generated the glowing objects (the smaller the faster).
  106698. */
  106699. mainTextureRatio: number;
  106700. /**
  106701. * Enforces a fixed size texture to ensure resize independant blur.
  106702. */
  106703. mainTextureFixedSize?: number;
  106704. /**
  106705. * How big is the kernel of the blur texture.
  106706. */
  106707. blurKernelSize: number;
  106708. /**
  106709. * The camera attached to the layer.
  106710. */
  106711. camera: Nullable<Camera>;
  106712. /**
  106713. * Enable MSAA by chosing the number of samples.
  106714. */
  106715. mainTextureSamples?: number;
  106716. /**
  106717. * The rendering group to draw the layer in.
  106718. */
  106719. renderingGroupId: number;
  106720. }
  106721. /**
  106722. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  106723. *
  106724. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  106725. * glowy meshes to your scene.
  106726. *
  106727. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  106728. */
  106729. export class GlowLayer extends EffectLayer {
  106730. /**
  106731. * Effect Name of the layer.
  106732. */
  106733. static readonly EffectName: string;
  106734. /**
  106735. * The default blur kernel size used for the glow.
  106736. */
  106737. static DefaultBlurKernelSize: number;
  106738. /**
  106739. * The default texture size ratio used for the glow.
  106740. */
  106741. static DefaultTextureRatio: number;
  106742. /**
  106743. * Sets the kernel size of the blur.
  106744. */
  106745. /**
  106746. * Gets the kernel size of the blur.
  106747. */
  106748. blurKernelSize: number;
  106749. /**
  106750. * Sets the glow intensity.
  106751. */
  106752. /**
  106753. * Gets the glow intensity.
  106754. */
  106755. intensity: number;
  106756. private _options;
  106757. private _intensity;
  106758. private _horizontalBlurPostprocess1;
  106759. private _verticalBlurPostprocess1;
  106760. private _horizontalBlurPostprocess2;
  106761. private _verticalBlurPostprocess2;
  106762. private _blurTexture1;
  106763. private _blurTexture2;
  106764. private _postProcesses1;
  106765. private _postProcesses2;
  106766. private _includedOnlyMeshes;
  106767. private _excludedMeshes;
  106768. /**
  106769. * Callback used to let the user override the color selection on a per mesh basis
  106770. */
  106771. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  106772. /**
  106773. * Callback used to let the user override the texture selection on a per mesh basis
  106774. */
  106775. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  106776. /**
  106777. * Instantiates a new glow Layer and references it to the scene.
  106778. * @param name The name of the layer
  106779. * @param scene The scene to use the layer in
  106780. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  106781. */
  106782. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  106783. /**
  106784. * Get the effect name of the layer.
  106785. * @return The effect name
  106786. */
  106787. getEffectName(): string;
  106788. /**
  106789. * Create the merge effect. This is the shader use to blit the information back
  106790. * to the main canvas at the end of the scene rendering.
  106791. */
  106792. protected _createMergeEffect(): Effect;
  106793. /**
  106794. * Creates the render target textures and post processes used in the glow layer.
  106795. */
  106796. protected _createTextureAndPostProcesses(): void;
  106797. /**
  106798. * Checks for the readiness of the element composing the layer.
  106799. * @param subMesh the mesh to check for
  106800. * @param useInstances specify wether or not to use instances to render the mesh
  106801. * @param emissiveTexture the associated emissive texture used to generate the glow
  106802. * @return true if ready otherwise, false
  106803. */
  106804. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106805. /**
  106806. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106807. */
  106808. needStencil(): boolean;
  106809. /**
  106810. * Returns true if the mesh can be rendered, otherwise false.
  106811. * @param mesh The mesh to render
  106812. * @param material The material used on the mesh
  106813. * @returns true if it can be rendered otherwise false
  106814. */
  106815. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  106816. /**
  106817. * Implementation specific of rendering the generating effect on the main canvas.
  106818. * @param effect The effect used to render through
  106819. */
  106820. protected _internalRender(effect: Effect): void;
  106821. /**
  106822. * Sets the required values for both the emissive texture and and the main color.
  106823. */
  106824. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106825. /**
  106826. * Returns true if the mesh should render, otherwise false.
  106827. * @param mesh The mesh to render
  106828. * @returns true if it should render otherwise false
  106829. */
  106830. protected _shouldRenderMesh(mesh: Mesh): boolean;
  106831. /**
  106832. * Adds specific effects defines.
  106833. * @param defines The defines to add specifics to.
  106834. */
  106835. protected _addCustomEffectDefines(defines: string[]): void;
  106836. /**
  106837. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  106838. * @param mesh The mesh to exclude from the glow layer
  106839. */
  106840. addExcludedMesh(mesh: Mesh): void;
  106841. /**
  106842. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  106843. * @param mesh The mesh to remove
  106844. */
  106845. removeExcludedMesh(mesh: Mesh): void;
  106846. /**
  106847. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  106848. * @param mesh The mesh to include in the glow layer
  106849. */
  106850. addIncludedOnlyMesh(mesh: Mesh): void;
  106851. /**
  106852. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  106853. * @param mesh The mesh to remove
  106854. */
  106855. removeIncludedOnlyMesh(mesh: Mesh): void;
  106856. /**
  106857. * Determine if a given mesh will be used in the glow layer
  106858. * @param mesh The mesh to test
  106859. * @returns true if the mesh will be highlighted by the current glow layer
  106860. */
  106861. hasMesh(mesh: AbstractMesh): boolean;
  106862. /**
  106863. * Free any resources and references associated to a mesh.
  106864. * Internal use
  106865. * @param mesh The mesh to free.
  106866. * @hidden
  106867. */
  106868. _disposeMesh(mesh: Mesh): void;
  106869. /**
  106870. * Gets the class name of the effect layer
  106871. * @returns the string with the class name of the effect layer
  106872. */
  106873. getClassName(): string;
  106874. /**
  106875. * Serializes this glow layer
  106876. * @returns a serialized glow layer object
  106877. */
  106878. serialize(): any;
  106879. /**
  106880. * Creates a Glow Layer from parsed glow layer data
  106881. * @param parsedGlowLayer defines glow layer data
  106882. * @param scene defines the current scene
  106883. * @param rootUrl defines the root URL containing the glow layer information
  106884. * @returns a parsed Glow Layer
  106885. */
  106886. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  106887. }
  106888. }
  106889. declare module BABYLON {
  106890. /** @hidden */
  106891. export var glowBlurPostProcessPixelShader: {
  106892. name: string;
  106893. shader: string;
  106894. };
  106895. }
  106896. declare module BABYLON {
  106897. interface AbstractScene {
  106898. /**
  106899. * Return a the first highlight layer of the scene with a given name.
  106900. * @param name The name of the highlight layer to look for.
  106901. * @return The highlight layer if found otherwise null.
  106902. */
  106903. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  106904. }
  106905. /**
  106906. * Highlight layer options. This helps customizing the behaviour
  106907. * of the highlight layer.
  106908. */
  106909. export interface IHighlightLayerOptions {
  106910. /**
  106911. * Multiplication factor apply to the canvas size to compute the render target size
  106912. * used to generated the glowing objects (the smaller the faster).
  106913. */
  106914. mainTextureRatio: number;
  106915. /**
  106916. * Enforces a fixed size texture to ensure resize independant blur.
  106917. */
  106918. mainTextureFixedSize?: number;
  106919. /**
  106920. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  106921. * of the picture to blur (the smaller the faster).
  106922. */
  106923. blurTextureSizeRatio: number;
  106924. /**
  106925. * How big in texel of the blur texture is the vertical blur.
  106926. */
  106927. blurVerticalSize: number;
  106928. /**
  106929. * How big in texel of the blur texture is the horizontal blur.
  106930. */
  106931. blurHorizontalSize: number;
  106932. /**
  106933. * Alpha blending mode used to apply the blur. Default is combine.
  106934. */
  106935. alphaBlendingMode: number;
  106936. /**
  106937. * The camera attached to the layer.
  106938. */
  106939. camera: Nullable<Camera>;
  106940. /**
  106941. * Should we display highlight as a solid stroke?
  106942. */
  106943. isStroke?: boolean;
  106944. /**
  106945. * The rendering group to draw the layer in.
  106946. */
  106947. renderingGroupId: number;
  106948. }
  106949. /**
  106950. * The highlight layer Helps adding a glow effect around a mesh.
  106951. *
  106952. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  106953. * glowy meshes to your scene.
  106954. *
  106955. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  106956. */
  106957. export class HighlightLayer extends EffectLayer {
  106958. name: string;
  106959. /**
  106960. * Effect Name of the highlight layer.
  106961. */
  106962. static readonly EffectName: string;
  106963. /**
  106964. * The neutral color used during the preparation of the glow effect.
  106965. * This is black by default as the blend operation is a blend operation.
  106966. */
  106967. static NeutralColor: Color4;
  106968. /**
  106969. * Stencil value used for glowing meshes.
  106970. */
  106971. static GlowingMeshStencilReference: number;
  106972. /**
  106973. * Stencil value used for the other meshes in the scene.
  106974. */
  106975. static NormalMeshStencilReference: number;
  106976. /**
  106977. * Specifies whether or not the inner glow is ACTIVE in the layer.
  106978. */
  106979. innerGlow: boolean;
  106980. /**
  106981. * Specifies whether or not the outer glow is ACTIVE in the layer.
  106982. */
  106983. outerGlow: boolean;
  106984. /**
  106985. * Specifies the horizontal size of the blur.
  106986. */
  106987. /**
  106988. * Gets the horizontal size of the blur.
  106989. */
  106990. blurHorizontalSize: number;
  106991. /**
  106992. * Specifies the vertical size of the blur.
  106993. */
  106994. /**
  106995. * Gets the vertical size of the blur.
  106996. */
  106997. blurVerticalSize: number;
  106998. /**
  106999. * An event triggered when the highlight layer is being blurred.
  107000. */
  107001. onBeforeBlurObservable: Observable<HighlightLayer>;
  107002. /**
  107003. * An event triggered when the highlight layer has been blurred.
  107004. */
  107005. onAfterBlurObservable: Observable<HighlightLayer>;
  107006. private _instanceGlowingMeshStencilReference;
  107007. private _options;
  107008. private _downSamplePostprocess;
  107009. private _horizontalBlurPostprocess;
  107010. private _verticalBlurPostprocess;
  107011. private _blurTexture;
  107012. private _meshes;
  107013. private _excludedMeshes;
  107014. /**
  107015. * Instantiates a new highlight Layer and references it to the scene..
  107016. * @param name The name of the layer
  107017. * @param scene The scene to use the layer in
  107018. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  107019. */
  107020. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  107021. /**
  107022. * Get the effect name of the layer.
  107023. * @return The effect name
  107024. */
  107025. getEffectName(): string;
  107026. /**
  107027. * Create the merge effect. This is the shader use to blit the information back
  107028. * to the main canvas at the end of the scene rendering.
  107029. */
  107030. protected _createMergeEffect(): Effect;
  107031. /**
  107032. * Creates the render target textures and post processes used in the highlight layer.
  107033. */
  107034. protected _createTextureAndPostProcesses(): void;
  107035. /**
  107036. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  107037. */
  107038. needStencil(): boolean;
  107039. /**
  107040. * Checks for the readiness of the element composing the layer.
  107041. * @param subMesh the mesh to check for
  107042. * @param useInstances specify wether or not to use instances to render the mesh
  107043. * @param emissiveTexture the associated emissive texture used to generate the glow
  107044. * @return true if ready otherwise, false
  107045. */
  107046. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107047. /**
  107048. * Implementation specific of rendering the generating effect on the main canvas.
  107049. * @param effect The effect used to render through
  107050. */
  107051. protected _internalRender(effect: Effect): void;
  107052. /**
  107053. * Returns true if the layer contains information to display, otherwise false.
  107054. */
  107055. shouldRender(): boolean;
  107056. /**
  107057. * Returns true if the mesh should render, otherwise false.
  107058. * @param mesh The mesh to render
  107059. * @returns true if it should render otherwise false
  107060. */
  107061. protected _shouldRenderMesh(mesh: Mesh): boolean;
  107062. /**
  107063. * Sets the required values for both the emissive texture and and the main color.
  107064. */
  107065. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  107066. /**
  107067. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  107068. * @param mesh The mesh to exclude from the highlight layer
  107069. */
  107070. addExcludedMesh(mesh: Mesh): void;
  107071. /**
  107072. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  107073. * @param mesh The mesh to highlight
  107074. */
  107075. removeExcludedMesh(mesh: Mesh): void;
  107076. /**
  107077. * Determine if a given mesh will be highlighted by the current HighlightLayer
  107078. * @param mesh mesh to test
  107079. * @returns true if the mesh will be highlighted by the current HighlightLayer
  107080. */
  107081. hasMesh(mesh: AbstractMesh): boolean;
  107082. /**
  107083. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  107084. * @param mesh The mesh to highlight
  107085. * @param color The color of the highlight
  107086. * @param glowEmissiveOnly Extract the glow from the emissive texture
  107087. */
  107088. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  107089. /**
  107090. * Remove a mesh from the highlight layer in order to make it stop glowing.
  107091. * @param mesh The mesh to highlight
  107092. */
  107093. removeMesh(mesh: Mesh): void;
  107094. /**
  107095. * Force the stencil to the normal expected value for none glowing parts
  107096. */
  107097. private _defaultStencilReference;
  107098. /**
  107099. * Free any resources and references associated to a mesh.
  107100. * Internal use
  107101. * @param mesh The mesh to free.
  107102. * @hidden
  107103. */
  107104. _disposeMesh(mesh: Mesh): void;
  107105. /**
  107106. * Dispose the highlight layer and free resources.
  107107. */
  107108. dispose(): void;
  107109. /**
  107110. * Gets the class name of the effect layer
  107111. * @returns the string with the class name of the effect layer
  107112. */
  107113. getClassName(): string;
  107114. /**
  107115. * Serializes this Highlight layer
  107116. * @returns a serialized Highlight layer object
  107117. */
  107118. serialize(): any;
  107119. /**
  107120. * Creates a Highlight layer from parsed Highlight layer data
  107121. * @param parsedHightlightLayer defines the Highlight layer data
  107122. * @param scene defines the current scene
  107123. * @param rootUrl defines the root URL containing the Highlight layer information
  107124. * @returns a parsed Highlight layer
  107125. */
  107126. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  107127. }
  107128. }
  107129. declare module BABYLON {
  107130. /** @hidden */
  107131. export var lensFlarePixelShader: {
  107132. name: string;
  107133. shader: string;
  107134. };
  107135. }
  107136. declare module BABYLON {
  107137. /** @hidden */
  107138. export var lensFlareVertexShader: {
  107139. name: string;
  107140. shader: string;
  107141. };
  107142. }
  107143. declare module BABYLON {
  107144. /**
  107145. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  107146. * It is usually composed of several `lensFlare`.
  107147. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107148. */
  107149. export class LensFlareSystem {
  107150. /**
  107151. * Define the name of the lens flare system
  107152. */
  107153. name: string;
  107154. /**
  107155. * List of lens flares used in this system.
  107156. */
  107157. lensFlares: LensFlare[];
  107158. /**
  107159. * Define a limit from the border the lens flare can be visible.
  107160. */
  107161. borderLimit: number;
  107162. /**
  107163. * Define a viewport border we do not want to see the lens flare in.
  107164. */
  107165. viewportBorder: number;
  107166. /**
  107167. * Define a predicate which could limit the list of meshes able to occlude the effect.
  107168. */
  107169. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  107170. /**
  107171. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  107172. */
  107173. layerMask: number;
  107174. /**
  107175. * Define the id of the lens flare system in the scene.
  107176. * (equal to name by default)
  107177. */
  107178. id: string;
  107179. private _scene;
  107180. private _emitter;
  107181. private _vertexBuffers;
  107182. private _indexBuffer;
  107183. private _effect;
  107184. private _positionX;
  107185. private _positionY;
  107186. private _isEnabled;
  107187. /** @hidden */
  107188. static _SceneComponentInitialization: (scene: Scene) => void;
  107189. /**
  107190. * Instantiates a lens flare system.
  107191. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  107192. * It is usually composed of several `lensFlare`.
  107193. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107194. * @param name Define the name of the lens flare system in the scene
  107195. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  107196. * @param scene Define the scene the lens flare system belongs to
  107197. */
  107198. constructor(
  107199. /**
  107200. * Define the name of the lens flare system
  107201. */
  107202. name: string, emitter: any, scene: Scene);
  107203. /**
  107204. * Define if the lens flare system is enabled.
  107205. */
  107206. isEnabled: boolean;
  107207. /**
  107208. * Get the scene the effects belongs to.
  107209. * @returns the scene holding the lens flare system
  107210. */
  107211. getScene(): Scene;
  107212. /**
  107213. * Get the emitter of the lens flare system.
  107214. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  107215. * @returns the emitter of the lens flare system
  107216. */
  107217. getEmitter(): any;
  107218. /**
  107219. * Set the emitter of the lens flare system.
  107220. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  107221. * @param newEmitter Define the new emitter of the system
  107222. */
  107223. setEmitter(newEmitter: any): void;
  107224. /**
  107225. * Get the lens flare system emitter position.
  107226. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  107227. * @returns the position
  107228. */
  107229. getEmitterPosition(): Vector3;
  107230. /**
  107231. * @hidden
  107232. */
  107233. computeEffectivePosition(globalViewport: Viewport): boolean;
  107234. /** @hidden */
  107235. _isVisible(): boolean;
  107236. /**
  107237. * @hidden
  107238. */
  107239. render(): boolean;
  107240. /**
  107241. * Dispose and release the lens flare with its associated resources.
  107242. */
  107243. dispose(): void;
  107244. /**
  107245. * Parse a lens flare system from a JSON repressentation
  107246. * @param parsedLensFlareSystem Define the JSON to parse
  107247. * @param scene Define the scene the parsed system should be instantiated in
  107248. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  107249. * @returns the parsed system
  107250. */
  107251. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  107252. /**
  107253. * Serialize the current Lens Flare System into a JSON representation.
  107254. * @returns the serialized JSON
  107255. */
  107256. serialize(): any;
  107257. }
  107258. }
  107259. declare module BABYLON {
  107260. /**
  107261. * This represents one of the lens effect in a `lensFlareSystem`.
  107262. * It controls one of the indiviual texture used in the effect.
  107263. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107264. */
  107265. export class LensFlare {
  107266. /**
  107267. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  107268. */
  107269. size: number;
  107270. /**
  107271. * 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.
  107272. */
  107273. position: number;
  107274. /**
  107275. * Define the lens color.
  107276. */
  107277. color: Color3;
  107278. /**
  107279. * Define the lens texture.
  107280. */
  107281. texture: Nullable<Texture>;
  107282. /**
  107283. * Define the alpha mode to render this particular lens.
  107284. */
  107285. alphaMode: number;
  107286. private _system;
  107287. /**
  107288. * Creates a new Lens Flare.
  107289. * This represents one of the lens effect in a `lensFlareSystem`.
  107290. * It controls one of the indiviual texture used in the effect.
  107291. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107292. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  107293. * @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.
  107294. * @param color Define the lens color
  107295. * @param imgUrl Define the lens texture url
  107296. * @param system Define the `lensFlareSystem` this flare is part of
  107297. * @returns The newly created Lens Flare
  107298. */
  107299. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  107300. /**
  107301. * Instantiates a new Lens Flare.
  107302. * This represents one of the lens effect in a `lensFlareSystem`.
  107303. * It controls one of the indiviual texture used in the effect.
  107304. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107305. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  107306. * @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.
  107307. * @param color Define the lens color
  107308. * @param imgUrl Define the lens texture url
  107309. * @param system Define the `lensFlareSystem` this flare is part of
  107310. */
  107311. constructor(
  107312. /**
  107313. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  107314. */
  107315. size: number,
  107316. /**
  107317. * 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.
  107318. */
  107319. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  107320. /**
  107321. * Dispose and release the lens flare with its associated resources.
  107322. */
  107323. dispose(): void;
  107324. }
  107325. }
  107326. declare module BABYLON {
  107327. interface AbstractScene {
  107328. /**
  107329. * The list of lens flare system added to the scene
  107330. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107331. */
  107332. lensFlareSystems: Array<LensFlareSystem>;
  107333. /**
  107334. * Removes the given lens flare system from this scene.
  107335. * @param toRemove The lens flare system to remove
  107336. * @returns The index of the removed lens flare system
  107337. */
  107338. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  107339. /**
  107340. * Adds the given lens flare system to this scene
  107341. * @param newLensFlareSystem The lens flare system to add
  107342. */
  107343. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  107344. /**
  107345. * Gets a lens flare system using its name
  107346. * @param name defines the name to look for
  107347. * @returns the lens flare system or null if not found
  107348. */
  107349. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  107350. /**
  107351. * Gets a lens flare system using its id
  107352. * @param id defines the id to look for
  107353. * @returns the lens flare system or null if not found
  107354. */
  107355. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  107356. }
  107357. /**
  107358. * Defines the lens flare scene component responsible to manage any lens flares
  107359. * in a given scene.
  107360. */
  107361. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  107362. /**
  107363. * The component name helpfull to identify the component in the list of scene components.
  107364. */
  107365. readonly name: string;
  107366. /**
  107367. * The scene the component belongs to.
  107368. */
  107369. scene: Scene;
  107370. /**
  107371. * Creates a new instance of the component for the given scene
  107372. * @param scene Defines the scene to register the component in
  107373. */
  107374. constructor(scene: Scene);
  107375. /**
  107376. * Registers the component in a given scene
  107377. */
  107378. register(): void;
  107379. /**
  107380. * Rebuilds the elements related to this component in case of
  107381. * context lost for instance.
  107382. */
  107383. rebuild(): void;
  107384. /**
  107385. * Adds all the element from the container to the scene
  107386. * @param container the container holding the elements
  107387. */
  107388. addFromContainer(container: AbstractScene): void;
  107389. /**
  107390. * Removes all the elements in the container from the scene
  107391. * @param container contains the elements to remove
  107392. * @param dispose if the removed element should be disposed (default: false)
  107393. */
  107394. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107395. /**
  107396. * Serializes the component data to the specified json object
  107397. * @param serializationObject The object to serialize to
  107398. */
  107399. serialize(serializationObject: any): void;
  107400. /**
  107401. * Disposes the component and the associated ressources.
  107402. */
  107403. dispose(): void;
  107404. private _draw;
  107405. }
  107406. }
  107407. declare module BABYLON {
  107408. /**
  107409. * Defines the shadow generator component responsible to manage any shadow generators
  107410. * in a given scene.
  107411. */
  107412. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  107413. /**
  107414. * The component name helpfull to identify the component in the list of scene components.
  107415. */
  107416. readonly name: string;
  107417. /**
  107418. * The scene the component belongs to.
  107419. */
  107420. scene: Scene;
  107421. /**
  107422. * Creates a new instance of the component for the given scene
  107423. * @param scene Defines the scene to register the component in
  107424. */
  107425. constructor(scene: Scene);
  107426. /**
  107427. * Registers the component in a given scene
  107428. */
  107429. register(): void;
  107430. /**
  107431. * Rebuilds the elements related to this component in case of
  107432. * context lost for instance.
  107433. */
  107434. rebuild(): void;
  107435. /**
  107436. * Serializes the component data to the specified json object
  107437. * @param serializationObject The object to serialize to
  107438. */
  107439. serialize(serializationObject: any): void;
  107440. /**
  107441. * Adds all the element from the container to the scene
  107442. * @param container the container holding the elements
  107443. */
  107444. addFromContainer(container: AbstractScene): void;
  107445. /**
  107446. * Removes all the elements in the container from the scene
  107447. * @param container contains the elements to remove
  107448. * @param dispose if the removed element should be disposed (default: false)
  107449. */
  107450. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107451. /**
  107452. * Rebuilds the elements related to this component in case of
  107453. * context lost for instance.
  107454. */
  107455. dispose(): void;
  107456. private _gatherRenderTargets;
  107457. }
  107458. }
  107459. declare module BABYLON {
  107460. /**
  107461. * A point light is a light defined by an unique point in world space.
  107462. * The light is emitted in every direction from this point.
  107463. * A good example of a point light is a standard light bulb.
  107464. * Documentation: https://doc.babylonjs.com/babylon101/lights
  107465. */
  107466. export class PointLight extends ShadowLight {
  107467. private _shadowAngle;
  107468. /**
  107469. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107470. * This specifies what angle the shadow will use to be created.
  107471. *
  107472. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  107473. */
  107474. /**
  107475. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107476. * This specifies what angle the shadow will use to be created.
  107477. *
  107478. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  107479. */
  107480. shadowAngle: number;
  107481. /**
  107482. * Gets the direction if it has been set.
  107483. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107484. */
  107485. /**
  107486. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107487. */
  107488. direction: Vector3;
  107489. /**
  107490. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  107491. * A PointLight emits the light in every direction.
  107492. * It can cast shadows.
  107493. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  107494. * ```javascript
  107495. * var pointLight = new PointLight("pl", camera.position, scene);
  107496. * ```
  107497. * Documentation : https://doc.babylonjs.com/babylon101/lights
  107498. * @param name The light friendly name
  107499. * @param position The position of the point light in the scene
  107500. * @param scene The scene the lights belongs to
  107501. */
  107502. constructor(name: string, position: Vector3, scene: Scene);
  107503. /**
  107504. * Returns the string "PointLight"
  107505. * @returns the class name
  107506. */
  107507. getClassName(): string;
  107508. /**
  107509. * Returns the integer 0.
  107510. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  107511. */
  107512. getTypeID(): number;
  107513. /**
  107514. * Specifies wether or not the shadowmap should be a cube texture.
  107515. * @returns true if the shadowmap needs to be a cube texture.
  107516. */
  107517. needCube(): boolean;
  107518. /**
  107519. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  107520. * @param faceIndex The index of the face we are computed the direction to generate shadow
  107521. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  107522. */
  107523. getShadowDirection(faceIndex?: number): Vector3;
  107524. /**
  107525. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  107526. * - fov = PI / 2
  107527. * - aspect ratio : 1.0
  107528. * - z-near and far equal to the active camera minZ and maxZ.
  107529. * Returns the PointLight.
  107530. */
  107531. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107532. protected _buildUniformLayout(): void;
  107533. /**
  107534. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  107535. * @param effect The effect to update
  107536. * @param lightIndex The index of the light in the effect to update
  107537. * @returns The point light
  107538. */
  107539. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  107540. /**
  107541. * Prepares the list of defines specific to the light type.
  107542. * @param defines the list of defines
  107543. * @param lightIndex defines the index of the light for the effect
  107544. */
  107545. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  107546. }
  107547. }
  107548. declare module BABYLON {
  107549. /**
  107550. * Header information of HDR texture files.
  107551. */
  107552. export interface HDRInfo {
  107553. /**
  107554. * The height of the texture in pixels.
  107555. */
  107556. height: number;
  107557. /**
  107558. * The width of the texture in pixels.
  107559. */
  107560. width: number;
  107561. /**
  107562. * The index of the beginning of the data in the binary file.
  107563. */
  107564. dataPosition: number;
  107565. }
  107566. /**
  107567. * This groups tools to convert HDR texture to native colors array.
  107568. */
  107569. export class HDRTools {
  107570. private static Ldexp;
  107571. private static Rgbe2float;
  107572. private static readStringLine;
  107573. /**
  107574. * Reads header information from an RGBE texture stored in a native array.
  107575. * More information on this format are available here:
  107576. * https://en.wikipedia.org/wiki/RGBE_image_format
  107577. *
  107578. * @param uint8array The binary file stored in native array.
  107579. * @return The header information.
  107580. */
  107581. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  107582. /**
  107583. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  107584. * This RGBE texture needs to store the information as a panorama.
  107585. *
  107586. * More information on this format are available here:
  107587. * https://en.wikipedia.org/wiki/RGBE_image_format
  107588. *
  107589. * @param buffer The binary file stored in an array buffer.
  107590. * @param size The expected size of the extracted cubemap.
  107591. * @return The Cube Map information.
  107592. */
  107593. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  107594. /**
  107595. * Returns the pixels data extracted from an RGBE texture.
  107596. * This pixels will be stored left to right up to down in the R G B order in one array.
  107597. *
  107598. * More information on this format are available here:
  107599. * https://en.wikipedia.org/wiki/RGBE_image_format
  107600. *
  107601. * @param uint8array The binary file stored in an array buffer.
  107602. * @param hdrInfo The header information of the file.
  107603. * @return The pixels data in RGB right to left up to down order.
  107604. */
  107605. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  107606. private static RGBE_ReadPixels_RLE;
  107607. }
  107608. }
  107609. declare module BABYLON {
  107610. /**
  107611. * This represents a texture coming from an HDR input.
  107612. *
  107613. * The only supported format is currently panorama picture stored in RGBE format.
  107614. * Example of such files can be found on HDRLib: http://hdrlib.com/
  107615. */
  107616. export class HDRCubeTexture extends BaseTexture {
  107617. private static _facesMapping;
  107618. private _generateHarmonics;
  107619. private _noMipmap;
  107620. private _textureMatrix;
  107621. private _size;
  107622. private _onLoad;
  107623. private _onError;
  107624. /**
  107625. * The texture URL.
  107626. */
  107627. url: string;
  107628. /**
  107629. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  107630. */
  107631. coordinatesMode: number;
  107632. protected _isBlocking: boolean;
  107633. /**
  107634. * Sets wether or not the texture is blocking during loading.
  107635. */
  107636. /**
  107637. * Gets wether or not the texture is blocking during loading.
  107638. */
  107639. isBlocking: boolean;
  107640. protected _rotationY: number;
  107641. /**
  107642. * Sets texture matrix rotation angle around Y axis in radians.
  107643. */
  107644. /**
  107645. * Gets texture matrix rotation angle around Y axis radians.
  107646. */
  107647. rotationY: number;
  107648. /**
  107649. * Gets or sets the center of the bounding box associated with the cube texture
  107650. * It must define where the camera used to render the texture was set
  107651. */
  107652. boundingBoxPosition: Vector3;
  107653. private _boundingBoxSize;
  107654. /**
  107655. * Gets or sets the size of the bounding box associated with the cube texture
  107656. * When defined, the cubemap will switch to local mode
  107657. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  107658. * @example https://www.babylonjs-playground.com/#RNASML
  107659. */
  107660. boundingBoxSize: Vector3;
  107661. /**
  107662. * Instantiates an HDRTexture from the following parameters.
  107663. *
  107664. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  107665. * @param scene The scene the texture will be used in
  107666. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  107667. * @param noMipmap Forces to not generate the mipmap if true
  107668. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  107669. * @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)
  107670. * @param reserved Reserved flag for internal use.
  107671. */
  107672. 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>);
  107673. /**
  107674. * Get the current class name of the texture useful for serialization or dynamic coding.
  107675. * @returns "HDRCubeTexture"
  107676. */
  107677. getClassName(): string;
  107678. /**
  107679. * Occurs when the file is raw .hdr file.
  107680. */
  107681. private loadTexture;
  107682. clone(): HDRCubeTexture;
  107683. delayLoad(): void;
  107684. /**
  107685. * Get the texture reflection matrix used to rotate/transform the reflection.
  107686. * @returns the reflection matrix
  107687. */
  107688. getReflectionTextureMatrix(): Matrix;
  107689. /**
  107690. * Set the texture reflection matrix used to rotate/transform the reflection.
  107691. * @param value Define the reflection matrix to set
  107692. */
  107693. setReflectionTextureMatrix(value: Matrix): void;
  107694. /**
  107695. * Parses a JSON representation of an HDR Texture in order to create the texture
  107696. * @param parsedTexture Define the JSON representation
  107697. * @param scene Define the scene the texture should be created in
  107698. * @param rootUrl Define the root url in case we need to load relative dependencies
  107699. * @returns the newly created texture after parsing
  107700. */
  107701. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  107702. serialize(): any;
  107703. }
  107704. }
  107705. declare module BABYLON {
  107706. /**
  107707. * Class used to control physics engine
  107708. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  107709. */
  107710. export class PhysicsEngine implements IPhysicsEngine {
  107711. private _physicsPlugin;
  107712. /**
  107713. * Global value used to control the smallest number supported by the simulation
  107714. */
  107715. static Epsilon: number;
  107716. private _impostors;
  107717. private _joints;
  107718. /**
  107719. * Gets the gravity vector used by the simulation
  107720. */
  107721. gravity: Vector3;
  107722. /**
  107723. * Factory used to create the default physics plugin.
  107724. * @returns The default physics plugin
  107725. */
  107726. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  107727. /**
  107728. * Creates a new Physics Engine
  107729. * @param gravity defines the gravity vector used by the simulation
  107730. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  107731. */
  107732. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  107733. /**
  107734. * Sets the gravity vector used by the simulation
  107735. * @param gravity defines the gravity vector to use
  107736. */
  107737. setGravity(gravity: Vector3): void;
  107738. /**
  107739. * Set the time step of the physics engine.
  107740. * Default is 1/60.
  107741. * To slow it down, enter 1/600 for example.
  107742. * To speed it up, 1/30
  107743. * @param newTimeStep defines the new timestep to apply to this world.
  107744. */
  107745. setTimeStep(newTimeStep?: number): void;
  107746. /**
  107747. * Get the time step of the physics engine.
  107748. * @returns the current time step
  107749. */
  107750. getTimeStep(): number;
  107751. /**
  107752. * Release all resources
  107753. */
  107754. dispose(): void;
  107755. /**
  107756. * Gets the name of the current physics plugin
  107757. * @returns the name of the plugin
  107758. */
  107759. getPhysicsPluginName(): string;
  107760. /**
  107761. * Adding a new impostor for the impostor tracking.
  107762. * This will be done by the impostor itself.
  107763. * @param impostor the impostor to add
  107764. */
  107765. addImpostor(impostor: PhysicsImpostor): void;
  107766. /**
  107767. * Remove an impostor from the engine.
  107768. * This impostor and its mesh will not longer be updated by the physics engine.
  107769. * @param impostor the impostor to remove
  107770. */
  107771. removeImpostor(impostor: PhysicsImpostor): void;
  107772. /**
  107773. * Add a joint to the physics engine
  107774. * @param mainImpostor defines the main impostor to which the joint is added.
  107775. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  107776. * @param joint defines the joint that will connect both impostors.
  107777. */
  107778. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107779. /**
  107780. * Removes a joint from the simulation
  107781. * @param mainImpostor defines the impostor used with the joint
  107782. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  107783. * @param joint defines the joint to remove
  107784. */
  107785. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107786. /**
  107787. * Called by the scene. No need to call it.
  107788. * @param delta defines the timespam between frames
  107789. */
  107790. _step(delta: number): void;
  107791. /**
  107792. * Gets the current plugin used to run the simulation
  107793. * @returns current plugin
  107794. */
  107795. getPhysicsPlugin(): IPhysicsEnginePlugin;
  107796. /**
  107797. * Gets the list of physic impostors
  107798. * @returns an array of PhysicsImpostor
  107799. */
  107800. getImpostors(): Array<PhysicsImpostor>;
  107801. /**
  107802. * Gets the impostor for a physics enabled object
  107803. * @param object defines the object impersonated by the impostor
  107804. * @returns the PhysicsImpostor or null if not found
  107805. */
  107806. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107807. /**
  107808. * Gets the impostor for a physics body object
  107809. * @param body defines physics body used by the impostor
  107810. * @returns the PhysicsImpostor or null if not found
  107811. */
  107812. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  107813. /**
  107814. * Does a raycast in the physics world
  107815. * @param from when should the ray start?
  107816. * @param to when should the ray end?
  107817. * @returns PhysicsRaycastResult
  107818. */
  107819. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107820. }
  107821. }
  107822. declare module BABYLON {
  107823. /** @hidden */
  107824. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  107825. private _useDeltaForWorldStep;
  107826. world: any;
  107827. name: string;
  107828. private _physicsMaterials;
  107829. private _fixedTimeStep;
  107830. private _cannonRaycastResult;
  107831. private _raycastResult;
  107832. private _removeAfterStep;
  107833. BJSCANNON: any;
  107834. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  107835. setGravity(gravity: Vector3): void;
  107836. setTimeStep(timeStep: number): void;
  107837. getTimeStep(): number;
  107838. executeStep(delta: number): void;
  107839. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107840. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107841. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107842. private _processChildMeshes;
  107843. removePhysicsBody(impostor: PhysicsImpostor): void;
  107844. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107845. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107846. private _addMaterial;
  107847. private _checkWithEpsilon;
  107848. private _createShape;
  107849. private _createHeightmap;
  107850. private _minus90X;
  107851. private _plus90X;
  107852. private _tmpPosition;
  107853. private _tmpDeltaPosition;
  107854. private _tmpUnityRotation;
  107855. private _updatePhysicsBodyTransformation;
  107856. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107857. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107858. isSupported(): boolean;
  107859. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107860. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107861. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107862. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107863. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107864. getBodyMass(impostor: PhysicsImpostor): number;
  107865. getBodyFriction(impostor: PhysicsImpostor): number;
  107866. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107867. getBodyRestitution(impostor: PhysicsImpostor): number;
  107868. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107869. sleepBody(impostor: PhysicsImpostor): void;
  107870. wakeUpBody(impostor: PhysicsImpostor): void;
  107871. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  107872. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107873. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107874. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107875. getRadius(impostor: PhysicsImpostor): number;
  107876. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107877. dispose(): void;
  107878. private _extendNamespace;
  107879. /**
  107880. * Does a raycast in the physics world
  107881. * @param from when should the ray start?
  107882. * @param to when should the ray end?
  107883. * @returns PhysicsRaycastResult
  107884. */
  107885. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107886. }
  107887. }
  107888. declare module BABYLON {
  107889. /** @hidden */
  107890. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  107891. world: any;
  107892. name: string;
  107893. BJSOIMO: any;
  107894. private _raycastResult;
  107895. constructor(iterations?: number, oimoInjection?: any);
  107896. setGravity(gravity: Vector3): void;
  107897. setTimeStep(timeStep: number): void;
  107898. getTimeStep(): number;
  107899. private _tmpImpostorsArray;
  107900. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107901. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107902. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107903. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107904. private _tmpPositionVector;
  107905. removePhysicsBody(impostor: PhysicsImpostor): void;
  107906. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107907. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107908. isSupported(): boolean;
  107909. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107910. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107911. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107912. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107913. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107914. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107915. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107916. getBodyMass(impostor: PhysicsImpostor): number;
  107917. getBodyFriction(impostor: PhysicsImpostor): number;
  107918. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107919. getBodyRestitution(impostor: PhysicsImpostor): number;
  107920. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107921. sleepBody(impostor: PhysicsImpostor): void;
  107922. wakeUpBody(impostor: PhysicsImpostor): void;
  107923. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107924. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  107925. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107926. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107927. getRadius(impostor: PhysicsImpostor): number;
  107928. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107929. dispose(): void;
  107930. /**
  107931. * Does a raycast in the physics world
  107932. * @param from when should the ray start?
  107933. * @param to when should the ray end?
  107934. * @returns PhysicsRaycastResult
  107935. */
  107936. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107937. }
  107938. }
  107939. declare module BABYLON {
  107940. /**
  107941. * Class containing static functions to help procedurally build meshes
  107942. */
  107943. export class RibbonBuilder {
  107944. /**
  107945. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107946. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  107947. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  107948. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  107949. * * 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
  107950. * * 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
  107951. * * 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
  107952. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107953. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107954. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107955. * * 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
  107956. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  107957. * * 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
  107958. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  107959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107960. * @param name defines the name of the mesh
  107961. * @param options defines the options used to create the mesh
  107962. * @param scene defines the hosting scene
  107963. * @returns the ribbon mesh
  107964. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  107965. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107966. */
  107967. static CreateRibbon(name: string, options: {
  107968. pathArray: Vector3[][];
  107969. closeArray?: boolean;
  107970. closePath?: boolean;
  107971. offset?: number;
  107972. updatable?: boolean;
  107973. sideOrientation?: number;
  107974. frontUVs?: Vector4;
  107975. backUVs?: Vector4;
  107976. instance?: Mesh;
  107977. invertUV?: boolean;
  107978. uvs?: Vector2[];
  107979. colors?: Color4[];
  107980. }, scene?: Nullable<Scene>): Mesh;
  107981. }
  107982. }
  107983. declare module BABYLON {
  107984. /**
  107985. * Class containing static functions to help procedurally build meshes
  107986. */
  107987. export class ShapeBuilder {
  107988. /**
  107989. * 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.
  107990. * * 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.
  107991. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107992. * * 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.
  107993. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  107994. * * 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
  107995. * * 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
  107996. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  107997. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107998. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107999. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  108000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108001. * @param name defines the name of the mesh
  108002. * @param options defines the options used to create the mesh
  108003. * @param scene defines the hosting scene
  108004. * @returns the extruded shape mesh
  108005. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108006. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108007. */
  108008. static ExtrudeShape(name: string, options: {
  108009. shape: Vector3[];
  108010. path: Vector3[];
  108011. scale?: number;
  108012. rotation?: number;
  108013. cap?: number;
  108014. updatable?: boolean;
  108015. sideOrientation?: number;
  108016. frontUVs?: Vector4;
  108017. backUVs?: Vector4;
  108018. instance?: Mesh;
  108019. invertUV?: boolean;
  108020. }, scene?: Nullable<Scene>): Mesh;
  108021. /**
  108022. * Creates an custom extruded shape mesh.
  108023. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  108024. * * 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.
  108025. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  108026. * * 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
  108027. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  108028. * * 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
  108029. * * It must returns a float value that will be the scale value applied to the shape on each path point
  108030. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  108031. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  108032. * * 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
  108033. * * 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
  108034. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  108035. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108036. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108037. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108039. * @param name defines the name of the mesh
  108040. * @param options defines the options used to create the mesh
  108041. * @param scene defines the hosting scene
  108042. * @returns the custom extruded shape mesh
  108043. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  108044. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108045. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108046. */
  108047. static ExtrudeShapeCustom(name: string, options: {
  108048. shape: Vector3[];
  108049. path: Vector3[];
  108050. scaleFunction?: any;
  108051. rotationFunction?: any;
  108052. ribbonCloseArray?: boolean;
  108053. ribbonClosePath?: boolean;
  108054. cap?: number;
  108055. updatable?: boolean;
  108056. sideOrientation?: number;
  108057. frontUVs?: Vector4;
  108058. backUVs?: Vector4;
  108059. instance?: Mesh;
  108060. invertUV?: boolean;
  108061. }, scene?: Nullable<Scene>): Mesh;
  108062. private static _ExtrudeShapeGeneric;
  108063. }
  108064. }
  108065. declare module BABYLON {
  108066. /**
  108067. * AmmoJS Physics plugin
  108068. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108069. * @see https://github.com/kripken/ammo.js/
  108070. */
  108071. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  108072. private _useDeltaForWorldStep;
  108073. /**
  108074. * Reference to the Ammo library
  108075. */
  108076. bjsAMMO: any;
  108077. /**
  108078. * Created ammoJS world which physics bodies are added to
  108079. */
  108080. world: any;
  108081. /**
  108082. * Name of the plugin
  108083. */
  108084. name: string;
  108085. private _timeStep;
  108086. private _fixedTimeStep;
  108087. private _maxSteps;
  108088. private _tmpQuaternion;
  108089. private _tmpAmmoTransform;
  108090. private _tmpAmmoQuaternion;
  108091. private _tmpAmmoConcreteContactResultCallback;
  108092. private _collisionConfiguration;
  108093. private _dispatcher;
  108094. private _overlappingPairCache;
  108095. private _solver;
  108096. private _softBodySolver;
  108097. private _tmpAmmoVectorA;
  108098. private _tmpAmmoVectorB;
  108099. private _tmpAmmoVectorC;
  108100. private _tmpAmmoVectorD;
  108101. private _tmpContactCallbackResult;
  108102. private _tmpAmmoVectorRCA;
  108103. private _tmpAmmoVectorRCB;
  108104. private _raycastResult;
  108105. private static readonly DISABLE_COLLISION_FLAG;
  108106. private static readonly KINEMATIC_FLAG;
  108107. private static readonly DISABLE_DEACTIVATION_FLAG;
  108108. /**
  108109. * Initializes the ammoJS plugin
  108110. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  108111. * @param ammoInjection can be used to inject your own ammo reference
  108112. */
  108113. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  108114. /**
  108115. * Sets the gravity of the physics world (m/(s^2))
  108116. * @param gravity Gravity to set
  108117. */
  108118. setGravity(gravity: Vector3): void;
  108119. /**
  108120. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  108121. * @param timeStep timestep to use in seconds
  108122. */
  108123. setTimeStep(timeStep: number): void;
  108124. /**
  108125. * 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)
  108126. * @param fixedTimeStep fixedTimeStep to use in seconds
  108127. */
  108128. setFixedTimeStep(fixedTimeStep: number): void;
  108129. /**
  108130. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  108131. * @param maxSteps the maximum number of steps by the physics engine per frame
  108132. */
  108133. setMaxSteps(maxSteps: number): void;
  108134. /**
  108135. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  108136. * @returns the current timestep in seconds
  108137. */
  108138. getTimeStep(): number;
  108139. private _isImpostorInContact;
  108140. private _isImpostorPairInContact;
  108141. private _stepSimulation;
  108142. /**
  108143. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  108144. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  108145. * After the step the babylon meshes are set to the position of the physics imposters
  108146. * @param delta amount of time to step forward
  108147. * @param impostors array of imposters to update before/after the step
  108148. */
  108149. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  108150. /**
  108151. * Update babylon mesh to match physics world object
  108152. * @param impostor imposter to match
  108153. */
  108154. private _afterSoftStep;
  108155. /**
  108156. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  108157. * @param impostor imposter to match
  108158. */
  108159. private _ropeStep;
  108160. /**
  108161. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  108162. * @param impostor imposter to match
  108163. */
  108164. private _softbodyOrClothStep;
  108165. private _tmpVector;
  108166. private _tmpMatrix;
  108167. /**
  108168. * Applies an impulse on the imposter
  108169. * @param impostor imposter to apply impulse to
  108170. * @param force amount of force to be applied to the imposter
  108171. * @param contactPoint the location to apply the impulse on the imposter
  108172. */
  108173. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108174. /**
  108175. * Applies a force on the imposter
  108176. * @param impostor imposter to apply force
  108177. * @param force amount of force to be applied to the imposter
  108178. * @param contactPoint the location to apply the force on the imposter
  108179. */
  108180. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108181. /**
  108182. * Creates a physics body using the plugin
  108183. * @param impostor the imposter to create the physics body on
  108184. */
  108185. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108186. /**
  108187. * Removes the physics body from the imposter and disposes of the body's memory
  108188. * @param impostor imposter to remove the physics body from
  108189. */
  108190. removePhysicsBody(impostor: PhysicsImpostor): void;
  108191. /**
  108192. * Generates a joint
  108193. * @param impostorJoint the imposter joint to create the joint with
  108194. */
  108195. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108196. /**
  108197. * Removes a joint
  108198. * @param impostorJoint the imposter joint to remove the joint from
  108199. */
  108200. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108201. private _addMeshVerts;
  108202. /**
  108203. * Initialise the soft body vertices to match its object's (mesh) vertices
  108204. * Softbody vertices (nodes) are in world space and to match this
  108205. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  108206. * @param impostor to create the softbody for
  108207. */
  108208. private _softVertexData;
  108209. /**
  108210. * Create an impostor's soft body
  108211. * @param impostor to create the softbody for
  108212. */
  108213. private _createSoftbody;
  108214. /**
  108215. * Create cloth for an impostor
  108216. * @param impostor to create the softbody for
  108217. */
  108218. private _createCloth;
  108219. /**
  108220. * Create rope for an impostor
  108221. * @param impostor to create the softbody for
  108222. */
  108223. private _createRope;
  108224. private _addHullVerts;
  108225. private _createShape;
  108226. /**
  108227. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  108228. * @param impostor imposter containing the physics body and babylon object
  108229. */
  108230. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108231. /**
  108232. * Sets the babylon object's position/rotation from the physics body's position/rotation
  108233. * @param impostor imposter containing the physics body and babylon object
  108234. * @param newPosition new position
  108235. * @param newRotation new rotation
  108236. */
  108237. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108238. /**
  108239. * If this plugin is supported
  108240. * @returns true if its supported
  108241. */
  108242. isSupported(): boolean;
  108243. /**
  108244. * Sets the linear velocity of the physics body
  108245. * @param impostor imposter to set the velocity on
  108246. * @param velocity velocity to set
  108247. */
  108248. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108249. /**
  108250. * Sets the angular velocity of the physics body
  108251. * @param impostor imposter to set the velocity on
  108252. * @param velocity velocity to set
  108253. */
  108254. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108255. /**
  108256. * gets the linear velocity
  108257. * @param impostor imposter to get linear velocity from
  108258. * @returns linear velocity
  108259. */
  108260. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108261. /**
  108262. * gets the angular velocity
  108263. * @param impostor imposter to get angular velocity from
  108264. * @returns angular velocity
  108265. */
  108266. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108267. /**
  108268. * Sets the mass of physics body
  108269. * @param impostor imposter to set the mass on
  108270. * @param mass mass to set
  108271. */
  108272. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108273. /**
  108274. * Gets the mass of the physics body
  108275. * @param impostor imposter to get the mass from
  108276. * @returns mass
  108277. */
  108278. getBodyMass(impostor: PhysicsImpostor): number;
  108279. /**
  108280. * Gets friction of the impostor
  108281. * @param impostor impostor to get friction from
  108282. * @returns friction value
  108283. */
  108284. getBodyFriction(impostor: PhysicsImpostor): number;
  108285. /**
  108286. * Sets friction of the impostor
  108287. * @param impostor impostor to set friction on
  108288. * @param friction friction value
  108289. */
  108290. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108291. /**
  108292. * Gets restitution of the impostor
  108293. * @param impostor impostor to get restitution from
  108294. * @returns restitution value
  108295. */
  108296. getBodyRestitution(impostor: PhysicsImpostor): number;
  108297. /**
  108298. * Sets resitution of the impostor
  108299. * @param impostor impostor to set resitution on
  108300. * @param restitution resitution value
  108301. */
  108302. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108303. /**
  108304. * Gets pressure inside the impostor
  108305. * @param impostor impostor to get pressure from
  108306. * @returns pressure value
  108307. */
  108308. getBodyPressure(impostor: PhysicsImpostor): number;
  108309. /**
  108310. * Sets pressure inside a soft body impostor
  108311. * Cloth and rope must remain 0 pressure
  108312. * @param impostor impostor to set pressure on
  108313. * @param pressure pressure value
  108314. */
  108315. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  108316. /**
  108317. * Gets stiffness of the impostor
  108318. * @param impostor impostor to get stiffness from
  108319. * @returns pressure value
  108320. */
  108321. getBodyStiffness(impostor: PhysicsImpostor): number;
  108322. /**
  108323. * Sets stiffness of the impostor
  108324. * @param impostor impostor to set stiffness on
  108325. * @param stiffness stiffness value from 0 to 1
  108326. */
  108327. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  108328. /**
  108329. * Gets velocityIterations of the impostor
  108330. * @param impostor impostor to get velocity iterations from
  108331. * @returns velocityIterations value
  108332. */
  108333. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  108334. /**
  108335. * Sets velocityIterations of the impostor
  108336. * @param impostor impostor to set velocity iterations on
  108337. * @param velocityIterations velocityIterations value
  108338. */
  108339. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  108340. /**
  108341. * Gets positionIterations of the impostor
  108342. * @param impostor impostor to get position iterations from
  108343. * @returns positionIterations value
  108344. */
  108345. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  108346. /**
  108347. * Sets positionIterations of the impostor
  108348. * @param impostor impostor to set position on
  108349. * @param positionIterations positionIterations value
  108350. */
  108351. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  108352. /**
  108353. * Append an anchor to a cloth object
  108354. * @param impostor is the cloth impostor to add anchor to
  108355. * @param otherImpostor is the rigid impostor to anchor to
  108356. * @param width ratio across width from 0 to 1
  108357. * @param height ratio up height from 0 to 1
  108358. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  108359. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108360. */
  108361. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108362. /**
  108363. * Append an hook to a rope object
  108364. * @param impostor is the rope impostor to add hook to
  108365. * @param otherImpostor is the rigid impostor to hook to
  108366. * @param length ratio along the rope from 0 to 1
  108367. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  108368. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108369. */
  108370. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108371. /**
  108372. * Sleeps the physics body and stops it from being active
  108373. * @param impostor impostor to sleep
  108374. */
  108375. sleepBody(impostor: PhysicsImpostor): void;
  108376. /**
  108377. * Activates the physics body
  108378. * @param impostor impostor to activate
  108379. */
  108380. wakeUpBody(impostor: PhysicsImpostor): void;
  108381. /**
  108382. * Updates the distance parameters of the joint
  108383. * @param joint joint to update
  108384. * @param maxDistance maximum distance of the joint
  108385. * @param minDistance minimum distance of the joint
  108386. */
  108387. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108388. /**
  108389. * Sets a motor on the joint
  108390. * @param joint joint to set motor on
  108391. * @param speed speed of the motor
  108392. * @param maxForce maximum force of the motor
  108393. * @param motorIndex index of the motor
  108394. */
  108395. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108396. /**
  108397. * Sets the motors limit
  108398. * @param joint joint to set limit on
  108399. * @param upperLimit upper limit
  108400. * @param lowerLimit lower limit
  108401. */
  108402. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108403. /**
  108404. * Syncs the position and rotation of a mesh with the impostor
  108405. * @param mesh mesh to sync
  108406. * @param impostor impostor to update the mesh with
  108407. */
  108408. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108409. /**
  108410. * Gets the radius of the impostor
  108411. * @param impostor impostor to get radius from
  108412. * @returns the radius
  108413. */
  108414. getRadius(impostor: PhysicsImpostor): number;
  108415. /**
  108416. * Gets the box size of the impostor
  108417. * @param impostor impostor to get box size from
  108418. * @param result the resulting box size
  108419. */
  108420. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108421. /**
  108422. * Disposes of the impostor
  108423. */
  108424. dispose(): void;
  108425. /**
  108426. * Does a raycast in the physics world
  108427. * @param from when should the ray start?
  108428. * @param to when should the ray end?
  108429. * @returns PhysicsRaycastResult
  108430. */
  108431. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108432. }
  108433. }
  108434. declare module BABYLON {
  108435. interface AbstractScene {
  108436. /**
  108437. * The list of reflection probes added to the scene
  108438. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  108439. */
  108440. reflectionProbes: Array<ReflectionProbe>;
  108441. /**
  108442. * Removes the given reflection probe from this scene.
  108443. * @param toRemove The reflection probe to remove
  108444. * @returns The index of the removed reflection probe
  108445. */
  108446. removeReflectionProbe(toRemove: ReflectionProbe): number;
  108447. /**
  108448. * Adds the given reflection probe to this scene.
  108449. * @param newReflectionProbe The reflection probe to add
  108450. */
  108451. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  108452. }
  108453. /**
  108454. * Class used to generate realtime reflection / refraction cube textures
  108455. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  108456. */
  108457. export class ReflectionProbe {
  108458. /** defines the name of the probe */
  108459. name: string;
  108460. private _scene;
  108461. private _renderTargetTexture;
  108462. private _projectionMatrix;
  108463. private _viewMatrix;
  108464. private _target;
  108465. private _add;
  108466. private _attachedMesh;
  108467. private _invertYAxis;
  108468. /** Gets or sets probe position (center of the cube map) */
  108469. position: Vector3;
  108470. /**
  108471. * Creates a new reflection probe
  108472. * @param name defines the name of the probe
  108473. * @param size defines the texture resolution (for each face)
  108474. * @param scene defines the hosting scene
  108475. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  108476. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  108477. */
  108478. constructor(
  108479. /** defines the name of the probe */
  108480. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  108481. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  108482. samples: number;
  108483. /** Gets or sets the refresh rate to use (on every frame by default) */
  108484. refreshRate: number;
  108485. /**
  108486. * Gets the hosting scene
  108487. * @returns a Scene
  108488. */
  108489. getScene(): Scene;
  108490. /** Gets the internal CubeTexture used to render to */
  108491. readonly cubeTexture: RenderTargetTexture;
  108492. /** Gets the list of meshes to render */
  108493. readonly renderList: Nullable<AbstractMesh[]>;
  108494. /**
  108495. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  108496. * @param mesh defines the mesh to attach to
  108497. */
  108498. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  108499. /**
  108500. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  108501. * @param renderingGroupId The rendering group id corresponding to its index
  108502. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  108503. */
  108504. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  108505. /**
  108506. * Clean all associated resources
  108507. */
  108508. dispose(): void;
  108509. /**
  108510. * Converts the reflection probe information to a readable string for debug purpose.
  108511. * @param fullDetails Supports for multiple levels of logging within scene loading
  108512. * @returns the human readable reflection probe info
  108513. */
  108514. toString(fullDetails?: boolean): string;
  108515. /**
  108516. * Get the class name of the relfection probe.
  108517. * @returns "ReflectionProbe"
  108518. */
  108519. getClassName(): string;
  108520. /**
  108521. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  108522. * @returns The JSON representation of the texture
  108523. */
  108524. serialize(): any;
  108525. /**
  108526. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  108527. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  108528. * @param scene Define the scene the parsed reflection probe should be instantiated in
  108529. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  108530. * @returns The parsed reflection probe if successful
  108531. */
  108532. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  108533. }
  108534. }
  108535. declare module BABYLON {
  108536. /** @hidden */
  108537. export var _BabylonLoaderRegistered: boolean;
  108538. }
  108539. declare module BABYLON {
  108540. /**
  108541. * The Physically based simple base material of BJS.
  108542. *
  108543. * This enables better naming and convention enforcements on top of the pbrMaterial.
  108544. * It is used as the base class for both the specGloss and metalRough conventions.
  108545. */
  108546. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  108547. /**
  108548. * Number of Simultaneous lights allowed on the material.
  108549. */
  108550. maxSimultaneousLights: number;
  108551. /**
  108552. * If sets to true, disables all the lights affecting the material.
  108553. */
  108554. disableLighting: boolean;
  108555. /**
  108556. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  108557. */
  108558. environmentTexture: BaseTexture;
  108559. /**
  108560. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108561. */
  108562. invertNormalMapX: boolean;
  108563. /**
  108564. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108565. */
  108566. invertNormalMapY: boolean;
  108567. /**
  108568. * Normal map used in the model.
  108569. */
  108570. normalTexture: BaseTexture;
  108571. /**
  108572. * Emissivie color used to self-illuminate the model.
  108573. */
  108574. emissiveColor: Color3;
  108575. /**
  108576. * Emissivie texture used to self-illuminate the model.
  108577. */
  108578. emissiveTexture: BaseTexture;
  108579. /**
  108580. * Occlusion Channel Strenght.
  108581. */
  108582. occlusionStrength: number;
  108583. /**
  108584. * Occlusion Texture of the material (adding extra occlusion effects).
  108585. */
  108586. occlusionTexture: BaseTexture;
  108587. /**
  108588. * Defines the alpha limits in alpha test mode.
  108589. */
  108590. alphaCutOff: number;
  108591. /**
  108592. * Gets the current double sided mode.
  108593. */
  108594. /**
  108595. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108596. */
  108597. doubleSided: boolean;
  108598. /**
  108599. * Stores the pre-calculated light information of a mesh in a texture.
  108600. */
  108601. lightmapTexture: BaseTexture;
  108602. /**
  108603. * If true, the light map contains occlusion information instead of lighting info.
  108604. */
  108605. useLightmapAsShadowmap: boolean;
  108606. /**
  108607. * Instantiates a new PBRMaterial instance.
  108608. *
  108609. * @param name The material name
  108610. * @param scene The scene the material will be use in.
  108611. */
  108612. constructor(name: string, scene: Scene);
  108613. getClassName(): string;
  108614. }
  108615. }
  108616. declare module BABYLON {
  108617. /**
  108618. * The PBR material of BJS following the metal roughness convention.
  108619. *
  108620. * This fits to the PBR convention in the GLTF definition:
  108621. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  108622. */
  108623. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  108624. /**
  108625. * The base color has two different interpretations depending on the value of metalness.
  108626. * When the material is a metal, the base color is the specific measured reflectance value
  108627. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  108628. * of the material.
  108629. */
  108630. baseColor: Color3;
  108631. /**
  108632. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  108633. * well as opacity information in the alpha channel.
  108634. */
  108635. baseTexture: BaseTexture;
  108636. /**
  108637. * Specifies the metallic scalar value of the material.
  108638. * Can also be used to scale the metalness values of the metallic texture.
  108639. */
  108640. metallic: number;
  108641. /**
  108642. * Specifies the roughness scalar value of the material.
  108643. * Can also be used to scale the roughness values of the metallic texture.
  108644. */
  108645. roughness: number;
  108646. /**
  108647. * Texture containing both the metallic value in the B channel and the
  108648. * roughness value in the G channel to keep better precision.
  108649. */
  108650. metallicRoughnessTexture: BaseTexture;
  108651. /**
  108652. * Instantiates a new PBRMetalRoughnessMaterial instance.
  108653. *
  108654. * @param name The material name
  108655. * @param scene The scene the material will be use in.
  108656. */
  108657. constructor(name: string, scene: Scene);
  108658. /**
  108659. * Return the currrent class name of the material.
  108660. */
  108661. getClassName(): string;
  108662. /**
  108663. * Makes a duplicate of the current material.
  108664. * @param name - name to use for the new material.
  108665. */
  108666. clone(name: string): PBRMetallicRoughnessMaterial;
  108667. /**
  108668. * Serialize the material to a parsable JSON object.
  108669. */
  108670. serialize(): any;
  108671. /**
  108672. * Parses a JSON object correponding to the serialize function.
  108673. */
  108674. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  108675. }
  108676. }
  108677. declare module BABYLON {
  108678. /**
  108679. * The PBR material of BJS following the specular glossiness convention.
  108680. *
  108681. * This fits to the PBR convention in the GLTF definition:
  108682. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  108683. */
  108684. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  108685. /**
  108686. * Specifies the diffuse color of the material.
  108687. */
  108688. diffuseColor: Color3;
  108689. /**
  108690. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  108691. * channel.
  108692. */
  108693. diffuseTexture: BaseTexture;
  108694. /**
  108695. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  108696. */
  108697. specularColor: Color3;
  108698. /**
  108699. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  108700. */
  108701. glossiness: number;
  108702. /**
  108703. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  108704. */
  108705. specularGlossinessTexture: BaseTexture;
  108706. /**
  108707. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  108708. *
  108709. * @param name The material name
  108710. * @param scene The scene the material will be use in.
  108711. */
  108712. constructor(name: string, scene: Scene);
  108713. /**
  108714. * Return the currrent class name of the material.
  108715. */
  108716. getClassName(): string;
  108717. /**
  108718. * Makes a duplicate of the current material.
  108719. * @param name - name to use for the new material.
  108720. */
  108721. clone(name: string): PBRSpecularGlossinessMaterial;
  108722. /**
  108723. * Serialize the material to a parsable JSON object.
  108724. */
  108725. serialize(): any;
  108726. /**
  108727. * Parses a JSON object correponding to the serialize function.
  108728. */
  108729. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  108730. }
  108731. }
  108732. declare module BABYLON {
  108733. /**
  108734. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  108735. * It can help converting any input color in a desired output one. This can then be used to create effects
  108736. * from sepia, black and white to sixties or futuristic rendering...
  108737. *
  108738. * The only supported format is currently 3dl.
  108739. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  108740. */
  108741. export class ColorGradingTexture extends BaseTexture {
  108742. /**
  108743. * The current texture matrix. (will always be identity in color grading texture)
  108744. */
  108745. private _textureMatrix;
  108746. /**
  108747. * The texture URL.
  108748. */
  108749. url: string;
  108750. /**
  108751. * Empty line regex stored for GC.
  108752. */
  108753. private static _noneEmptyLineRegex;
  108754. private _engine;
  108755. /**
  108756. * Instantiates a ColorGradingTexture from the following parameters.
  108757. *
  108758. * @param url The location of the color gradind data (currently only supporting 3dl)
  108759. * @param scene The scene the texture will be used in
  108760. */
  108761. constructor(url: string, scene: Scene);
  108762. /**
  108763. * Returns the texture matrix used in most of the material.
  108764. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  108765. */
  108766. getTextureMatrix(): Matrix;
  108767. /**
  108768. * Occurs when the file being loaded is a .3dl LUT file.
  108769. */
  108770. private load3dlTexture;
  108771. /**
  108772. * Starts the loading process of the texture.
  108773. */
  108774. private loadTexture;
  108775. /**
  108776. * Clones the color gradind texture.
  108777. */
  108778. clone(): ColorGradingTexture;
  108779. /**
  108780. * Called during delayed load for textures.
  108781. */
  108782. delayLoad(): void;
  108783. /**
  108784. * Parses a color grading texture serialized by Babylon.
  108785. * @param parsedTexture The texture information being parsedTexture
  108786. * @param scene The scene to load the texture in
  108787. * @param rootUrl The root url of the data assets to load
  108788. * @return A color gradind texture
  108789. */
  108790. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  108791. /**
  108792. * Serializes the LUT texture to json format.
  108793. */
  108794. serialize(): any;
  108795. }
  108796. }
  108797. declare module BABYLON {
  108798. /**
  108799. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  108800. */
  108801. export class EquiRectangularCubeTexture extends BaseTexture {
  108802. /** The six faces of the cube. */
  108803. private static _FacesMapping;
  108804. private _noMipmap;
  108805. private _onLoad;
  108806. private _onError;
  108807. /** The size of the cubemap. */
  108808. private _size;
  108809. /** The buffer of the image. */
  108810. private _buffer;
  108811. /** The width of the input image. */
  108812. private _width;
  108813. /** The height of the input image. */
  108814. private _height;
  108815. /** The URL to the image. */
  108816. url: string;
  108817. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  108818. coordinatesMode: number;
  108819. /**
  108820. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  108821. * @param url The location of the image
  108822. * @param scene The scene the texture will be used in
  108823. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  108824. * @param noMipmap Forces to not generate the mipmap if true
  108825. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  108826. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  108827. * @param onLoad — defines a callback called when texture is loaded
  108828. * @param onError — defines a callback called if there is an error
  108829. */
  108830. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  108831. /**
  108832. * Load the image data, by putting the image on a canvas and extracting its buffer.
  108833. */
  108834. private loadImage;
  108835. /**
  108836. * Convert the image buffer into a cubemap and create a CubeTexture.
  108837. */
  108838. private loadTexture;
  108839. /**
  108840. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  108841. * @param buffer The ArrayBuffer that should be converted.
  108842. * @returns The buffer as Float32Array.
  108843. */
  108844. private getFloat32ArrayFromArrayBuffer;
  108845. /**
  108846. * Get the current class name of the texture useful for serialization or dynamic coding.
  108847. * @returns "EquiRectangularCubeTexture"
  108848. */
  108849. getClassName(): string;
  108850. /**
  108851. * Create a clone of the current EquiRectangularCubeTexture and return it.
  108852. * @returns A clone of the current EquiRectangularCubeTexture.
  108853. */
  108854. clone(): EquiRectangularCubeTexture;
  108855. }
  108856. }
  108857. declare module BABYLON {
  108858. /**
  108859. * Based on jsTGALoader - Javascript loader for TGA file
  108860. * By Vincent Thibault
  108861. * @see http://blog.robrowser.com/javascript-tga-loader.html
  108862. */
  108863. export class TGATools {
  108864. private static _TYPE_INDEXED;
  108865. private static _TYPE_RGB;
  108866. private static _TYPE_GREY;
  108867. private static _TYPE_RLE_INDEXED;
  108868. private static _TYPE_RLE_RGB;
  108869. private static _TYPE_RLE_GREY;
  108870. private static _ORIGIN_MASK;
  108871. private static _ORIGIN_SHIFT;
  108872. private static _ORIGIN_BL;
  108873. private static _ORIGIN_BR;
  108874. private static _ORIGIN_UL;
  108875. private static _ORIGIN_UR;
  108876. /**
  108877. * Gets the header of a TGA file
  108878. * @param data defines the TGA data
  108879. * @returns the header
  108880. */
  108881. static GetTGAHeader(data: Uint8Array): any;
  108882. /**
  108883. * Uploads TGA content to a Babylon Texture
  108884. * @hidden
  108885. */
  108886. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  108887. /** @hidden */
  108888. 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;
  108889. /** @hidden */
  108890. 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;
  108891. /** @hidden */
  108892. 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;
  108893. /** @hidden */
  108894. 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;
  108895. /** @hidden */
  108896. 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;
  108897. /** @hidden */
  108898. 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;
  108899. }
  108900. }
  108901. declare module BABYLON {
  108902. /**
  108903. * Implementation of the TGA Texture Loader.
  108904. * @hidden
  108905. */
  108906. export class _TGATextureLoader implements IInternalTextureLoader {
  108907. /**
  108908. * Defines wether the loader supports cascade loading the different faces.
  108909. */
  108910. readonly supportCascades: boolean;
  108911. /**
  108912. * This returns if the loader support the current file information.
  108913. * @param extension defines the file extension of the file being loaded
  108914. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108915. * @param fallback defines the fallback internal texture if any
  108916. * @param isBase64 defines whether the texture is encoded as a base64
  108917. * @param isBuffer defines whether the texture data are stored as a buffer
  108918. * @returns true if the loader can load the specified file
  108919. */
  108920. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  108921. /**
  108922. * Transform the url before loading if required.
  108923. * @param rootUrl the url of the texture
  108924. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108925. * @returns the transformed texture
  108926. */
  108927. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  108928. /**
  108929. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  108930. * @param rootUrl the url of the texture
  108931. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108932. * @returns the fallback texture
  108933. */
  108934. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  108935. /**
  108936. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  108937. * @param data contains the texture data
  108938. * @param texture defines the BabylonJS internal texture
  108939. * @param createPolynomials will be true if polynomials have been requested
  108940. * @param onLoad defines the callback to trigger once the texture is ready
  108941. * @param onError defines the callback to trigger in case of error
  108942. */
  108943. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  108944. /**
  108945. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  108946. * @param data contains the texture data
  108947. * @param texture defines the BabylonJS internal texture
  108948. * @param callback defines the method to call once ready to upload
  108949. */
  108950. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  108951. }
  108952. }
  108953. declare module BABYLON {
  108954. /**
  108955. * 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.
  108956. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  108957. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  108958. */
  108959. export class CustomProceduralTexture extends ProceduralTexture {
  108960. private _animate;
  108961. private _time;
  108962. private _config;
  108963. private _texturePath;
  108964. /**
  108965. * Instantiates a new Custom Procedural Texture.
  108966. * 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.
  108967. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  108968. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  108969. * @param name Define the name of the texture
  108970. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  108971. * @param size Define the size of the texture to create
  108972. * @param scene Define the scene the texture belongs to
  108973. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  108974. * @param generateMipMaps Define if the texture should creates mip maps or not
  108975. */
  108976. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  108977. private _loadJson;
  108978. /**
  108979. * Is the texture ready to be used ? (rendered at least once)
  108980. * @returns true if ready, otherwise, false.
  108981. */
  108982. isReady(): boolean;
  108983. /**
  108984. * Render the texture to its associated render target.
  108985. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  108986. */
  108987. render(useCameraPostProcess?: boolean): void;
  108988. /**
  108989. * Update the list of dependant textures samplers in the shader.
  108990. */
  108991. updateTextures(): void;
  108992. /**
  108993. * Update the uniform values of the procedural texture in the shader.
  108994. */
  108995. updateShaderUniforms(): void;
  108996. /**
  108997. * Define if the texture animates or not.
  108998. */
  108999. animate: boolean;
  109000. }
  109001. }
  109002. declare module BABYLON {
  109003. /** @hidden */
  109004. export var noisePixelShader: {
  109005. name: string;
  109006. shader: string;
  109007. };
  109008. }
  109009. declare module BABYLON {
  109010. /**
  109011. * Class used to generate noise procedural textures
  109012. */
  109013. export class NoiseProceduralTexture extends ProceduralTexture {
  109014. private _time;
  109015. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  109016. brightness: number;
  109017. /** Defines the number of octaves to process */
  109018. octaves: number;
  109019. /** Defines the level of persistence (0.8 by default) */
  109020. persistence: number;
  109021. /** Gets or sets animation speed factor (default is 1) */
  109022. animationSpeedFactor: number;
  109023. /**
  109024. * Creates a new NoiseProceduralTexture
  109025. * @param name defines the name fo the texture
  109026. * @param size defines the size of the texture (default is 256)
  109027. * @param scene defines the hosting scene
  109028. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  109029. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  109030. */
  109031. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  109032. private _updateShaderUniforms;
  109033. protected _getDefines(): string;
  109034. /** Generate the current state of the procedural texture */
  109035. render(useCameraPostProcess?: boolean): void;
  109036. /**
  109037. * Serializes this noise procedural texture
  109038. * @returns a serialized noise procedural texture object
  109039. */
  109040. serialize(): any;
  109041. /**
  109042. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  109043. * @param parsedTexture defines parsed texture data
  109044. * @param scene defines the current scene
  109045. * @param rootUrl defines the root URL containing noise procedural texture information
  109046. * @returns a parsed NoiseProceduralTexture
  109047. */
  109048. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  109049. }
  109050. }
  109051. declare module BABYLON {
  109052. /**
  109053. * Raw cube texture where the raw buffers are passed in
  109054. */
  109055. export class RawCubeTexture extends CubeTexture {
  109056. /**
  109057. * Creates a cube texture where the raw buffers are passed in.
  109058. * @param scene defines the scene the texture is attached to
  109059. * @param data defines the array of data to use to create each face
  109060. * @param size defines the size of the textures
  109061. * @param format defines the format of the data
  109062. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  109063. * @param generateMipMaps defines if the engine should generate the mip levels
  109064. * @param invertY defines if data must be stored with Y axis inverted
  109065. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  109066. * @param compression defines the compression used (null by default)
  109067. */
  109068. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  109069. /**
  109070. * Updates the raw cube texture.
  109071. * @param data defines the data to store
  109072. * @param format defines the data format
  109073. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  109074. * @param invertY defines if data must be stored with Y axis inverted
  109075. * @param compression defines the compression used (null by default)
  109076. * @param level defines which level of the texture to update
  109077. */
  109078. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  109079. /**
  109080. * Updates a raw cube texture with RGBD encoded data.
  109081. * @param data defines the array of data [mipmap][face] to use to create each face
  109082. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  109083. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  109084. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  109085. * @returns a promsie that resolves when the operation is complete
  109086. */
  109087. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  109088. /**
  109089. * Clones the raw cube texture.
  109090. * @return a new cube texture
  109091. */
  109092. clone(): CubeTexture;
  109093. /** @hidden */
  109094. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109095. }
  109096. }
  109097. declare module BABYLON {
  109098. /**
  109099. * Class used to store 3D textures containing user data
  109100. */
  109101. export class RawTexture3D extends Texture {
  109102. /** Gets or sets the texture format to use */
  109103. format: number;
  109104. private _engine;
  109105. /**
  109106. * Create a new RawTexture3D
  109107. * @param data defines the data of the texture
  109108. * @param width defines the width of the texture
  109109. * @param height defines the height of the texture
  109110. * @param depth defines the depth of the texture
  109111. * @param format defines the texture format to use
  109112. * @param scene defines the hosting scene
  109113. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  109114. * @param invertY defines if texture must be stored with Y axis inverted
  109115. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  109116. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  109117. */
  109118. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  109119. /** Gets or sets the texture format to use */
  109120. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  109121. /**
  109122. * Update the texture with new data
  109123. * @param data defines the data to store in the texture
  109124. */
  109125. update(data: ArrayBufferView): void;
  109126. }
  109127. }
  109128. declare module BABYLON {
  109129. /**
  109130. * Creates a refraction texture used by refraction channel of the standard material.
  109131. * It is like a mirror but to see through a material.
  109132. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109133. */
  109134. export class RefractionTexture extends RenderTargetTexture {
  109135. /**
  109136. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  109137. * 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.
  109138. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109139. */
  109140. refractionPlane: Plane;
  109141. /**
  109142. * Define how deep under the surface we should see.
  109143. */
  109144. depth: number;
  109145. /**
  109146. * Creates a refraction texture used by refraction channel of the standard material.
  109147. * It is like a mirror but to see through a material.
  109148. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109149. * @param name Define the texture name
  109150. * @param size Define the size of the underlying texture
  109151. * @param scene Define the scene the refraction belongs to
  109152. * @param generateMipMaps Define if we need to generate mips level for the refraction
  109153. */
  109154. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  109155. /**
  109156. * Clone the refraction texture.
  109157. * @returns the cloned texture
  109158. */
  109159. clone(): RefractionTexture;
  109160. /**
  109161. * Serialize the texture to a JSON representation you could use in Parse later on
  109162. * @returns the serialized JSON representation
  109163. */
  109164. serialize(): any;
  109165. }
  109166. }
  109167. declare module BABYLON {
  109168. /**
  109169. * Defines the options related to the creation of an HtmlElementTexture
  109170. */
  109171. export interface IHtmlElementTextureOptions {
  109172. /**
  109173. * Defines wether mip maps should be created or not.
  109174. */
  109175. generateMipMaps?: boolean;
  109176. /**
  109177. * Defines the sampling mode of the texture.
  109178. */
  109179. samplingMode?: number;
  109180. /**
  109181. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  109182. */
  109183. engine: Nullable<Engine>;
  109184. /**
  109185. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  109186. */
  109187. scene: Nullable<Scene>;
  109188. }
  109189. /**
  109190. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  109191. * To be as efficient as possible depending on your constraints nothing aside the first upload
  109192. * is automatically managed.
  109193. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  109194. * in your application.
  109195. *
  109196. * As the update is not automatic, you need to call them manually.
  109197. */
  109198. export class HtmlElementTexture extends BaseTexture {
  109199. /**
  109200. * The texture URL.
  109201. */
  109202. element: HTMLVideoElement | HTMLCanvasElement;
  109203. private static readonly DefaultOptions;
  109204. private _textureMatrix;
  109205. private _engine;
  109206. private _isVideo;
  109207. private _generateMipMaps;
  109208. private _samplingMode;
  109209. /**
  109210. * Instantiates a HtmlElementTexture from the following parameters.
  109211. *
  109212. * @param name Defines the name of the texture
  109213. * @param element Defines the video or canvas the texture is filled with
  109214. * @param options Defines the other none mandatory texture creation options
  109215. */
  109216. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  109217. private _createInternalTexture;
  109218. /**
  109219. * Returns the texture matrix used in most of the material.
  109220. */
  109221. getTextureMatrix(): Matrix;
  109222. /**
  109223. * Updates the content of the texture.
  109224. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  109225. */
  109226. update(invertY?: Nullable<boolean>): void;
  109227. }
  109228. }
  109229. declare module BABYLON {
  109230. /**
  109231. * Helper class to push actions to a pool of workers.
  109232. */
  109233. export class WorkerPool implements IDisposable {
  109234. private _workerInfos;
  109235. private _pendingActions;
  109236. /**
  109237. * Constructor
  109238. * @param workers Array of workers to use for actions
  109239. */
  109240. constructor(workers: Array<Worker>);
  109241. /**
  109242. * Terminates all workers and clears any pending actions.
  109243. */
  109244. dispose(): void;
  109245. /**
  109246. * Pushes an action to the worker pool. If all the workers are active, the action will be
  109247. * pended until a worker has completed its action.
  109248. * @param action The action to perform. Call onComplete when the action is complete.
  109249. */
  109250. push(action: (worker: Worker, onComplete: () => void) => void): void;
  109251. private _execute;
  109252. }
  109253. }
  109254. declare module BABYLON {
  109255. /**
  109256. * Configuration for Draco compression
  109257. */
  109258. export interface IDracoCompressionConfiguration {
  109259. /**
  109260. * Configuration for the decoder.
  109261. */
  109262. decoder?: {
  109263. /**
  109264. * The url to the WebAssembly module.
  109265. */
  109266. wasmUrl?: string;
  109267. /**
  109268. * The url to the WebAssembly binary.
  109269. */
  109270. wasmBinaryUrl?: string;
  109271. /**
  109272. * The url to the fallback JavaScript module.
  109273. */
  109274. fallbackUrl?: string;
  109275. };
  109276. }
  109277. /**
  109278. * Draco compression (https://google.github.io/draco/)
  109279. *
  109280. * This class wraps the Draco module.
  109281. *
  109282. * **Encoder**
  109283. *
  109284. * The encoder is not currently implemented.
  109285. *
  109286. * **Decoder**
  109287. *
  109288. * 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.
  109289. *
  109290. * To update the configuration, use the following code:
  109291. * ```javascript
  109292. * DracoCompression.Configuration = {
  109293. * decoder: {
  109294. * wasmUrl: "<url to the WebAssembly library>",
  109295. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  109296. * fallbackUrl: "<url to the fallback JavaScript library>",
  109297. * }
  109298. * };
  109299. * ```
  109300. *
  109301. * 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.
  109302. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  109303. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  109304. *
  109305. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  109306. * ```javascript
  109307. * var dracoCompression = new DracoCompression();
  109308. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  109309. * [VertexBuffer.PositionKind]: 0
  109310. * });
  109311. * ```
  109312. *
  109313. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  109314. */
  109315. export class DracoCompression implements IDisposable {
  109316. private _workerPoolPromise;
  109317. /**
  109318. * The configuration. Defaults to the following urls:
  109319. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  109320. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  109321. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  109322. */
  109323. static Configuration: IDracoCompressionConfiguration;
  109324. /**
  109325. * Returns true if the decoder is available.
  109326. */
  109327. static readonly DecoderAvailable: boolean;
  109328. /**
  109329. * Default number of workers to create when creating the draco compression object.
  109330. */
  109331. static DefaultNumWorkers: number;
  109332. private static GetDefaultNumWorkers;
  109333. /**
  109334. * Constructor
  109335. * @param numWorkers The number of workers for async operations
  109336. */
  109337. constructor(numWorkers?: number);
  109338. /**
  109339. * Stop all async operations and release resources.
  109340. */
  109341. dispose(): void;
  109342. /**
  109343. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  109344. * @returns a promise that resolves when ready
  109345. */
  109346. whenReadyAsync(): Promise<void>;
  109347. /**
  109348. * Decode Draco compressed mesh data to vertex data.
  109349. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  109350. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  109351. * @returns A promise that resolves with the decoded vertex data
  109352. */
  109353. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  109354. [kind: string]: number;
  109355. }): Promise<VertexData>;
  109356. /**
  109357. * The worker function that gets converted to a blob url to pass into a worker.
  109358. */
  109359. private static _Worker;
  109360. private _loadDecoderWasmBinaryAsync;
  109361. }
  109362. }
  109363. declare module BABYLON {
  109364. /**
  109365. * Class for building Constructive Solid Geometry
  109366. */
  109367. export class CSG {
  109368. private polygons;
  109369. /**
  109370. * The world matrix
  109371. */
  109372. matrix: Matrix;
  109373. /**
  109374. * Stores the position
  109375. */
  109376. position: Vector3;
  109377. /**
  109378. * Stores the rotation
  109379. */
  109380. rotation: Vector3;
  109381. /**
  109382. * Stores the rotation quaternion
  109383. */
  109384. rotationQuaternion: Nullable<Quaternion>;
  109385. /**
  109386. * Stores the scaling vector
  109387. */
  109388. scaling: Vector3;
  109389. /**
  109390. * Convert the Mesh to CSG
  109391. * @param mesh The Mesh to convert to CSG
  109392. * @returns A new CSG from the Mesh
  109393. */
  109394. static FromMesh(mesh: Mesh): CSG;
  109395. /**
  109396. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  109397. * @param polygons Polygons used to construct a CSG solid
  109398. */
  109399. private static FromPolygons;
  109400. /**
  109401. * Clones, or makes a deep copy, of the CSG
  109402. * @returns A new CSG
  109403. */
  109404. clone(): CSG;
  109405. /**
  109406. * Unions this CSG with another CSG
  109407. * @param csg The CSG to union against this CSG
  109408. * @returns The unioned CSG
  109409. */
  109410. union(csg: CSG): CSG;
  109411. /**
  109412. * Unions this CSG with another CSG in place
  109413. * @param csg The CSG to union against this CSG
  109414. */
  109415. unionInPlace(csg: CSG): void;
  109416. /**
  109417. * Subtracts this CSG with another CSG
  109418. * @param csg The CSG to subtract against this CSG
  109419. * @returns A new CSG
  109420. */
  109421. subtract(csg: CSG): CSG;
  109422. /**
  109423. * Subtracts this CSG with another CSG in place
  109424. * @param csg The CSG to subtact against this CSG
  109425. */
  109426. subtractInPlace(csg: CSG): void;
  109427. /**
  109428. * Intersect this CSG with another CSG
  109429. * @param csg The CSG to intersect against this CSG
  109430. * @returns A new CSG
  109431. */
  109432. intersect(csg: CSG): CSG;
  109433. /**
  109434. * Intersects this CSG with another CSG in place
  109435. * @param csg The CSG to intersect against this CSG
  109436. */
  109437. intersectInPlace(csg: CSG): void;
  109438. /**
  109439. * Return a new CSG solid with solid and empty space switched. This solid is
  109440. * not modified.
  109441. * @returns A new CSG solid with solid and empty space switched
  109442. */
  109443. inverse(): CSG;
  109444. /**
  109445. * Inverses the CSG in place
  109446. */
  109447. inverseInPlace(): void;
  109448. /**
  109449. * This is used to keep meshes transformations so they can be restored
  109450. * when we build back a Babylon Mesh
  109451. * NB : All CSG operations are performed in world coordinates
  109452. * @param csg The CSG to copy the transform attributes from
  109453. * @returns This CSG
  109454. */
  109455. copyTransformAttributes(csg: CSG): CSG;
  109456. /**
  109457. * Build Raw mesh from CSG
  109458. * Coordinates here are in world space
  109459. * @param name The name of the mesh geometry
  109460. * @param scene The Scene
  109461. * @param keepSubMeshes Specifies if the submeshes should be kept
  109462. * @returns A new Mesh
  109463. */
  109464. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  109465. /**
  109466. * Build Mesh from CSG taking material and transforms into account
  109467. * @param name The name of the Mesh
  109468. * @param material The material of the Mesh
  109469. * @param scene The Scene
  109470. * @param keepSubMeshes Specifies if submeshes should be kept
  109471. * @returns The new Mesh
  109472. */
  109473. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  109474. }
  109475. }
  109476. declare module BABYLON {
  109477. /**
  109478. * Class used to create a trail following a mesh
  109479. */
  109480. export class TrailMesh extends Mesh {
  109481. private _generator;
  109482. private _autoStart;
  109483. private _running;
  109484. private _diameter;
  109485. private _length;
  109486. private _sectionPolygonPointsCount;
  109487. private _sectionVectors;
  109488. private _sectionNormalVectors;
  109489. private _beforeRenderObserver;
  109490. /**
  109491. * @constructor
  109492. * @param name The value used by scene.getMeshByName() to do a lookup.
  109493. * @param generator The mesh to generate a trail.
  109494. * @param scene The scene to add this mesh to.
  109495. * @param diameter Diameter of trailing mesh. Default is 1.
  109496. * @param length Length of trailing mesh. Default is 60.
  109497. * @param autoStart Automatically start trailing mesh. Default true.
  109498. */
  109499. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  109500. /**
  109501. * "TrailMesh"
  109502. * @returns "TrailMesh"
  109503. */
  109504. getClassName(): string;
  109505. private _createMesh;
  109506. /**
  109507. * Start trailing mesh.
  109508. */
  109509. start(): void;
  109510. /**
  109511. * Stop trailing mesh.
  109512. */
  109513. stop(): void;
  109514. /**
  109515. * Update trailing mesh geometry.
  109516. */
  109517. update(): void;
  109518. /**
  109519. * Returns a new TrailMesh object.
  109520. * @param name is a string, the name given to the new mesh
  109521. * @param newGenerator use new generator object for cloned trail mesh
  109522. * @returns a new mesh
  109523. */
  109524. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  109525. /**
  109526. * Serializes this trail mesh
  109527. * @param serializationObject object to write serialization to
  109528. */
  109529. serialize(serializationObject: any): void;
  109530. /**
  109531. * Parses a serialized trail mesh
  109532. * @param parsedMesh the serialized mesh
  109533. * @param scene the scene to create the trail mesh in
  109534. * @returns the created trail mesh
  109535. */
  109536. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  109537. }
  109538. }
  109539. declare module BABYLON {
  109540. /**
  109541. * Class containing static functions to help procedurally build meshes
  109542. */
  109543. export class TorusKnotBuilder {
  109544. /**
  109545. * Creates a torus knot mesh
  109546. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  109547. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  109548. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  109549. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  109550. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109551. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109553. * @param name defines the name of the mesh
  109554. * @param options defines the options used to create the mesh
  109555. * @param scene defines the hosting scene
  109556. * @returns the torus knot mesh
  109557. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  109558. */
  109559. static CreateTorusKnot(name: string, options: {
  109560. radius?: number;
  109561. tube?: number;
  109562. radialSegments?: number;
  109563. tubularSegments?: number;
  109564. p?: number;
  109565. q?: number;
  109566. updatable?: boolean;
  109567. sideOrientation?: number;
  109568. frontUVs?: Vector4;
  109569. backUVs?: Vector4;
  109570. }, scene: any): Mesh;
  109571. }
  109572. }
  109573. declare module BABYLON {
  109574. /**
  109575. * Polygon
  109576. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  109577. */
  109578. export class Polygon {
  109579. /**
  109580. * Creates a rectangle
  109581. * @param xmin bottom X coord
  109582. * @param ymin bottom Y coord
  109583. * @param xmax top X coord
  109584. * @param ymax top Y coord
  109585. * @returns points that make the resulting rectation
  109586. */
  109587. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  109588. /**
  109589. * Creates a circle
  109590. * @param radius radius of circle
  109591. * @param cx scale in x
  109592. * @param cy scale in y
  109593. * @param numberOfSides number of sides that make up the circle
  109594. * @returns points that make the resulting circle
  109595. */
  109596. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  109597. /**
  109598. * Creates a polygon from input string
  109599. * @param input Input polygon data
  109600. * @returns the parsed points
  109601. */
  109602. static Parse(input: string): Vector2[];
  109603. /**
  109604. * Starts building a polygon from x and y coordinates
  109605. * @param x x coordinate
  109606. * @param y y coordinate
  109607. * @returns the started path2
  109608. */
  109609. static StartingAt(x: number, y: number): Path2;
  109610. }
  109611. /**
  109612. * Builds a polygon
  109613. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  109614. */
  109615. export class PolygonMeshBuilder {
  109616. private _points;
  109617. private _outlinepoints;
  109618. private _holes;
  109619. private _name;
  109620. private _scene;
  109621. private _epoints;
  109622. private _eholes;
  109623. private _addToepoint;
  109624. /**
  109625. * Babylon reference to the earcut plugin.
  109626. */
  109627. bjsEarcut: any;
  109628. /**
  109629. * Creates a PolygonMeshBuilder
  109630. * @param name name of the builder
  109631. * @param contours Path of the polygon
  109632. * @param scene scene to add to when creating the mesh
  109633. * @param earcutInjection can be used to inject your own earcut reference
  109634. */
  109635. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  109636. /**
  109637. * Adds a whole within the polygon
  109638. * @param hole Array of points defining the hole
  109639. * @returns this
  109640. */
  109641. addHole(hole: Vector2[]): PolygonMeshBuilder;
  109642. /**
  109643. * Creates the polygon
  109644. * @param updatable If the mesh should be updatable
  109645. * @param depth The depth of the mesh created
  109646. * @returns the created mesh
  109647. */
  109648. build(updatable?: boolean, depth?: number): Mesh;
  109649. /**
  109650. * Creates the polygon
  109651. * @param depth The depth of the mesh created
  109652. * @returns the created VertexData
  109653. */
  109654. buildVertexData(depth?: number): VertexData;
  109655. /**
  109656. * Adds a side to the polygon
  109657. * @param positions points that make the polygon
  109658. * @param normals normals of the polygon
  109659. * @param uvs uvs of the polygon
  109660. * @param indices indices of the polygon
  109661. * @param bounds bounds of the polygon
  109662. * @param points points of the polygon
  109663. * @param depth depth of the polygon
  109664. * @param flip flip of the polygon
  109665. */
  109666. private addSide;
  109667. }
  109668. }
  109669. declare module BABYLON {
  109670. /**
  109671. * Class containing static functions to help procedurally build meshes
  109672. */
  109673. export class PolygonBuilder {
  109674. /**
  109675. * Creates a polygon mesh
  109676. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  109677. * * 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
  109678. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109680. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  109681. * * Remember you can only change the shape positions, not their number when updating a polygon
  109682. * @param name defines the name of the mesh
  109683. * @param options defines the options used to create the mesh
  109684. * @param scene defines the hosting scene
  109685. * @param earcutInjection can be used to inject your own earcut reference
  109686. * @returns the polygon mesh
  109687. */
  109688. static CreatePolygon(name: string, options: {
  109689. shape: Vector3[];
  109690. holes?: Vector3[][];
  109691. depth?: number;
  109692. faceUV?: Vector4[];
  109693. faceColors?: Color4[];
  109694. updatable?: boolean;
  109695. sideOrientation?: number;
  109696. frontUVs?: Vector4;
  109697. backUVs?: Vector4;
  109698. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109699. /**
  109700. * Creates an extruded polygon mesh, with depth in the Y direction.
  109701. * * 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)
  109702. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109703. * @param name defines the name of the mesh
  109704. * @param options defines the options used to create the mesh
  109705. * @param scene defines the hosting scene
  109706. * @param earcutInjection can be used to inject your own earcut reference
  109707. * @returns the polygon mesh
  109708. */
  109709. static ExtrudePolygon(name: string, options: {
  109710. shape: Vector3[];
  109711. holes?: Vector3[][];
  109712. depth?: number;
  109713. faceUV?: Vector4[];
  109714. faceColors?: Color4[];
  109715. updatable?: boolean;
  109716. sideOrientation?: number;
  109717. frontUVs?: Vector4;
  109718. backUVs?: Vector4;
  109719. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109720. }
  109721. }
  109722. declare module BABYLON {
  109723. /**
  109724. * Class containing static functions to help procedurally build meshes
  109725. */
  109726. export class LatheBuilder {
  109727. /**
  109728. * Creates lathe mesh.
  109729. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  109730. * * 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
  109731. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  109732. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  109733. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  109734. * * 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
  109735. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  109736. * * 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
  109737. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109738. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109739. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109741. * @param name defines the name of the mesh
  109742. * @param options defines the options used to create the mesh
  109743. * @param scene defines the hosting scene
  109744. * @returns the lathe mesh
  109745. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  109746. */
  109747. static CreateLathe(name: string, options: {
  109748. shape: Vector3[];
  109749. radius?: number;
  109750. tessellation?: number;
  109751. clip?: number;
  109752. arc?: number;
  109753. closed?: boolean;
  109754. updatable?: boolean;
  109755. sideOrientation?: number;
  109756. frontUVs?: Vector4;
  109757. backUVs?: Vector4;
  109758. cap?: number;
  109759. invertUV?: boolean;
  109760. }, scene?: Nullable<Scene>): Mesh;
  109761. }
  109762. }
  109763. declare module BABYLON {
  109764. /**
  109765. * Class containing static functions to help procedurally build meshes
  109766. */
  109767. export class TubeBuilder {
  109768. /**
  109769. * Creates a tube mesh.
  109770. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109771. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  109772. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  109773. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  109774. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  109775. * * 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)
  109776. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  109777. * * 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
  109778. * * 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
  109779. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109780. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109781. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109783. * @param name defines the name of the mesh
  109784. * @param options defines the options used to create the mesh
  109785. * @param scene defines the hosting scene
  109786. * @returns the tube mesh
  109787. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109788. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  109789. */
  109790. static CreateTube(name: string, options: {
  109791. path: Vector3[];
  109792. radius?: number;
  109793. tessellation?: number;
  109794. radiusFunction?: {
  109795. (i: number, distance: number): number;
  109796. };
  109797. cap?: number;
  109798. arc?: number;
  109799. updatable?: boolean;
  109800. sideOrientation?: number;
  109801. frontUVs?: Vector4;
  109802. backUVs?: Vector4;
  109803. instance?: Mesh;
  109804. invertUV?: boolean;
  109805. }, scene?: Nullable<Scene>): Mesh;
  109806. }
  109807. }
  109808. declare module BABYLON {
  109809. /**
  109810. * Class containing static functions to help procedurally build meshes
  109811. */
  109812. export class IcoSphereBuilder {
  109813. /**
  109814. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109815. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109816. * * 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`)
  109817. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109818. * * 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
  109819. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109820. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109822. * @param name defines the name of the mesh
  109823. * @param options defines the options used to create the mesh
  109824. * @param scene defines the hosting scene
  109825. * @returns the icosahedron mesh
  109826. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109827. */
  109828. static CreateIcoSphere(name: string, options: {
  109829. radius?: number;
  109830. radiusX?: number;
  109831. radiusY?: number;
  109832. radiusZ?: number;
  109833. flat?: boolean;
  109834. subdivisions?: number;
  109835. sideOrientation?: number;
  109836. frontUVs?: Vector4;
  109837. backUVs?: Vector4;
  109838. updatable?: boolean;
  109839. }, scene?: Nullable<Scene>): Mesh;
  109840. }
  109841. }
  109842. declare module BABYLON {
  109843. /**
  109844. * Class containing static functions to help procedurally build meshes
  109845. */
  109846. export class DecalBuilder {
  109847. /**
  109848. * Creates a decal mesh.
  109849. * 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
  109850. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  109851. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  109852. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  109853. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  109854. * @param name defines the name of the mesh
  109855. * @param sourceMesh defines the mesh where the decal must be applied
  109856. * @param options defines the options used to create the mesh
  109857. * @param scene defines the hosting scene
  109858. * @returns the decal mesh
  109859. * @see https://doc.babylonjs.com/how_to/decals
  109860. */
  109861. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  109862. position?: Vector3;
  109863. normal?: Vector3;
  109864. size?: Vector3;
  109865. angle?: number;
  109866. }): Mesh;
  109867. }
  109868. }
  109869. declare module BABYLON {
  109870. /**
  109871. * Class containing static functions to help procedurally build meshes
  109872. */
  109873. export class MeshBuilder {
  109874. /**
  109875. * Creates a box mesh
  109876. * * The parameter `size` sets the size (float) of each box side (default 1)
  109877. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  109878. * * 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)
  109879. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109880. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109881. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109883. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  109884. * @param name defines the name of the mesh
  109885. * @param options defines the options used to create the mesh
  109886. * @param scene defines the hosting scene
  109887. * @returns the box mesh
  109888. */
  109889. static CreateBox(name: string, options: {
  109890. size?: number;
  109891. width?: number;
  109892. height?: number;
  109893. depth?: number;
  109894. faceUV?: Vector4[];
  109895. faceColors?: Color4[];
  109896. sideOrientation?: number;
  109897. frontUVs?: Vector4;
  109898. backUVs?: Vector4;
  109899. updatable?: boolean;
  109900. }, scene?: Nullable<Scene>): Mesh;
  109901. /**
  109902. * Creates a sphere mesh
  109903. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  109904. * * 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`)
  109905. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  109906. * * 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
  109907. * * 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)
  109908. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109909. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109911. * @param name defines the name of the mesh
  109912. * @param options defines the options used to create the mesh
  109913. * @param scene defines the hosting scene
  109914. * @returns the sphere mesh
  109915. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  109916. */
  109917. static CreateSphere(name: string, options: {
  109918. segments?: number;
  109919. diameter?: number;
  109920. diameterX?: number;
  109921. diameterY?: number;
  109922. diameterZ?: number;
  109923. arc?: number;
  109924. slice?: number;
  109925. sideOrientation?: number;
  109926. frontUVs?: Vector4;
  109927. backUVs?: Vector4;
  109928. updatable?: boolean;
  109929. }, scene?: Nullable<Scene>): Mesh;
  109930. /**
  109931. * Creates a plane polygonal mesh. By default, this is a disc
  109932. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  109933. * * 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
  109934. * * 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
  109935. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109936. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109938. * @param name defines the name of the mesh
  109939. * @param options defines the options used to create the mesh
  109940. * @param scene defines the hosting scene
  109941. * @returns the plane polygonal mesh
  109942. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  109943. */
  109944. static CreateDisc(name: string, options: {
  109945. radius?: number;
  109946. tessellation?: number;
  109947. arc?: number;
  109948. updatable?: boolean;
  109949. sideOrientation?: number;
  109950. frontUVs?: Vector4;
  109951. backUVs?: Vector4;
  109952. }, scene?: Nullable<Scene>): Mesh;
  109953. /**
  109954. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109955. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109956. * * 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`)
  109957. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109958. * * 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
  109959. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109960. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109962. * @param name defines the name of the mesh
  109963. * @param options defines the options used to create the mesh
  109964. * @param scene defines the hosting scene
  109965. * @returns the icosahedron mesh
  109966. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109967. */
  109968. static CreateIcoSphere(name: string, options: {
  109969. radius?: number;
  109970. radiusX?: number;
  109971. radiusY?: number;
  109972. radiusZ?: number;
  109973. flat?: boolean;
  109974. subdivisions?: number;
  109975. sideOrientation?: number;
  109976. frontUVs?: Vector4;
  109977. backUVs?: Vector4;
  109978. updatable?: boolean;
  109979. }, scene?: Nullable<Scene>): Mesh;
  109980. /**
  109981. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109982. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  109983. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  109984. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  109985. * * 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
  109986. * * 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
  109987. * * 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
  109988. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109989. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109990. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109991. * * 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
  109992. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  109993. * * 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
  109994. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  109995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109996. * @param name defines the name of the mesh
  109997. * @param options defines the options used to create the mesh
  109998. * @param scene defines the hosting scene
  109999. * @returns the ribbon mesh
  110000. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  110001. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110002. */
  110003. static CreateRibbon(name: string, options: {
  110004. pathArray: Vector3[][];
  110005. closeArray?: boolean;
  110006. closePath?: boolean;
  110007. offset?: number;
  110008. updatable?: boolean;
  110009. sideOrientation?: number;
  110010. frontUVs?: Vector4;
  110011. backUVs?: Vector4;
  110012. instance?: Mesh;
  110013. invertUV?: boolean;
  110014. uvs?: Vector2[];
  110015. colors?: Color4[];
  110016. }, scene?: Nullable<Scene>): Mesh;
  110017. /**
  110018. * Creates a cylinder or a cone mesh
  110019. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  110020. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  110021. * * 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.
  110022. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  110023. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  110024. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  110025. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  110026. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  110027. * * 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).
  110028. * * 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
  110029. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  110030. * * 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
  110031. * * 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.
  110032. * * If `enclose` is false, a ring surface is one element.
  110033. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  110034. * * 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
  110035. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110036. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110038. * @param name defines the name of the mesh
  110039. * @param options defines the options used to create the mesh
  110040. * @param scene defines the hosting scene
  110041. * @returns the cylinder mesh
  110042. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  110043. */
  110044. static CreateCylinder(name: string, options: {
  110045. height?: number;
  110046. diameterTop?: number;
  110047. diameterBottom?: number;
  110048. diameter?: number;
  110049. tessellation?: number;
  110050. subdivisions?: number;
  110051. arc?: number;
  110052. faceColors?: Color4[];
  110053. faceUV?: Vector4[];
  110054. updatable?: boolean;
  110055. hasRings?: boolean;
  110056. enclose?: boolean;
  110057. sideOrientation?: number;
  110058. frontUVs?: Vector4;
  110059. backUVs?: Vector4;
  110060. }, scene?: Nullable<Scene>): Mesh;
  110061. /**
  110062. * Creates a torus mesh
  110063. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  110064. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  110065. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  110066. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110067. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110069. * @param name defines the name of the mesh
  110070. * @param options defines the options used to create the mesh
  110071. * @param scene defines the hosting scene
  110072. * @returns the torus mesh
  110073. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  110074. */
  110075. static CreateTorus(name: string, options: {
  110076. diameter?: number;
  110077. thickness?: number;
  110078. tessellation?: number;
  110079. updatable?: boolean;
  110080. sideOrientation?: number;
  110081. frontUVs?: Vector4;
  110082. backUVs?: Vector4;
  110083. }, scene?: Nullable<Scene>): Mesh;
  110084. /**
  110085. * Creates a torus knot mesh
  110086. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  110087. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  110088. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  110089. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  110090. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110091. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110093. * @param name defines the name of the mesh
  110094. * @param options defines the options used to create the mesh
  110095. * @param scene defines the hosting scene
  110096. * @returns the torus knot mesh
  110097. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  110098. */
  110099. static CreateTorusKnot(name: string, options: {
  110100. radius?: number;
  110101. tube?: number;
  110102. radialSegments?: number;
  110103. tubularSegments?: number;
  110104. p?: number;
  110105. q?: number;
  110106. updatable?: boolean;
  110107. sideOrientation?: number;
  110108. frontUVs?: Vector4;
  110109. backUVs?: Vector4;
  110110. }, scene?: Nullable<Scene>): Mesh;
  110111. /**
  110112. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110113. * * 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
  110114. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110115. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110116. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110117. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110118. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110119. * * 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
  110120. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110122. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110123. * @param name defines the name of the new line system
  110124. * @param options defines the options used to create the line system
  110125. * @param scene defines the hosting scene
  110126. * @returns a new line system mesh
  110127. */
  110128. static CreateLineSystem(name: string, options: {
  110129. lines: Vector3[][];
  110130. updatable?: boolean;
  110131. instance?: Nullable<LinesMesh>;
  110132. colors?: Nullable<Color4[][]>;
  110133. useVertexAlpha?: boolean;
  110134. }, scene: Nullable<Scene>): LinesMesh;
  110135. /**
  110136. * Creates a line mesh
  110137. * 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
  110138. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110139. * * The parameter `points` is an array successive Vector3
  110140. * * 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
  110141. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110142. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110143. * * When updating an instance, remember that only point positions can change, not the number of points
  110144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110145. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110146. * @param name defines the name of the new line system
  110147. * @param options defines the options used to create the line system
  110148. * @param scene defines the hosting scene
  110149. * @returns a new line mesh
  110150. */
  110151. static CreateLines(name: string, options: {
  110152. points: Vector3[];
  110153. updatable?: boolean;
  110154. instance?: Nullable<LinesMesh>;
  110155. colors?: Color4[];
  110156. useVertexAlpha?: boolean;
  110157. }, scene?: Nullable<Scene>): LinesMesh;
  110158. /**
  110159. * Creates a dashed line mesh
  110160. * * 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
  110161. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110162. * * The parameter `points` is an array successive Vector3
  110163. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110164. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110165. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110166. * * 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
  110167. * * When updating an instance, remember that only point positions can change, not the number of points
  110168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110169. * @param name defines the name of the mesh
  110170. * @param options defines the options used to create the mesh
  110171. * @param scene defines the hosting scene
  110172. * @returns the dashed line mesh
  110173. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110174. */
  110175. static CreateDashedLines(name: string, options: {
  110176. points: Vector3[];
  110177. dashSize?: number;
  110178. gapSize?: number;
  110179. dashNb?: number;
  110180. updatable?: boolean;
  110181. instance?: LinesMesh;
  110182. }, scene?: Nullable<Scene>): LinesMesh;
  110183. /**
  110184. * 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.
  110185. * * 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.
  110186. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110187. * * 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.
  110188. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  110189. * * 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
  110190. * * 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
  110191. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  110192. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110193. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110194. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  110195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110196. * @param name defines the name of the mesh
  110197. * @param options defines the options used to create the mesh
  110198. * @param scene defines the hosting scene
  110199. * @returns the extruded shape mesh
  110200. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110201. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110202. */
  110203. static ExtrudeShape(name: string, options: {
  110204. shape: Vector3[];
  110205. path: Vector3[];
  110206. scale?: number;
  110207. rotation?: number;
  110208. cap?: number;
  110209. updatable?: boolean;
  110210. sideOrientation?: number;
  110211. frontUVs?: Vector4;
  110212. backUVs?: Vector4;
  110213. instance?: Mesh;
  110214. invertUV?: boolean;
  110215. }, scene?: Nullable<Scene>): Mesh;
  110216. /**
  110217. * Creates an custom extruded shape mesh.
  110218. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  110219. * * 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.
  110220. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110221. * * 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
  110222. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  110223. * * 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
  110224. * * It must returns a float value that will be the scale value applied to the shape on each path point
  110225. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  110226. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  110227. * * 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
  110228. * * 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
  110229. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  110230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110231. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110232. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110234. * @param name defines the name of the mesh
  110235. * @param options defines the options used to create the mesh
  110236. * @param scene defines the hosting scene
  110237. * @returns the custom extruded shape mesh
  110238. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  110239. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110240. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110241. */
  110242. static ExtrudeShapeCustom(name: string, options: {
  110243. shape: Vector3[];
  110244. path: Vector3[];
  110245. scaleFunction?: any;
  110246. rotationFunction?: any;
  110247. ribbonCloseArray?: boolean;
  110248. ribbonClosePath?: boolean;
  110249. cap?: number;
  110250. updatable?: boolean;
  110251. sideOrientation?: number;
  110252. frontUVs?: Vector4;
  110253. backUVs?: Vector4;
  110254. instance?: Mesh;
  110255. invertUV?: boolean;
  110256. }, scene?: Nullable<Scene>): Mesh;
  110257. /**
  110258. * Creates lathe mesh.
  110259. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  110260. * * 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
  110261. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  110262. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  110263. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  110264. * * 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
  110265. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  110266. * * 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
  110267. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110268. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110269. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110271. * @param name defines the name of the mesh
  110272. * @param options defines the options used to create the mesh
  110273. * @param scene defines the hosting scene
  110274. * @returns the lathe mesh
  110275. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  110276. */
  110277. static CreateLathe(name: string, options: {
  110278. shape: Vector3[];
  110279. radius?: number;
  110280. tessellation?: number;
  110281. clip?: number;
  110282. arc?: number;
  110283. closed?: boolean;
  110284. updatable?: boolean;
  110285. sideOrientation?: number;
  110286. frontUVs?: Vector4;
  110287. backUVs?: Vector4;
  110288. cap?: number;
  110289. invertUV?: boolean;
  110290. }, scene?: Nullable<Scene>): Mesh;
  110291. /**
  110292. * Creates a plane mesh
  110293. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  110294. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  110295. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  110296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110297. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110299. * @param name defines the name of the mesh
  110300. * @param options defines the options used to create the mesh
  110301. * @param scene defines the hosting scene
  110302. * @returns the plane mesh
  110303. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  110304. */
  110305. static CreatePlane(name: string, options: {
  110306. size?: number;
  110307. width?: number;
  110308. height?: number;
  110309. sideOrientation?: number;
  110310. frontUVs?: Vector4;
  110311. backUVs?: Vector4;
  110312. updatable?: boolean;
  110313. sourcePlane?: Plane;
  110314. }, scene?: Nullable<Scene>): Mesh;
  110315. /**
  110316. * Creates a ground mesh
  110317. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  110318. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  110319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110320. * @param name defines the name of the mesh
  110321. * @param options defines the options used to create the mesh
  110322. * @param scene defines the hosting scene
  110323. * @returns the ground mesh
  110324. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  110325. */
  110326. static CreateGround(name: string, options: {
  110327. width?: number;
  110328. height?: number;
  110329. subdivisions?: number;
  110330. subdivisionsX?: number;
  110331. subdivisionsY?: number;
  110332. updatable?: boolean;
  110333. }, scene?: Nullable<Scene>): Mesh;
  110334. /**
  110335. * Creates a tiled ground mesh
  110336. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  110337. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  110338. * * 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
  110339. * * 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
  110340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110341. * @param name defines the name of the mesh
  110342. * @param options defines the options used to create the mesh
  110343. * @param scene defines the hosting scene
  110344. * @returns the tiled ground mesh
  110345. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  110346. */
  110347. static CreateTiledGround(name: string, options: {
  110348. xmin: number;
  110349. zmin: number;
  110350. xmax: number;
  110351. zmax: number;
  110352. subdivisions?: {
  110353. w: number;
  110354. h: number;
  110355. };
  110356. precision?: {
  110357. w: number;
  110358. h: number;
  110359. };
  110360. updatable?: boolean;
  110361. }, scene?: Nullable<Scene>): Mesh;
  110362. /**
  110363. * Creates a ground mesh from a height map
  110364. * * The parameter `url` sets the URL of the height map image resource.
  110365. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  110366. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  110367. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  110368. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  110369. * * 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.
  110370. * * 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).
  110371. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  110372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110373. * @param name defines the name of the mesh
  110374. * @param url defines the url to the height map
  110375. * @param options defines the options used to create the mesh
  110376. * @param scene defines the hosting scene
  110377. * @returns the ground mesh
  110378. * @see https://doc.babylonjs.com/babylon101/height_map
  110379. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  110380. */
  110381. static CreateGroundFromHeightMap(name: string, url: string, options: {
  110382. width?: number;
  110383. height?: number;
  110384. subdivisions?: number;
  110385. minHeight?: number;
  110386. maxHeight?: number;
  110387. colorFilter?: Color3;
  110388. alphaFilter?: number;
  110389. updatable?: boolean;
  110390. onReady?: (mesh: GroundMesh) => void;
  110391. }, scene?: Nullable<Scene>): GroundMesh;
  110392. /**
  110393. * Creates a polygon mesh
  110394. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  110395. * * 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
  110396. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110398. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  110399. * * Remember you can only change the shape positions, not their number when updating a polygon
  110400. * @param name defines the name of the mesh
  110401. * @param options defines the options used to create the mesh
  110402. * @param scene defines the hosting scene
  110403. * @param earcutInjection can be used to inject your own earcut reference
  110404. * @returns the polygon mesh
  110405. */
  110406. static CreatePolygon(name: string, options: {
  110407. shape: Vector3[];
  110408. holes?: Vector3[][];
  110409. depth?: number;
  110410. faceUV?: Vector4[];
  110411. faceColors?: Color4[];
  110412. updatable?: boolean;
  110413. sideOrientation?: number;
  110414. frontUVs?: Vector4;
  110415. backUVs?: Vector4;
  110416. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110417. /**
  110418. * Creates an extruded polygon mesh, with depth in the Y direction.
  110419. * * 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)
  110420. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110421. * @param name defines the name of the mesh
  110422. * @param options defines the options used to create the mesh
  110423. * @param scene defines the hosting scene
  110424. * @param earcutInjection can be used to inject your own earcut reference
  110425. * @returns the polygon mesh
  110426. */
  110427. static ExtrudePolygon(name: string, options: {
  110428. shape: Vector3[];
  110429. holes?: Vector3[][];
  110430. depth?: number;
  110431. faceUV?: Vector4[];
  110432. faceColors?: Color4[];
  110433. updatable?: boolean;
  110434. sideOrientation?: number;
  110435. frontUVs?: Vector4;
  110436. backUVs?: Vector4;
  110437. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110438. /**
  110439. * Creates a tube mesh.
  110440. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110441. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  110442. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  110443. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  110444. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  110445. * * 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)
  110446. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  110447. * * 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
  110448. * * 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
  110449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110450. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110451. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110453. * @param name defines the name of the mesh
  110454. * @param options defines the options used to create the mesh
  110455. * @param scene defines the hosting scene
  110456. * @returns the tube mesh
  110457. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110458. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  110459. */
  110460. static CreateTube(name: string, options: {
  110461. path: Vector3[];
  110462. radius?: number;
  110463. tessellation?: number;
  110464. radiusFunction?: {
  110465. (i: number, distance: number): number;
  110466. };
  110467. cap?: number;
  110468. arc?: number;
  110469. updatable?: boolean;
  110470. sideOrientation?: number;
  110471. frontUVs?: Vector4;
  110472. backUVs?: Vector4;
  110473. instance?: Mesh;
  110474. invertUV?: boolean;
  110475. }, scene?: Nullable<Scene>): Mesh;
  110476. /**
  110477. * Creates a polyhedron mesh
  110478. * * 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
  110479. * * The parameter `size` (positive float, default 1) sets the polygon size
  110480. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  110481. * * 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`
  110482. * * 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
  110483. * * 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)`)
  110484. * * 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
  110485. * * 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
  110486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110487. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110489. * @param name defines the name of the mesh
  110490. * @param options defines the options used to create the mesh
  110491. * @param scene defines the hosting scene
  110492. * @returns the polyhedron mesh
  110493. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  110494. */
  110495. static CreatePolyhedron(name: string, options: {
  110496. type?: number;
  110497. size?: number;
  110498. sizeX?: number;
  110499. sizeY?: number;
  110500. sizeZ?: number;
  110501. custom?: any;
  110502. faceUV?: Vector4[];
  110503. faceColors?: Color4[];
  110504. flat?: boolean;
  110505. updatable?: boolean;
  110506. sideOrientation?: number;
  110507. frontUVs?: Vector4;
  110508. backUVs?: Vector4;
  110509. }, scene?: Nullable<Scene>): Mesh;
  110510. /**
  110511. * Creates a decal mesh.
  110512. * 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
  110513. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  110514. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  110515. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  110516. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  110517. * @param name defines the name of the mesh
  110518. * @param sourceMesh defines the mesh where the decal must be applied
  110519. * @param options defines the options used to create the mesh
  110520. * @param scene defines the hosting scene
  110521. * @returns the decal mesh
  110522. * @see https://doc.babylonjs.com/how_to/decals
  110523. */
  110524. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  110525. position?: Vector3;
  110526. normal?: Vector3;
  110527. size?: Vector3;
  110528. angle?: number;
  110529. }): Mesh;
  110530. }
  110531. }
  110532. declare module BABYLON {
  110533. /**
  110534. * A simplifier interface for future simplification implementations
  110535. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110536. */
  110537. export interface ISimplifier {
  110538. /**
  110539. * Simplification of a given mesh according to the given settings.
  110540. * Since this requires computation, it is assumed that the function runs async.
  110541. * @param settings The settings of the simplification, including quality and distance
  110542. * @param successCallback A callback that will be called after the mesh was simplified.
  110543. * @param errorCallback in case of an error, this callback will be called. optional.
  110544. */
  110545. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  110546. }
  110547. /**
  110548. * Expected simplification settings.
  110549. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  110550. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110551. */
  110552. export interface ISimplificationSettings {
  110553. /**
  110554. * Gets or sets the expected quality
  110555. */
  110556. quality: number;
  110557. /**
  110558. * Gets or sets the distance when this optimized version should be used
  110559. */
  110560. distance: number;
  110561. /**
  110562. * Gets an already optimized mesh
  110563. */
  110564. optimizeMesh?: boolean;
  110565. }
  110566. /**
  110567. * Class used to specify simplification options
  110568. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110569. */
  110570. export class SimplificationSettings implements ISimplificationSettings {
  110571. /** expected quality */
  110572. quality: number;
  110573. /** distance when this optimized version should be used */
  110574. distance: number;
  110575. /** already optimized mesh */
  110576. optimizeMesh?: boolean | undefined;
  110577. /**
  110578. * Creates a SimplificationSettings
  110579. * @param quality expected quality
  110580. * @param distance distance when this optimized version should be used
  110581. * @param optimizeMesh already optimized mesh
  110582. */
  110583. constructor(
  110584. /** expected quality */
  110585. quality: number,
  110586. /** distance when this optimized version should be used */
  110587. distance: number,
  110588. /** already optimized mesh */
  110589. optimizeMesh?: boolean | undefined);
  110590. }
  110591. /**
  110592. * Interface used to define a simplification task
  110593. */
  110594. export interface ISimplificationTask {
  110595. /**
  110596. * Array of settings
  110597. */
  110598. settings: Array<ISimplificationSettings>;
  110599. /**
  110600. * Simplification type
  110601. */
  110602. simplificationType: SimplificationType;
  110603. /**
  110604. * Mesh to simplify
  110605. */
  110606. mesh: Mesh;
  110607. /**
  110608. * Callback called on success
  110609. */
  110610. successCallback?: () => void;
  110611. /**
  110612. * Defines if parallel processing can be used
  110613. */
  110614. parallelProcessing: boolean;
  110615. }
  110616. /**
  110617. * Queue used to order the simplification tasks
  110618. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110619. */
  110620. export class SimplificationQueue {
  110621. private _simplificationArray;
  110622. /**
  110623. * Gets a boolean indicating that the process is still running
  110624. */
  110625. running: boolean;
  110626. /**
  110627. * Creates a new queue
  110628. */
  110629. constructor();
  110630. /**
  110631. * Adds a new simplification task
  110632. * @param task defines a task to add
  110633. */
  110634. addTask(task: ISimplificationTask): void;
  110635. /**
  110636. * Execute next task
  110637. */
  110638. executeNext(): void;
  110639. /**
  110640. * Execute a simplification task
  110641. * @param task defines the task to run
  110642. */
  110643. runSimplification(task: ISimplificationTask): void;
  110644. private getSimplifier;
  110645. }
  110646. /**
  110647. * The implemented types of simplification
  110648. * At the moment only Quadratic Error Decimation is implemented
  110649. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110650. */
  110651. export enum SimplificationType {
  110652. /** Quadratic error decimation */
  110653. QUADRATIC = 0
  110654. }
  110655. }
  110656. declare module BABYLON {
  110657. interface Scene {
  110658. /** @hidden (Backing field) */
  110659. _simplificationQueue: SimplificationQueue;
  110660. /**
  110661. * Gets or sets the simplification queue attached to the scene
  110662. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110663. */
  110664. simplificationQueue: SimplificationQueue;
  110665. }
  110666. interface Mesh {
  110667. /**
  110668. * Simplify the mesh according to the given array of settings.
  110669. * Function will return immediately and will simplify async
  110670. * @param settings a collection of simplification settings
  110671. * @param parallelProcessing should all levels calculate parallel or one after the other
  110672. * @param simplificationType the type of simplification to run
  110673. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  110674. * @returns the current mesh
  110675. */
  110676. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  110677. }
  110678. /**
  110679. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  110680. * created in a scene
  110681. */
  110682. export class SimplicationQueueSceneComponent implements ISceneComponent {
  110683. /**
  110684. * The component name helpfull to identify the component in the list of scene components.
  110685. */
  110686. readonly name: string;
  110687. /**
  110688. * The scene the component belongs to.
  110689. */
  110690. scene: Scene;
  110691. /**
  110692. * Creates a new instance of the component for the given scene
  110693. * @param scene Defines the scene to register the component in
  110694. */
  110695. constructor(scene: Scene);
  110696. /**
  110697. * Registers the component in a given scene
  110698. */
  110699. register(): void;
  110700. /**
  110701. * Rebuilds the elements related to this component in case of
  110702. * context lost for instance.
  110703. */
  110704. rebuild(): void;
  110705. /**
  110706. * Disposes the component and the associated ressources
  110707. */
  110708. dispose(): void;
  110709. private _beforeCameraUpdate;
  110710. }
  110711. }
  110712. declare module BABYLON {
  110713. /**
  110714. * Class used to enable access to IndexedDB
  110715. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  110716. */
  110717. export class Database implements IOfflineProvider {
  110718. private _callbackManifestChecked;
  110719. private _currentSceneUrl;
  110720. private _db;
  110721. private _enableSceneOffline;
  110722. private _enableTexturesOffline;
  110723. private _manifestVersionFound;
  110724. private _mustUpdateRessources;
  110725. private _hasReachedQuota;
  110726. private _isSupported;
  110727. private _idbFactory;
  110728. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  110729. private static IsUASupportingBlobStorage;
  110730. /**
  110731. * Gets a boolean indicating if Database storate is enabled (off by default)
  110732. */
  110733. static IDBStorageEnabled: boolean;
  110734. /**
  110735. * Gets a boolean indicating if scene must be saved in the database
  110736. */
  110737. readonly enableSceneOffline: boolean;
  110738. /**
  110739. * Gets a boolean indicating if textures must be saved in the database
  110740. */
  110741. readonly enableTexturesOffline: boolean;
  110742. /**
  110743. * Creates a new Database
  110744. * @param urlToScene defines the url to load the scene
  110745. * @param callbackManifestChecked defines the callback to use when manifest is checked
  110746. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  110747. */
  110748. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  110749. private static _ParseURL;
  110750. private static _ReturnFullUrlLocation;
  110751. private _checkManifestFile;
  110752. /**
  110753. * Open the database and make it available
  110754. * @param successCallback defines the callback to call on success
  110755. * @param errorCallback defines the callback to call on error
  110756. */
  110757. open(successCallback: () => void, errorCallback: () => void): void;
  110758. /**
  110759. * Loads an image from the database
  110760. * @param url defines the url to load from
  110761. * @param image defines the target DOM image
  110762. */
  110763. loadImage(url: string, image: HTMLImageElement): void;
  110764. private _loadImageFromDBAsync;
  110765. private _saveImageIntoDBAsync;
  110766. private _checkVersionFromDB;
  110767. private _loadVersionFromDBAsync;
  110768. private _saveVersionIntoDBAsync;
  110769. /**
  110770. * Loads a file from database
  110771. * @param url defines the URL to load from
  110772. * @param sceneLoaded defines a callback to call on success
  110773. * @param progressCallBack defines a callback to call when progress changed
  110774. * @param errorCallback defines a callback to call on error
  110775. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  110776. */
  110777. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  110778. private _loadFileAsync;
  110779. private _saveFileAsync;
  110780. /**
  110781. * Validates if xhr data is correct
  110782. * @param xhr defines the request to validate
  110783. * @param dataType defines the expected data type
  110784. * @returns true if data is correct
  110785. */
  110786. private static _ValidateXHRData;
  110787. }
  110788. }
  110789. declare module BABYLON {
  110790. /** @hidden */
  110791. export var gpuUpdateParticlesPixelShader: {
  110792. name: string;
  110793. shader: string;
  110794. };
  110795. }
  110796. declare module BABYLON {
  110797. /** @hidden */
  110798. export var gpuUpdateParticlesVertexShader: {
  110799. name: string;
  110800. shader: string;
  110801. };
  110802. }
  110803. declare module BABYLON {
  110804. /** @hidden */
  110805. export var clipPlaneFragmentDeclaration2: {
  110806. name: string;
  110807. shader: string;
  110808. };
  110809. }
  110810. declare module BABYLON {
  110811. /** @hidden */
  110812. export var gpuRenderParticlesPixelShader: {
  110813. name: string;
  110814. shader: string;
  110815. };
  110816. }
  110817. declare module BABYLON {
  110818. /** @hidden */
  110819. export var clipPlaneVertexDeclaration2: {
  110820. name: string;
  110821. shader: string;
  110822. };
  110823. }
  110824. declare module BABYLON {
  110825. /** @hidden */
  110826. export var gpuRenderParticlesVertexShader: {
  110827. name: string;
  110828. shader: string;
  110829. };
  110830. }
  110831. declare module BABYLON {
  110832. /**
  110833. * This represents a GPU particle system in Babylon
  110834. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  110835. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  110836. */
  110837. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  110838. /**
  110839. * The layer mask we are rendering the particles through.
  110840. */
  110841. layerMask: number;
  110842. private _capacity;
  110843. private _activeCount;
  110844. private _currentActiveCount;
  110845. private _accumulatedCount;
  110846. private _renderEffect;
  110847. private _updateEffect;
  110848. private _buffer0;
  110849. private _buffer1;
  110850. private _spriteBuffer;
  110851. private _updateVAO;
  110852. private _renderVAO;
  110853. private _targetIndex;
  110854. private _sourceBuffer;
  110855. private _targetBuffer;
  110856. private _engine;
  110857. private _currentRenderId;
  110858. private _started;
  110859. private _stopped;
  110860. private _timeDelta;
  110861. private _randomTexture;
  110862. private _randomTexture2;
  110863. private _attributesStrideSize;
  110864. private _updateEffectOptions;
  110865. private _randomTextureSize;
  110866. private _actualFrame;
  110867. private readonly _rawTextureWidth;
  110868. /**
  110869. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  110870. */
  110871. static readonly IsSupported: boolean;
  110872. /**
  110873. * An event triggered when the system is disposed.
  110874. */
  110875. onDisposeObservable: Observable<GPUParticleSystem>;
  110876. /**
  110877. * Gets the maximum number of particles active at the same time.
  110878. * @returns The max number of active particles.
  110879. */
  110880. getCapacity(): number;
  110881. /**
  110882. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  110883. * to override the particles.
  110884. */
  110885. forceDepthWrite: boolean;
  110886. /**
  110887. * Gets or set the number of active particles
  110888. */
  110889. activeParticleCount: number;
  110890. private _preWarmDone;
  110891. /**
  110892. * Is this system ready to be used/rendered
  110893. * @return true if the system is ready
  110894. */
  110895. isReady(): boolean;
  110896. /**
  110897. * Gets if the system has been started. (Note: this will still be true after stop is called)
  110898. * @returns True if it has been started, otherwise false.
  110899. */
  110900. isStarted(): boolean;
  110901. /**
  110902. * Starts the particle system and begins to emit
  110903. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  110904. */
  110905. start(delay?: number): void;
  110906. /**
  110907. * Stops the particle system.
  110908. */
  110909. stop(): void;
  110910. /**
  110911. * Remove all active particles
  110912. */
  110913. reset(): void;
  110914. /**
  110915. * Returns the string "GPUParticleSystem"
  110916. * @returns a string containing the class name
  110917. */
  110918. getClassName(): string;
  110919. private _colorGradientsTexture;
  110920. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  110921. /**
  110922. * Adds a new color gradient
  110923. * @param gradient defines the gradient to use (between 0 and 1)
  110924. * @param color1 defines the color to affect to the specified gradient
  110925. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  110926. * @returns the current particle system
  110927. */
  110928. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  110929. /**
  110930. * Remove a specific color gradient
  110931. * @param gradient defines the gradient to remove
  110932. * @returns the current particle system
  110933. */
  110934. removeColorGradient(gradient: number): GPUParticleSystem;
  110935. private _angularSpeedGradientsTexture;
  110936. private _sizeGradientsTexture;
  110937. private _velocityGradientsTexture;
  110938. private _limitVelocityGradientsTexture;
  110939. private _dragGradientsTexture;
  110940. private _addFactorGradient;
  110941. /**
  110942. * Adds a new size gradient
  110943. * @param gradient defines the gradient to use (between 0 and 1)
  110944. * @param factor defines the size factor to affect to the specified gradient
  110945. * @returns the current particle system
  110946. */
  110947. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  110948. /**
  110949. * Remove a specific size gradient
  110950. * @param gradient defines the gradient to remove
  110951. * @returns the current particle system
  110952. */
  110953. removeSizeGradient(gradient: number): GPUParticleSystem;
  110954. /**
  110955. * Adds a new angular speed gradient
  110956. * @param gradient defines the gradient to use (between 0 and 1)
  110957. * @param factor defines the angular speed to affect to the specified gradient
  110958. * @returns the current particle system
  110959. */
  110960. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  110961. /**
  110962. * Remove a specific angular speed gradient
  110963. * @param gradient defines the gradient to remove
  110964. * @returns the current particle system
  110965. */
  110966. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  110967. /**
  110968. * Adds a new velocity gradient
  110969. * @param gradient defines the gradient to use (between 0 and 1)
  110970. * @param factor defines the velocity to affect to the specified gradient
  110971. * @returns the current particle system
  110972. */
  110973. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  110974. /**
  110975. * Remove a specific velocity gradient
  110976. * @param gradient defines the gradient to remove
  110977. * @returns the current particle system
  110978. */
  110979. removeVelocityGradient(gradient: number): GPUParticleSystem;
  110980. /**
  110981. * Adds a new limit velocity gradient
  110982. * @param gradient defines the gradient to use (between 0 and 1)
  110983. * @param factor defines the limit velocity value to affect to the specified gradient
  110984. * @returns the current particle system
  110985. */
  110986. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  110987. /**
  110988. * Remove a specific limit velocity gradient
  110989. * @param gradient defines the gradient to remove
  110990. * @returns the current particle system
  110991. */
  110992. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  110993. /**
  110994. * Adds a new drag gradient
  110995. * @param gradient defines the gradient to use (between 0 and 1)
  110996. * @param factor defines the drag value to affect to the specified gradient
  110997. * @returns the current particle system
  110998. */
  110999. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  111000. /**
  111001. * Remove a specific drag gradient
  111002. * @param gradient defines the gradient to remove
  111003. * @returns the current particle system
  111004. */
  111005. removeDragGradient(gradient: number): GPUParticleSystem;
  111006. /**
  111007. * Not supported by GPUParticleSystem
  111008. * @param gradient defines the gradient to use (between 0 and 1)
  111009. * @param factor defines the emit rate value to affect to the specified gradient
  111010. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111011. * @returns the current particle system
  111012. */
  111013. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111014. /**
  111015. * Not supported by GPUParticleSystem
  111016. * @param gradient defines the gradient to remove
  111017. * @returns the current particle system
  111018. */
  111019. removeEmitRateGradient(gradient: number): IParticleSystem;
  111020. /**
  111021. * Not supported by GPUParticleSystem
  111022. * @param gradient defines the gradient to use (between 0 and 1)
  111023. * @param factor defines the start size value to affect to the specified gradient
  111024. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111025. * @returns the current particle system
  111026. */
  111027. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111028. /**
  111029. * Not supported by GPUParticleSystem
  111030. * @param gradient defines the gradient to remove
  111031. * @returns the current particle system
  111032. */
  111033. removeStartSizeGradient(gradient: number): IParticleSystem;
  111034. /**
  111035. * Not supported by GPUParticleSystem
  111036. * @param gradient defines the gradient to use (between 0 and 1)
  111037. * @param min defines the color remap minimal range
  111038. * @param max defines the color remap maximal range
  111039. * @returns the current particle system
  111040. */
  111041. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  111042. /**
  111043. * Not supported by GPUParticleSystem
  111044. * @param gradient defines the gradient to remove
  111045. * @returns the current particle system
  111046. */
  111047. removeColorRemapGradient(): IParticleSystem;
  111048. /**
  111049. * Not supported by GPUParticleSystem
  111050. * @param gradient defines the gradient to use (between 0 and 1)
  111051. * @param min defines the alpha remap minimal range
  111052. * @param max defines the alpha remap maximal range
  111053. * @returns the current particle system
  111054. */
  111055. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  111056. /**
  111057. * Not supported by GPUParticleSystem
  111058. * @param gradient defines the gradient to remove
  111059. * @returns the current particle system
  111060. */
  111061. removeAlphaRemapGradient(): IParticleSystem;
  111062. /**
  111063. * Not supported by GPUParticleSystem
  111064. * @param gradient defines the gradient to use (between 0 and 1)
  111065. * @param color defines the color to affect to the specified gradient
  111066. * @returns the current particle system
  111067. */
  111068. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  111069. /**
  111070. * Not supported by GPUParticleSystem
  111071. * @param gradient defines the gradient to remove
  111072. * @returns the current particle system
  111073. */
  111074. removeRampGradient(): IParticleSystem;
  111075. /**
  111076. * Not supported by GPUParticleSystem
  111077. * @returns the list of ramp gradients
  111078. */
  111079. getRampGradients(): Nullable<Array<Color3Gradient>>;
  111080. /**
  111081. * Not supported by GPUParticleSystem
  111082. * Gets or sets a boolean indicating that ramp gradients must be used
  111083. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  111084. */
  111085. useRampGradients: boolean;
  111086. /**
  111087. * Not supported by GPUParticleSystem
  111088. * @param gradient defines the gradient to use (between 0 and 1)
  111089. * @param factor defines the life time factor to affect to the specified gradient
  111090. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111091. * @returns the current particle system
  111092. */
  111093. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111094. /**
  111095. * Not supported by GPUParticleSystem
  111096. * @param gradient defines the gradient to remove
  111097. * @returns the current particle system
  111098. */
  111099. removeLifeTimeGradient(gradient: number): IParticleSystem;
  111100. /**
  111101. * Instantiates a GPU particle system.
  111102. * 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.
  111103. * @param name The name of the particle system
  111104. * @param options The options used to create the system
  111105. * @param scene The scene the particle system belongs to
  111106. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  111107. */
  111108. constructor(name: string, options: Partial<{
  111109. capacity: number;
  111110. randomTextureSize: number;
  111111. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  111112. protected _reset(): void;
  111113. private _createUpdateVAO;
  111114. private _createRenderVAO;
  111115. private _initialize;
  111116. /** @hidden */
  111117. _recreateUpdateEffect(): void;
  111118. /** @hidden */
  111119. _recreateRenderEffect(): void;
  111120. /**
  111121. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  111122. * @param preWarm defines if we are in the pre-warmimg phase
  111123. */
  111124. animate(preWarm?: boolean): void;
  111125. private _createFactorGradientTexture;
  111126. private _createSizeGradientTexture;
  111127. private _createAngularSpeedGradientTexture;
  111128. private _createVelocityGradientTexture;
  111129. private _createLimitVelocityGradientTexture;
  111130. private _createDragGradientTexture;
  111131. private _createColorGradientTexture;
  111132. /**
  111133. * Renders the particle system in its current state
  111134. * @param preWarm defines if the system should only update the particles but not render them
  111135. * @returns the current number of particles
  111136. */
  111137. render(preWarm?: boolean): number;
  111138. /**
  111139. * Rebuilds the particle system
  111140. */
  111141. rebuild(): void;
  111142. private _releaseBuffers;
  111143. private _releaseVAOs;
  111144. /**
  111145. * Disposes the particle system and free the associated resources
  111146. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  111147. */
  111148. dispose(disposeTexture?: boolean): void;
  111149. /**
  111150. * Clones the particle system.
  111151. * @param name The name of the cloned object
  111152. * @param newEmitter The new emitter to use
  111153. * @returns the cloned particle system
  111154. */
  111155. clone(name: string, newEmitter: any): GPUParticleSystem;
  111156. /**
  111157. * Serializes the particle system to a JSON object.
  111158. * @returns the JSON object
  111159. */
  111160. serialize(): any;
  111161. /**
  111162. * Parses a JSON object to create a GPU particle system.
  111163. * @param parsedParticleSystem The JSON object to parse
  111164. * @param scene The scene to create the particle system in
  111165. * @param rootUrl The root url to use to load external dependencies like texture
  111166. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  111167. * @returns the parsed GPU particle system
  111168. */
  111169. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  111170. }
  111171. }
  111172. declare module BABYLON {
  111173. /**
  111174. * Represents a set of particle systems working together to create a specific effect
  111175. */
  111176. export class ParticleSystemSet implements IDisposable {
  111177. private _emitterCreationOptions;
  111178. private _emitterNode;
  111179. /**
  111180. * Gets the particle system list
  111181. */
  111182. systems: IParticleSystem[];
  111183. /**
  111184. * Gets the emitter node used with this set
  111185. */
  111186. readonly emitterNode: Nullable<TransformNode>;
  111187. /**
  111188. * Creates a new emitter mesh as a sphere
  111189. * @param options defines the options used to create the sphere
  111190. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  111191. * @param scene defines the hosting scene
  111192. */
  111193. setEmitterAsSphere(options: {
  111194. diameter: number;
  111195. segments: number;
  111196. color: Color3;
  111197. }, renderingGroupId: number, scene: Scene): void;
  111198. /**
  111199. * Starts all particle systems of the set
  111200. * @param emitter defines an optional mesh to use as emitter for the particle systems
  111201. */
  111202. start(emitter?: AbstractMesh): void;
  111203. /**
  111204. * Release all associated resources
  111205. */
  111206. dispose(): void;
  111207. /**
  111208. * Serialize the set into a JSON compatible object
  111209. * @returns a JSON compatible representation of the set
  111210. */
  111211. serialize(): any;
  111212. /**
  111213. * Parse a new ParticleSystemSet from a serialized source
  111214. * @param data defines a JSON compatible representation of the set
  111215. * @param scene defines the hosting scene
  111216. * @param gpu defines if we want GPU particles or CPU particles
  111217. * @returns a new ParticleSystemSet
  111218. */
  111219. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  111220. }
  111221. }
  111222. declare module BABYLON {
  111223. /**
  111224. * This class is made for on one-liner static method to help creating particle system set.
  111225. */
  111226. export class ParticleHelper {
  111227. /**
  111228. * Gets or sets base Assets URL
  111229. */
  111230. static BaseAssetsUrl: string;
  111231. /**
  111232. * Create a default particle system that you can tweak
  111233. * @param emitter defines the emitter to use
  111234. * @param capacity defines the system capacity (default is 500 particles)
  111235. * @param scene defines the hosting scene
  111236. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  111237. * @returns the new Particle system
  111238. */
  111239. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  111240. /**
  111241. * This is the main static method (one-liner) of this helper to create different particle systems
  111242. * @param type This string represents the type to the particle system to create
  111243. * @param scene The scene where the particle system should live
  111244. * @param gpu If the system will use gpu
  111245. * @returns the ParticleSystemSet created
  111246. */
  111247. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  111248. /**
  111249. * Static function used to export a particle system to a ParticleSystemSet variable.
  111250. * Please note that the emitter shape is not exported
  111251. * @param systems defines the particle systems to export
  111252. * @returns the created particle system set
  111253. */
  111254. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  111255. }
  111256. }
  111257. declare module BABYLON {
  111258. interface Engine {
  111259. /**
  111260. * Create an effect to use with particle systems.
  111261. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  111262. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  111263. * @param uniformsNames defines a list of attribute names
  111264. * @param samplers defines an array of string used to represent textures
  111265. * @param defines defines the string containing the defines to use to compile the shaders
  111266. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  111267. * @param onCompiled defines a function to call when the effect creation is successful
  111268. * @param onError defines a function to call when the effect creation has failed
  111269. * @returns the new Effect
  111270. */
  111271. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  111272. }
  111273. interface Mesh {
  111274. /**
  111275. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  111276. * @returns an array of IParticleSystem
  111277. */
  111278. getEmittedParticleSystems(): IParticleSystem[];
  111279. /**
  111280. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  111281. * @returns an array of IParticleSystem
  111282. */
  111283. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  111284. }
  111285. /**
  111286. * @hidden
  111287. */
  111288. export var _IDoNeedToBeInTheBuild: number;
  111289. }
  111290. declare module BABYLON {
  111291. interface Scene {
  111292. /** @hidden (Backing field) */
  111293. _physicsEngine: Nullable<IPhysicsEngine>;
  111294. /**
  111295. * Gets the current physics engine
  111296. * @returns a IPhysicsEngine or null if none attached
  111297. */
  111298. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  111299. /**
  111300. * Enables physics to the current scene
  111301. * @param gravity defines the scene's gravity for the physics engine
  111302. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  111303. * @return a boolean indicating if the physics engine was initialized
  111304. */
  111305. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  111306. /**
  111307. * Disables and disposes the physics engine associated with the scene
  111308. */
  111309. disablePhysicsEngine(): void;
  111310. /**
  111311. * Gets a boolean indicating if there is an active physics engine
  111312. * @returns a boolean indicating if there is an active physics engine
  111313. */
  111314. isPhysicsEnabled(): boolean;
  111315. /**
  111316. * Deletes a physics compound impostor
  111317. * @param compound defines the compound to delete
  111318. */
  111319. deleteCompoundImpostor(compound: any): void;
  111320. /**
  111321. * An event triggered when physic simulation is about to be run
  111322. */
  111323. onBeforePhysicsObservable: Observable<Scene>;
  111324. /**
  111325. * An event triggered when physic simulation has been done
  111326. */
  111327. onAfterPhysicsObservable: Observable<Scene>;
  111328. }
  111329. interface AbstractMesh {
  111330. /** @hidden */
  111331. _physicsImpostor: Nullable<PhysicsImpostor>;
  111332. /**
  111333. * Gets or sets impostor used for physic simulation
  111334. * @see http://doc.babylonjs.com/features/physics_engine
  111335. */
  111336. physicsImpostor: Nullable<PhysicsImpostor>;
  111337. /**
  111338. * Gets the current physics impostor
  111339. * @see http://doc.babylonjs.com/features/physics_engine
  111340. * @returns a physics impostor or null
  111341. */
  111342. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  111343. /** Apply a physic impulse to the mesh
  111344. * @param force defines the force to apply
  111345. * @param contactPoint defines where to apply the force
  111346. * @returns the current mesh
  111347. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111348. */
  111349. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  111350. /**
  111351. * Creates a physic joint between two meshes
  111352. * @param otherMesh defines the other mesh to use
  111353. * @param pivot1 defines the pivot to use on this mesh
  111354. * @param pivot2 defines the pivot to use on the other mesh
  111355. * @param options defines additional options (can be plugin dependent)
  111356. * @returns the current mesh
  111357. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  111358. */
  111359. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  111360. /** @hidden */
  111361. _disposePhysicsObserver: Nullable<Observer<Node>>;
  111362. }
  111363. /**
  111364. * Defines the physics engine scene component responsible to manage a physics engine
  111365. */
  111366. export class PhysicsEngineSceneComponent implements ISceneComponent {
  111367. /**
  111368. * The component name helpful to identify the component in the list of scene components.
  111369. */
  111370. readonly name: string;
  111371. /**
  111372. * The scene the component belongs to.
  111373. */
  111374. scene: Scene;
  111375. /**
  111376. * Creates a new instance of the component for the given scene
  111377. * @param scene Defines the scene to register the component in
  111378. */
  111379. constructor(scene: Scene);
  111380. /**
  111381. * Registers the component in a given scene
  111382. */
  111383. register(): void;
  111384. /**
  111385. * Rebuilds the elements related to this component in case of
  111386. * context lost for instance.
  111387. */
  111388. rebuild(): void;
  111389. /**
  111390. * Disposes the component and the associated ressources
  111391. */
  111392. dispose(): void;
  111393. }
  111394. }
  111395. declare module BABYLON {
  111396. /**
  111397. * A helper for physics simulations
  111398. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111399. */
  111400. export class PhysicsHelper {
  111401. private _scene;
  111402. private _physicsEngine;
  111403. /**
  111404. * Initializes the Physics helper
  111405. * @param scene Babylon.js scene
  111406. */
  111407. constructor(scene: Scene);
  111408. /**
  111409. * Applies a radial explosion impulse
  111410. * @param origin the origin of the explosion
  111411. * @param radiusOrEventOptions the radius or the options of radial explosion
  111412. * @param strength the explosion strength
  111413. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111414. * @returns A physics radial explosion event, or null
  111415. */
  111416. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111417. /**
  111418. * Applies a radial explosion force
  111419. * @param origin the origin of the explosion
  111420. * @param radiusOrEventOptions the radius or the options of radial explosion
  111421. * @param strength the explosion strength
  111422. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111423. * @returns A physics radial explosion event, or null
  111424. */
  111425. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111426. /**
  111427. * Creates a gravitational field
  111428. * @param origin the origin of the explosion
  111429. * @param radiusOrEventOptions the radius or the options of radial explosion
  111430. * @param strength the explosion strength
  111431. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111432. * @returns A physics gravitational field event, or null
  111433. */
  111434. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  111435. /**
  111436. * Creates a physics updraft event
  111437. * @param origin the origin of the updraft
  111438. * @param radiusOrEventOptions the radius or the options of the updraft
  111439. * @param strength the strength of the updraft
  111440. * @param height the height of the updraft
  111441. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  111442. * @returns A physics updraft event, or null
  111443. */
  111444. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  111445. /**
  111446. * Creates a physics vortex event
  111447. * @param origin the of the vortex
  111448. * @param radiusOrEventOptions the radius or the options of the vortex
  111449. * @param strength the strength of the vortex
  111450. * @param height the height of the vortex
  111451. * @returns a Physics vortex event, or null
  111452. * A physics vortex event or null
  111453. */
  111454. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  111455. }
  111456. /**
  111457. * Represents a physics radial explosion event
  111458. */
  111459. class PhysicsRadialExplosionEvent {
  111460. private _scene;
  111461. private _options;
  111462. private _sphere;
  111463. private _dataFetched;
  111464. /**
  111465. * Initializes a radial explosioin event
  111466. * @param _scene BabylonJS scene
  111467. * @param _options The options for the vortex event
  111468. */
  111469. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  111470. /**
  111471. * Returns the data related to the radial explosion event (sphere).
  111472. * @returns The radial explosion event data
  111473. */
  111474. getData(): PhysicsRadialExplosionEventData;
  111475. /**
  111476. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  111477. * @param impostor A physics imposter
  111478. * @param origin the origin of the explosion
  111479. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  111480. */
  111481. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  111482. /**
  111483. * Triggers affecterd impostors callbacks
  111484. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  111485. */
  111486. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  111487. /**
  111488. * Disposes the sphere.
  111489. * @param force Specifies if the sphere should be disposed by force
  111490. */
  111491. dispose(force?: boolean): void;
  111492. /*** Helpers ***/
  111493. private _prepareSphere;
  111494. private _intersectsWithSphere;
  111495. }
  111496. /**
  111497. * Represents a gravitational field event
  111498. */
  111499. class PhysicsGravitationalFieldEvent {
  111500. private _physicsHelper;
  111501. private _scene;
  111502. private _origin;
  111503. private _options;
  111504. private _tickCallback;
  111505. private _sphere;
  111506. private _dataFetched;
  111507. /**
  111508. * Initializes the physics gravitational field event
  111509. * @param _physicsHelper A physics helper
  111510. * @param _scene BabylonJS scene
  111511. * @param _origin The origin position of the gravitational field event
  111512. * @param _options The options for the vortex event
  111513. */
  111514. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  111515. /**
  111516. * Returns the data related to the gravitational field event (sphere).
  111517. * @returns A gravitational field event
  111518. */
  111519. getData(): PhysicsGravitationalFieldEventData;
  111520. /**
  111521. * Enables the gravitational field.
  111522. */
  111523. enable(): void;
  111524. /**
  111525. * Disables the gravitational field.
  111526. */
  111527. disable(): void;
  111528. /**
  111529. * Disposes the sphere.
  111530. * @param force The force to dispose from the gravitational field event
  111531. */
  111532. dispose(force?: boolean): void;
  111533. private _tick;
  111534. }
  111535. /**
  111536. * Represents a physics updraft event
  111537. */
  111538. class PhysicsUpdraftEvent {
  111539. private _scene;
  111540. private _origin;
  111541. private _options;
  111542. private _physicsEngine;
  111543. private _originTop;
  111544. private _originDirection;
  111545. private _tickCallback;
  111546. private _cylinder;
  111547. private _cylinderPosition;
  111548. private _dataFetched;
  111549. /**
  111550. * Initializes the physics updraft event
  111551. * @param _scene BabylonJS scene
  111552. * @param _origin The origin position of the updraft
  111553. * @param _options The options for the updraft event
  111554. */
  111555. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  111556. /**
  111557. * Returns the data related to the updraft event (cylinder).
  111558. * @returns A physics updraft event
  111559. */
  111560. getData(): PhysicsUpdraftEventData;
  111561. /**
  111562. * Enables the updraft.
  111563. */
  111564. enable(): void;
  111565. /**
  111566. * Disables the updraft.
  111567. */
  111568. disable(): void;
  111569. /**
  111570. * Disposes the cylinder.
  111571. * @param force Specifies if the updraft should be disposed by force
  111572. */
  111573. dispose(force?: boolean): void;
  111574. private getImpostorHitData;
  111575. private _tick;
  111576. /*** Helpers ***/
  111577. private _prepareCylinder;
  111578. private _intersectsWithCylinder;
  111579. }
  111580. /**
  111581. * Represents a physics vortex event
  111582. */
  111583. class PhysicsVortexEvent {
  111584. private _scene;
  111585. private _origin;
  111586. private _options;
  111587. private _physicsEngine;
  111588. private _originTop;
  111589. private _tickCallback;
  111590. private _cylinder;
  111591. private _cylinderPosition;
  111592. private _dataFetched;
  111593. /**
  111594. * Initializes the physics vortex event
  111595. * @param _scene The BabylonJS scene
  111596. * @param _origin The origin position of the vortex
  111597. * @param _options The options for the vortex event
  111598. */
  111599. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  111600. /**
  111601. * Returns the data related to the vortex event (cylinder).
  111602. * @returns The physics vortex event data
  111603. */
  111604. getData(): PhysicsVortexEventData;
  111605. /**
  111606. * Enables the vortex.
  111607. */
  111608. enable(): void;
  111609. /**
  111610. * Disables the cortex.
  111611. */
  111612. disable(): void;
  111613. /**
  111614. * Disposes the sphere.
  111615. * @param force
  111616. */
  111617. dispose(force?: boolean): void;
  111618. private getImpostorHitData;
  111619. private _tick;
  111620. /*** Helpers ***/
  111621. private _prepareCylinder;
  111622. private _intersectsWithCylinder;
  111623. }
  111624. /**
  111625. * Options fot the radial explosion event
  111626. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111627. */
  111628. export class PhysicsRadialExplosionEventOptions {
  111629. /**
  111630. * The radius of the sphere for the radial explosion.
  111631. */
  111632. radius: number;
  111633. /**
  111634. * The strenth of the explosion.
  111635. */
  111636. strength: number;
  111637. /**
  111638. * The strenght of the force in correspondence to the distance of the affected object
  111639. */
  111640. falloff: PhysicsRadialImpulseFalloff;
  111641. /**
  111642. * Sphere options for the radial explosion.
  111643. */
  111644. sphere: {
  111645. segments: number;
  111646. diameter: number;
  111647. };
  111648. /**
  111649. * Sphere options for the radial explosion.
  111650. */
  111651. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  111652. }
  111653. /**
  111654. * Options fot the updraft event
  111655. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111656. */
  111657. export class PhysicsUpdraftEventOptions {
  111658. /**
  111659. * The radius of the cylinder for the vortex
  111660. */
  111661. radius: number;
  111662. /**
  111663. * The strenth of the updraft.
  111664. */
  111665. strength: number;
  111666. /**
  111667. * The height of the cylinder for the updraft.
  111668. */
  111669. height: number;
  111670. /**
  111671. * The mode for the the updraft.
  111672. */
  111673. updraftMode: PhysicsUpdraftMode;
  111674. }
  111675. /**
  111676. * Options fot the vortex event
  111677. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111678. */
  111679. export class PhysicsVortexEventOptions {
  111680. /**
  111681. * The radius of the cylinder for the vortex
  111682. */
  111683. radius: number;
  111684. /**
  111685. * The strenth of the vortex.
  111686. */
  111687. strength: number;
  111688. /**
  111689. * The height of the cylinder for the vortex.
  111690. */
  111691. height: number;
  111692. /**
  111693. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  111694. */
  111695. centripetalForceThreshold: number;
  111696. /**
  111697. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  111698. */
  111699. centripetalForceMultiplier: number;
  111700. /**
  111701. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  111702. */
  111703. centrifugalForceMultiplier: number;
  111704. /**
  111705. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  111706. */
  111707. updraftForceMultiplier: number;
  111708. }
  111709. /**
  111710. * The strenght of the force in correspondence to the distance of the affected object
  111711. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111712. */
  111713. export enum PhysicsRadialImpulseFalloff {
  111714. /** Defines that impulse is constant in strength across it's whole radius */
  111715. Constant = 0,
  111716. /** Defines that impulse gets weaker if it's further from the origin */
  111717. Linear = 1
  111718. }
  111719. /**
  111720. * The strength of the force in correspondence to the distance of the affected object
  111721. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111722. */
  111723. export enum PhysicsUpdraftMode {
  111724. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  111725. Center = 0,
  111726. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  111727. Perpendicular = 1
  111728. }
  111729. /**
  111730. * Interface for a physics hit data
  111731. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111732. */
  111733. export interface PhysicsHitData {
  111734. /**
  111735. * The force applied at the contact point
  111736. */
  111737. force: Vector3;
  111738. /**
  111739. * The contact point
  111740. */
  111741. contactPoint: Vector3;
  111742. /**
  111743. * The distance from the origin to the contact point
  111744. */
  111745. distanceFromOrigin: number;
  111746. }
  111747. /**
  111748. * Interface for radial explosion event data
  111749. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111750. */
  111751. export interface PhysicsRadialExplosionEventData {
  111752. /**
  111753. * A sphere used for the radial explosion event
  111754. */
  111755. sphere: Mesh;
  111756. }
  111757. /**
  111758. * Interface for gravitational field event data
  111759. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111760. */
  111761. export interface PhysicsGravitationalFieldEventData {
  111762. /**
  111763. * A sphere mesh used for the gravitational field event
  111764. */
  111765. sphere: Mesh;
  111766. }
  111767. /**
  111768. * Interface for updraft event data
  111769. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111770. */
  111771. export interface PhysicsUpdraftEventData {
  111772. /**
  111773. * A cylinder used for the updraft event
  111774. */
  111775. cylinder: Mesh;
  111776. }
  111777. /**
  111778. * Interface for vortex event data
  111779. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111780. */
  111781. export interface PhysicsVortexEventData {
  111782. /**
  111783. * A cylinder used for the vortex event
  111784. */
  111785. cylinder: Mesh;
  111786. }
  111787. /**
  111788. * Interface for an affected physics impostor
  111789. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111790. */
  111791. export interface PhysicsAffectedImpostorWithData {
  111792. /**
  111793. * The impostor affected by the effect
  111794. */
  111795. impostor: PhysicsImpostor;
  111796. /**
  111797. * The data about the hit/horce from the explosion
  111798. */
  111799. hitData: PhysicsHitData;
  111800. }
  111801. }
  111802. declare module BABYLON {
  111803. /** @hidden */
  111804. export var blackAndWhitePixelShader: {
  111805. name: string;
  111806. shader: string;
  111807. };
  111808. }
  111809. declare module BABYLON {
  111810. /**
  111811. * Post process used to render in black and white
  111812. */
  111813. export class BlackAndWhitePostProcess extends PostProcess {
  111814. /**
  111815. * Linear about to convert he result to black and white (default: 1)
  111816. */
  111817. degree: number;
  111818. /**
  111819. * Creates a black and white post process
  111820. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  111821. * @param name The name of the effect.
  111822. * @param options The required width/height ratio to downsize to before computing the render pass.
  111823. * @param camera The camera to apply the render pass to.
  111824. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111825. * @param engine The engine which the post process will be applied. (default: current engine)
  111826. * @param reusable If the post process can be reused on the same frame. (default: false)
  111827. */
  111828. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111829. }
  111830. }
  111831. declare module BABYLON {
  111832. /**
  111833. * This represents a set of one or more post processes in Babylon.
  111834. * A post process can be used to apply a shader to a texture after it is rendered.
  111835. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  111836. */
  111837. export class PostProcessRenderEffect {
  111838. private _postProcesses;
  111839. private _getPostProcesses;
  111840. private _singleInstance;
  111841. private _cameras;
  111842. private _indicesForCamera;
  111843. /**
  111844. * Name of the effect
  111845. * @hidden
  111846. */
  111847. _name: string;
  111848. /**
  111849. * Instantiates a post process render effect.
  111850. * A post process can be used to apply a shader to a texture after it is rendered.
  111851. * @param engine The engine the effect is tied to
  111852. * @param name The name of the effect
  111853. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  111854. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  111855. */
  111856. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  111857. /**
  111858. * Checks if all the post processes in the effect are supported.
  111859. */
  111860. readonly isSupported: boolean;
  111861. /**
  111862. * Updates the current state of the effect
  111863. * @hidden
  111864. */
  111865. _update(): void;
  111866. /**
  111867. * Attaches the effect on cameras
  111868. * @param cameras The camera to attach to.
  111869. * @hidden
  111870. */
  111871. _attachCameras(cameras: Camera): void;
  111872. /**
  111873. * Attaches the effect on cameras
  111874. * @param cameras The camera to attach to.
  111875. * @hidden
  111876. */
  111877. _attachCameras(cameras: Camera[]): void;
  111878. /**
  111879. * Detaches the effect on cameras
  111880. * @param cameras The camera to detatch from.
  111881. * @hidden
  111882. */
  111883. _detachCameras(cameras: Camera): void;
  111884. /**
  111885. * Detatches the effect on cameras
  111886. * @param cameras The camera to detatch from.
  111887. * @hidden
  111888. */
  111889. _detachCameras(cameras: Camera[]): void;
  111890. /**
  111891. * Enables the effect on given cameras
  111892. * @param cameras The camera to enable.
  111893. * @hidden
  111894. */
  111895. _enable(cameras: Camera): void;
  111896. /**
  111897. * Enables the effect on given cameras
  111898. * @param cameras The camera to enable.
  111899. * @hidden
  111900. */
  111901. _enable(cameras: Nullable<Camera[]>): void;
  111902. /**
  111903. * Disables the effect on the given cameras
  111904. * @param cameras The camera to disable.
  111905. * @hidden
  111906. */
  111907. _disable(cameras: Camera): void;
  111908. /**
  111909. * Disables the effect on the given cameras
  111910. * @param cameras The camera to disable.
  111911. * @hidden
  111912. */
  111913. _disable(cameras: Nullable<Camera[]>): void;
  111914. /**
  111915. * Gets a list of the post processes contained in the effect.
  111916. * @param camera The camera to get the post processes on.
  111917. * @returns The list of the post processes in the effect.
  111918. */
  111919. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  111920. }
  111921. }
  111922. declare module BABYLON {
  111923. /** @hidden */
  111924. export var extractHighlightsPixelShader: {
  111925. name: string;
  111926. shader: string;
  111927. };
  111928. }
  111929. declare module BABYLON {
  111930. /**
  111931. * 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.
  111932. */
  111933. export class ExtractHighlightsPostProcess extends PostProcess {
  111934. /**
  111935. * The luminance threshold, pixels below this value will be set to black.
  111936. */
  111937. threshold: number;
  111938. /** @hidden */
  111939. _exposure: number;
  111940. /**
  111941. * Post process which has the input texture to be used when performing highlight extraction
  111942. * @hidden
  111943. */
  111944. _inputPostProcess: Nullable<PostProcess>;
  111945. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111946. }
  111947. }
  111948. declare module BABYLON {
  111949. /** @hidden */
  111950. export var bloomMergePixelShader: {
  111951. name: string;
  111952. shader: string;
  111953. };
  111954. }
  111955. declare module BABYLON {
  111956. /**
  111957. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  111958. */
  111959. export class BloomMergePostProcess extends PostProcess {
  111960. /** Weight of the bloom to be added to the original input. */
  111961. weight: number;
  111962. /**
  111963. * Creates a new instance of @see BloomMergePostProcess
  111964. * @param name The name of the effect.
  111965. * @param originalFromInput Post process which's input will be used for the merge.
  111966. * @param blurred Blurred highlights post process which's output will be used.
  111967. * @param weight Weight of the bloom to be added to the original input.
  111968. * @param options The required width/height ratio to downsize to before computing the render pass.
  111969. * @param camera The camera to apply the render pass to.
  111970. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111971. * @param engine The engine which the post process will be applied. (default: current engine)
  111972. * @param reusable If the post process can be reused on the same frame. (default: false)
  111973. * @param textureType Type of textures used when performing the post process. (default: 0)
  111974. * @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)
  111975. */
  111976. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  111977. /** Weight of the bloom to be added to the original input. */
  111978. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111979. }
  111980. }
  111981. declare module BABYLON {
  111982. /**
  111983. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  111984. */
  111985. export class BloomEffect extends PostProcessRenderEffect {
  111986. private bloomScale;
  111987. /**
  111988. * @hidden Internal
  111989. */
  111990. _effects: Array<PostProcess>;
  111991. /**
  111992. * @hidden Internal
  111993. */
  111994. _downscale: ExtractHighlightsPostProcess;
  111995. private _blurX;
  111996. private _blurY;
  111997. private _merge;
  111998. /**
  111999. * The luminance threshold to find bright areas of the image to bloom.
  112000. */
  112001. threshold: number;
  112002. /**
  112003. * The strength of the bloom.
  112004. */
  112005. weight: number;
  112006. /**
  112007. * Specifies the size of the bloom blur kernel, relative to the final output size
  112008. */
  112009. kernel: number;
  112010. /**
  112011. * Creates a new instance of @see BloomEffect
  112012. * @param scene The scene the effect belongs to.
  112013. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  112014. * @param bloomKernel The size of the kernel to be used when applying the blur.
  112015. * @param bloomWeight The the strength of bloom.
  112016. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  112017. * @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)
  112018. */
  112019. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  112020. /**
  112021. * Disposes each of the internal effects for a given camera.
  112022. * @param camera The camera to dispose the effect on.
  112023. */
  112024. disposeEffects(camera: Camera): void;
  112025. /**
  112026. * @hidden Internal
  112027. */
  112028. _updateEffects(): void;
  112029. /**
  112030. * Internal
  112031. * @returns if all the contained post processes are ready.
  112032. * @hidden
  112033. */
  112034. _isReady(): boolean;
  112035. }
  112036. }
  112037. declare module BABYLON {
  112038. /** @hidden */
  112039. export var chromaticAberrationPixelShader: {
  112040. name: string;
  112041. shader: string;
  112042. };
  112043. }
  112044. declare module BABYLON {
  112045. /**
  112046. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  112047. */
  112048. export class ChromaticAberrationPostProcess extends PostProcess {
  112049. /**
  112050. * The amount of seperation of rgb channels (default: 30)
  112051. */
  112052. aberrationAmount: number;
  112053. /**
  112054. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  112055. */
  112056. radialIntensity: number;
  112057. /**
  112058. * 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))
  112059. */
  112060. direction: Vector2;
  112061. /**
  112062. * 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))
  112063. */
  112064. centerPosition: Vector2;
  112065. /**
  112066. * Creates a new instance ChromaticAberrationPostProcess
  112067. * @param name The name of the effect.
  112068. * @param screenWidth The width of the screen to apply the effect on.
  112069. * @param screenHeight The height of the screen to apply the effect on.
  112070. * @param options The required width/height ratio to downsize to before computing the render pass.
  112071. * @param camera The camera to apply the render pass to.
  112072. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112073. * @param engine The engine which the post process will be applied. (default: current engine)
  112074. * @param reusable If the post process can be reused on the same frame. (default: false)
  112075. * @param textureType Type of textures used when performing the post process. (default: 0)
  112076. * @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)
  112077. */
  112078. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112079. }
  112080. }
  112081. declare module BABYLON {
  112082. /** @hidden */
  112083. export var circleOfConfusionPixelShader: {
  112084. name: string;
  112085. shader: string;
  112086. };
  112087. }
  112088. declare module BABYLON {
  112089. /**
  112090. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  112091. */
  112092. export class CircleOfConfusionPostProcess extends PostProcess {
  112093. /**
  112094. * 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.
  112095. */
  112096. lensSize: number;
  112097. /**
  112098. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  112099. */
  112100. fStop: number;
  112101. /**
  112102. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  112103. */
  112104. focusDistance: number;
  112105. /**
  112106. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  112107. */
  112108. focalLength: number;
  112109. private _depthTexture;
  112110. /**
  112111. * Creates a new instance CircleOfConfusionPostProcess
  112112. * @param name The name of the effect.
  112113. * @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.
  112114. * @param options The required width/height ratio to downsize to before computing the render pass.
  112115. * @param camera The camera to apply the render pass to.
  112116. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112117. * @param engine The engine which the post process will be applied. (default: current engine)
  112118. * @param reusable If the post process can be reused on the same frame. (default: false)
  112119. * @param textureType Type of textures used when performing the post process. (default: 0)
  112120. * @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)
  112121. */
  112122. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112123. /**
  112124. * 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.
  112125. */
  112126. depthTexture: RenderTargetTexture;
  112127. }
  112128. }
  112129. declare module BABYLON {
  112130. /** @hidden */
  112131. export var colorCorrectionPixelShader: {
  112132. name: string;
  112133. shader: string;
  112134. };
  112135. }
  112136. declare module BABYLON {
  112137. /**
  112138. *
  112139. * This post-process allows the modification of rendered colors by using
  112140. * a 'look-up table' (LUT). This effect is also called Color Grading.
  112141. *
  112142. * The object needs to be provided an url to a texture containing the color
  112143. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  112144. * Use an image editing software to tweak the LUT to match your needs.
  112145. *
  112146. * For an example of a color LUT, see here:
  112147. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  112148. * For explanations on color grading, see here:
  112149. * @see http://udn.epicgames.com/Three/ColorGrading.html
  112150. *
  112151. */
  112152. export class ColorCorrectionPostProcess extends PostProcess {
  112153. private _colorTableTexture;
  112154. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112155. }
  112156. }
  112157. declare module BABYLON {
  112158. /** @hidden */
  112159. export var convolutionPixelShader: {
  112160. name: string;
  112161. shader: string;
  112162. };
  112163. }
  112164. declare module BABYLON {
  112165. /**
  112166. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  112167. * input texture to perform effects such as edge detection or sharpening
  112168. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  112169. */
  112170. export class ConvolutionPostProcess extends PostProcess {
  112171. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  112172. kernel: number[];
  112173. /**
  112174. * Creates a new instance ConvolutionPostProcess
  112175. * @param name The name of the effect.
  112176. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  112177. * @param options The required width/height ratio to downsize to before computing the render pass.
  112178. * @param camera The camera to apply the render pass to.
  112179. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112180. * @param engine The engine which the post process will be applied. (default: current engine)
  112181. * @param reusable If the post process can be reused on the same frame. (default: false)
  112182. * @param textureType Type of textures used when performing the post process. (default: 0)
  112183. */
  112184. constructor(name: string,
  112185. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  112186. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112187. /**
  112188. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112189. */
  112190. static EdgeDetect0Kernel: number[];
  112191. /**
  112192. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112193. */
  112194. static EdgeDetect1Kernel: number[];
  112195. /**
  112196. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112197. */
  112198. static EdgeDetect2Kernel: number[];
  112199. /**
  112200. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112201. */
  112202. static SharpenKernel: number[];
  112203. /**
  112204. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112205. */
  112206. static EmbossKernel: number[];
  112207. /**
  112208. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112209. */
  112210. static GaussianKernel: number[];
  112211. }
  112212. }
  112213. declare module BABYLON {
  112214. /**
  112215. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  112216. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  112217. * based on samples that have a large difference in distance than the center pixel.
  112218. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  112219. */
  112220. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  112221. direction: Vector2;
  112222. /**
  112223. * Creates a new instance CircleOfConfusionPostProcess
  112224. * @param name The name of the effect.
  112225. * @param scene The scene the effect belongs to.
  112226. * @param direction The direction the blur should be applied.
  112227. * @param kernel The size of the kernel used to blur.
  112228. * @param options The required width/height ratio to downsize to before computing the render pass.
  112229. * @param camera The camera to apply the render pass to.
  112230. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  112231. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  112232. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112233. * @param engine The engine which the post process will be applied. (default: current engine)
  112234. * @param reusable If the post process can be reused on the same frame. (default: false)
  112235. * @param textureType Type of textures used when performing the post process. (default: 0)
  112236. * @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)
  112237. */
  112238. 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);
  112239. }
  112240. }
  112241. declare module BABYLON {
  112242. /** @hidden */
  112243. export var depthOfFieldMergePixelShader: {
  112244. name: string;
  112245. shader: string;
  112246. };
  112247. }
  112248. declare module BABYLON {
  112249. /**
  112250. * Options to be set when merging outputs from the default pipeline.
  112251. */
  112252. export class DepthOfFieldMergePostProcessOptions {
  112253. /**
  112254. * The original image to merge on top of
  112255. */
  112256. originalFromInput: PostProcess;
  112257. /**
  112258. * Parameters to perform the merge of the depth of field effect
  112259. */
  112260. depthOfField?: {
  112261. circleOfConfusion: PostProcess;
  112262. blurSteps: Array<PostProcess>;
  112263. };
  112264. /**
  112265. * Parameters to perform the merge of bloom effect
  112266. */
  112267. bloom?: {
  112268. blurred: PostProcess;
  112269. weight: number;
  112270. };
  112271. }
  112272. /**
  112273. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  112274. */
  112275. export class DepthOfFieldMergePostProcess extends PostProcess {
  112276. private blurSteps;
  112277. /**
  112278. * Creates a new instance of DepthOfFieldMergePostProcess
  112279. * @param name The name of the effect.
  112280. * @param originalFromInput Post process which's input will be used for the merge.
  112281. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  112282. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  112283. * @param options The required width/height ratio to downsize to before computing the render pass.
  112284. * @param camera The camera to apply the render pass to.
  112285. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112286. * @param engine The engine which the post process will be applied. (default: current engine)
  112287. * @param reusable If the post process can be reused on the same frame. (default: false)
  112288. * @param textureType Type of textures used when performing the post process. (default: 0)
  112289. * @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)
  112290. */
  112291. 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);
  112292. /**
  112293. * Updates the effect with the current post process compile time values and recompiles the shader.
  112294. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  112295. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  112296. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  112297. * @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
  112298. * @param onCompiled Called when the shader has been compiled.
  112299. * @param onError Called if there is an error when compiling a shader.
  112300. */
  112301. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  112302. }
  112303. }
  112304. declare module BABYLON {
  112305. /**
  112306. * Specifies the level of max blur that should be applied when using the depth of field effect
  112307. */
  112308. export enum DepthOfFieldEffectBlurLevel {
  112309. /**
  112310. * Subtle blur
  112311. */
  112312. Low = 0,
  112313. /**
  112314. * Medium blur
  112315. */
  112316. Medium = 1,
  112317. /**
  112318. * Large blur
  112319. */
  112320. High = 2
  112321. }
  112322. /**
  112323. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  112324. */
  112325. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  112326. private _circleOfConfusion;
  112327. /**
  112328. * @hidden Internal, blurs from high to low
  112329. */
  112330. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  112331. private _depthOfFieldBlurY;
  112332. private _dofMerge;
  112333. /**
  112334. * @hidden Internal post processes in depth of field effect
  112335. */
  112336. _effects: Array<PostProcess>;
  112337. /**
  112338. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  112339. */
  112340. focalLength: number;
  112341. /**
  112342. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  112343. */
  112344. fStop: number;
  112345. /**
  112346. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  112347. */
  112348. focusDistance: number;
  112349. /**
  112350. * 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.
  112351. */
  112352. lensSize: number;
  112353. /**
  112354. * Creates a new instance DepthOfFieldEffect
  112355. * @param scene The scene the effect belongs to.
  112356. * @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.
  112357. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  112358. * @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)
  112359. */
  112360. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  112361. /**
  112362. * Get the current class name of the current effet
  112363. * @returns "DepthOfFieldEffect"
  112364. */
  112365. getClassName(): string;
  112366. /**
  112367. * 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.
  112368. */
  112369. depthTexture: RenderTargetTexture;
  112370. /**
  112371. * Disposes each of the internal effects for a given camera.
  112372. * @param camera The camera to dispose the effect on.
  112373. */
  112374. disposeEffects(camera: Camera): void;
  112375. /**
  112376. * @hidden Internal
  112377. */
  112378. _updateEffects(): void;
  112379. /**
  112380. * Internal
  112381. * @returns if all the contained post processes are ready.
  112382. * @hidden
  112383. */
  112384. _isReady(): boolean;
  112385. }
  112386. }
  112387. declare module BABYLON {
  112388. /** @hidden */
  112389. export var displayPassPixelShader: {
  112390. name: string;
  112391. shader: string;
  112392. };
  112393. }
  112394. declare module BABYLON {
  112395. /**
  112396. * DisplayPassPostProcess which produces an output the same as it's input
  112397. */
  112398. export class DisplayPassPostProcess extends PostProcess {
  112399. /**
  112400. * Creates the DisplayPassPostProcess
  112401. * @param name The name of the effect.
  112402. * @param options The required width/height ratio to downsize to before computing the render pass.
  112403. * @param camera The camera to apply the render pass to.
  112404. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112405. * @param engine The engine which the post process will be applied. (default: current engine)
  112406. * @param reusable If the post process can be reused on the same frame. (default: false)
  112407. */
  112408. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112409. }
  112410. }
  112411. declare module BABYLON {
  112412. /** @hidden */
  112413. export var filterPixelShader: {
  112414. name: string;
  112415. shader: string;
  112416. };
  112417. }
  112418. declare module BABYLON {
  112419. /**
  112420. * Applies a kernel filter to the image
  112421. */
  112422. export class FilterPostProcess extends PostProcess {
  112423. /** The matrix to be applied to the image */
  112424. kernelMatrix: Matrix;
  112425. /**
  112426. *
  112427. * @param name The name of the effect.
  112428. * @param kernelMatrix The matrix to be applied to the image
  112429. * @param options The required width/height ratio to downsize to before computing the render pass.
  112430. * @param camera The camera to apply the render pass to.
  112431. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112432. * @param engine The engine which the post process will be applied. (default: current engine)
  112433. * @param reusable If the post process can be reused on the same frame. (default: false)
  112434. */
  112435. constructor(name: string,
  112436. /** The matrix to be applied to the image */
  112437. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112438. }
  112439. }
  112440. declare module BABYLON {
  112441. /** @hidden */
  112442. export var fxaaPixelShader: {
  112443. name: string;
  112444. shader: string;
  112445. };
  112446. }
  112447. declare module BABYLON {
  112448. /** @hidden */
  112449. export var fxaaVertexShader: {
  112450. name: string;
  112451. shader: string;
  112452. };
  112453. }
  112454. declare module BABYLON {
  112455. /**
  112456. * Fxaa post process
  112457. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  112458. */
  112459. export class FxaaPostProcess extends PostProcess {
  112460. /** @hidden */
  112461. texelWidth: number;
  112462. /** @hidden */
  112463. texelHeight: number;
  112464. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112465. private _getDefines;
  112466. }
  112467. }
  112468. declare module BABYLON {
  112469. /** @hidden */
  112470. export var grainPixelShader: {
  112471. name: string;
  112472. shader: string;
  112473. };
  112474. }
  112475. declare module BABYLON {
  112476. /**
  112477. * The GrainPostProcess adds noise to the image at mid luminance levels
  112478. */
  112479. export class GrainPostProcess extends PostProcess {
  112480. /**
  112481. * The intensity of the grain added (default: 30)
  112482. */
  112483. intensity: number;
  112484. /**
  112485. * If the grain should be randomized on every frame
  112486. */
  112487. animated: boolean;
  112488. /**
  112489. * Creates a new instance of @see GrainPostProcess
  112490. * @param name The name of the effect.
  112491. * @param options The required width/height ratio to downsize to before computing the render pass.
  112492. * @param camera The camera to apply the render pass to.
  112493. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112494. * @param engine The engine which the post process will be applied. (default: current engine)
  112495. * @param reusable If the post process can be reused on the same frame. (default: false)
  112496. * @param textureType Type of textures used when performing the post process. (default: 0)
  112497. * @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)
  112498. */
  112499. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112500. }
  112501. }
  112502. declare module BABYLON {
  112503. /** @hidden */
  112504. export var highlightsPixelShader: {
  112505. name: string;
  112506. shader: string;
  112507. };
  112508. }
  112509. declare module BABYLON {
  112510. /**
  112511. * Extracts highlights from the image
  112512. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  112513. */
  112514. export class HighlightsPostProcess extends PostProcess {
  112515. /**
  112516. * Extracts highlights from the image
  112517. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  112518. * @param name The name of the effect.
  112519. * @param options The required width/height ratio to downsize to before computing the render pass.
  112520. * @param camera The camera to apply the render pass to.
  112521. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112522. * @param engine The engine which the post process will be applied. (default: current engine)
  112523. * @param reusable If the post process can be reused on the same frame. (default: false)
  112524. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  112525. */
  112526. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112527. }
  112528. }
  112529. declare module BABYLON {
  112530. /** @hidden */
  112531. export var mrtFragmentDeclaration: {
  112532. name: string;
  112533. shader: string;
  112534. };
  112535. }
  112536. declare module BABYLON {
  112537. /** @hidden */
  112538. export var geometryPixelShader: {
  112539. name: string;
  112540. shader: string;
  112541. };
  112542. }
  112543. declare module BABYLON {
  112544. /** @hidden */
  112545. export var geometryVertexShader: {
  112546. name: string;
  112547. shader: string;
  112548. };
  112549. }
  112550. declare module BABYLON {
  112551. /**
  112552. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  112553. */
  112554. export class GeometryBufferRenderer {
  112555. /**
  112556. * Constant used to retrieve the position texture index in the G-Buffer textures array
  112557. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  112558. */
  112559. static readonly POSITION_TEXTURE_TYPE: number;
  112560. /**
  112561. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  112562. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  112563. */
  112564. static readonly VELOCITY_TEXTURE_TYPE: number;
  112565. /**
  112566. * Dictionary used to store the previous transformation matrices of each rendered mesh
  112567. * in order to compute objects velocities when enableVelocity is set to "true"
  112568. * @hidden
  112569. */
  112570. _previousTransformationMatrices: {
  112571. [index: number]: Matrix;
  112572. };
  112573. private _scene;
  112574. private _multiRenderTarget;
  112575. private _ratio;
  112576. private _enablePosition;
  112577. private _enableVelocity;
  112578. private _positionIndex;
  112579. private _velocityIndex;
  112580. protected _effect: Effect;
  112581. protected _cachedDefines: string;
  112582. /**
  112583. * Set the render list (meshes to be rendered) used in the G buffer.
  112584. */
  112585. renderList: Mesh[];
  112586. /**
  112587. * Gets wether or not G buffer are supported by the running hardware.
  112588. * This requires draw buffer supports
  112589. */
  112590. readonly isSupported: boolean;
  112591. /**
  112592. * Returns the index of the given texture type in the G-Buffer textures array
  112593. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  112594. * @returns the index of the given texture type in the G-Buffer textures array
  112595. */
  112596. getTextureIndex(textureType: number): number;
  112597. /**
  112598. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  112599. */
  112600. /**
  112601. * Sets whether or not objects positions are enabled for the G buffer.
  112602. */
  112603. enablePosition: boolean;
  112604. /**
  112605. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  112606. */
  112607. /**
  112608. * Sets wether or not objects velocities are enabled for the G buffer.
  112609. */
  112610. enableVelocity: boolean;
  112611. /**
  112612. * Gets the scene associated with the buffer.
  112613. */
  112614. readonly scene: Scene;
  112615. /**
  112616. * Gets the ratio used by the buffer during its creation.
  112617. * How big is the buffer related to the main canvas.
  112618. */
  112619. readonly ratio: number;
  112620. /** @hidden */
  112621. static _SceneComponentInitialization: (scene: Scene) => void;
  112622. /**
  112623. * Creates a new G Buffer for the scene
  112624. * @param scene The scene the buffer belongs to
  112625. * @param ratio How big is the buffer related to the main canvas.
  112626. */
  112627. constructor(scene: Scene, ratio?: number);
  112628. /**
  112629. * Checks wether everything is ready to render a submesh to the G buffer.
  112630. * @param subMesh the submesh to check readiness for
  112631. * @param useInstances is the mesh drawn using instance or not
  112632. * @returns true if ready otherwise false
  112633. */
  112634. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112635. /**
  112636. * Gets the current underlying G Buffer.
  112637. * @returns the buffer
  112638. */
  112639. getGBuffer(): MultiRenderTarget;
  112640. /**
  112641. * Gets the number of samples used to render the buffer (anti aliasing).
  112642. */
  112643. /**
  112644. * Sets the number of samples used to render the buffer (anti aliasing).
  112645. */
  112646. samples: number;
  112647. /**
  112648. * Disposes the renderer and frees up associated resources.
  112649. */
  112650. dispose(): void;
  112651. protected _createRenderTargets(): void;
  112652. }
  112653. }
  112654. declare module BABYLON {
  112655. interface Scene {
  112656. /** @hidden (Backing field) */
  112657. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  112658. /**
  112659. * Gets or Sets the current geometry buffer associated to the scene.
  112660. */
  112661. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  112662. /**
  112663. * Enables a GeometryBufferRender and associates it with the scene
  112664. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  112665. * @returns the GeometryBufferRenderer
  112666. */
  112667. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  112668. /**
  112669. * Disables the GeometryBufferRender associated with the scene
  112670. */
  112671. disableGeometryBufferRenderer(): void;
  112672. }
  112673. /**
  112674. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  112675. * in several rendering techniques.
  112676. */
  112677. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  112678. /**
  112679. * The component name helpful to identify the component in the list of scene components.
  112680. */
  112681. readonly name: string;
  112682. /**
  112683. * The scene the component belongs to.
  112684. */
  112685. scene: Scene;
  112686. /**
  112687. * Creates a new instance of the component for the given scene
  112688. * @param scene Defines the scene to register the component in
  112689. */
  112690. constructor(scene: Scene);
  112691. /**
  112692. * Registers the component in a given scene
  112693. */
  112694. register(): void;
  112695. /**
  112696. * Rebuilds the elements related to this component in case of
  112697. * context lost for instance.
  112698. */
  112699. rebuild(): void;
  112700. /**
  112701. * Disposes the component and the associated ressources
  112702. */
  112703. dispose(): void;
  112704. private _gatherRenderTargets;
  112705. }
  112706. }
  112707. declare module BABYLON {
  112708. /** @hidden */
  112709. export var motionBlurPixelShader: {
  112710. name: string;
  112711. shader: string;
  112712. };
  112713. }
  112714. declare module BABYLON {
  112715. /**
  112716. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  112717. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  112718. * As an example, all you have to do is to create the post-process:
  112719. * var mb = new BABYLON.MotionBlurPostProcess(
  112720. * 'mb', // The name of the effect.
  112721. * scene, // The scene containing the objects to blur according to their velocity.
  112722. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  112723. * camera // The camera to apply the render pass to.
  112724. * );
  112725. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  112726. */
  112727. export class MotionBlurPostProcess extends PostProcess {
  112728. /**
  112729. * Defines how much the image is blurred by the movement. Default value is equal to 1
  112730. */
  112731. motionStrength: number;
  112732. /**
  112733. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  112734. */
  112735. /**
  112736. * Sets the number of iterations to be used for motion blur quality
  112737. */
  112738. motionBlurSamples: number;
  112739. private _motionBlurSamples;
  112740. private _geometryBufferRenderer;
  112741. /**
  112742. * Creates a new instance MotionBlurPostProcess
  112743. * @param name The name of the effect.
  112744. * @param scene The scene containing the objects to blur according to their velocity.
  112745. * @param options The required width/height ratio to downsize to before computing the render pass.
  112746. * @param camera The camera to apply the render pass to.
  112747. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112748. * @param engine The engine which the post process will be applied. (default: current engine)
  112749. * @param reusable If the post process can be reused on the same frame. (default: false)
  112750. * @param textureType Type of textures used when performing the post process. (default: 0)
  112751. * @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)
  112752. */
  112753. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112754. /**
  112755. * Disposes the post process.
  112756. * @param camera The camera to dispose the post process on.
  112757. */
  112758. dispose(camera?: Camera): void;
  112759. }
  112760. }
  112761. declare module BABYLON {
  112762. /** @hidden */
  112763. export var refractionPixelShader: {
  112764. name: string;
  112765. shader: string;
  112766. };
  112767. }
  112768. declare module BABYLON {
  112769. /**
  112770. * Post process which applies a refractin texture
  112771. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  112772. */
  112773. export class RefractionPostProcess extends PostProcess {
  112774. /** the base color of the refraction (used to taint the rendering) */
  112775. color: Color3;
  112776. /** simulated refraction depth */
  112777. depth: number;
  112778. /** the coefficient of the base color (0 to remove base color tainting) */
  112779. colorLevel: number;
  112780. private _refTexture;
  112781. private _ownRefractionTexture;
  112782. /**
  112783. * Gets or sets the refraction texture
  112784. * Please note that you are responsible for disposing the texture if you set it manually
  112785. */
  112786. refractionTexture: Texture;
  112787. /**
  112788. * Initializes the RefractionPostProcess
  112789. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  112790. * @param name The name of the effect.
  112791. * @param refractionTextureUrl Url of the refraction texture to use
  112792. * @param color the base color of the refraction (used to taint the rendering)
  112793. * @param depth simulated refraction depth
  112794. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  112795. * @param camera The camera to apply the render pass to.
  112796. * @param options The required width/height ratio to downsize to before computing the render pass.
  112797. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112798. * @param engine The engine which the post process will be applied. (default: current engine)
  112799. * @param reusable If the post process can be reused on the same frame. (default: false)
  112800. */
  112801. constructor(name: string, refractionTextureUrl: string,
  112802. /** the base color of the refraction (used to taint the rendering) */
  112803. color: Color3,
  112804. /** simulated refraction depth */
  112805. depth: number,
  112806. /** the coefficient of the base color (0 to remove base color tainting) */
  112807. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112808. /**
  112809. * Disposes of the post process
  112810. * @param camera Camera to dispose post process on
  112811. */
  112812. dispose(camera: Camera): void;
  112813. }
  112814. }
  112815. declare module BABYLON {
  112816. /** @hidden */
  112817. export var sharpenPixelShader: {
  112818. name: string;
  112819. shader: string;
  112820. };
  112821. }
  112822. declare module BABYLON {
  112823. /**
  112824. * The SharpenPostProcess applies a sharpen kernel to every pixel
  112825. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  112826. */
  112827. export class SharpenPostProcess extends PostProcess {
  112828. /**
  112829. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  112830. */
  112831. colorAmount: number;
  112832. /**
  112833. * How much sharpness should be applied (default: 0.3)
  112834. */
  112835. edgeAmount: number;
  112836. /**
  112837. * Creates a new instance ConvolutionPostProcess
  112838. * @param name The name of the effect.
  112839. * @param options The required width/height ratio to downsize to before computing the render pass.
  112840. * @param camera The camera to apply the render pass to.
  112841. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112842. * @param engine The engine which the post process will be applied. (default: current engine)
  112843. * @param reusable If the post process can be reused on the same frame. (default: false)
  112844. * @param textureType Type of textures used when performing the post process. (default: 0)
  112845. * @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)
  112846. */
  112847. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112848. }
  112849. }
  112850. declare module BABYLON {
  112851. /**
  112852. * PostProcessRenderPipeline
  112853. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112854. */
  112855. export class PostProcessRenderPipeline {
  112856. private engine;
  112857. private _renderEffects;
  112858. private _renderEffectsForIsolatedPass;
  112859. /**
  112860. * List of inspectable custom properties (used by the Inspector)
  112861. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  112862. */
  112863. inspectableCustomProperties: IInspectable[];
  112864. /**
  112865. * @hidden
  112866. */
  112867. protected _cameras: Camera[];
  112868. /** @hidden */
  112869. _name: string;
  112870. /**
  112871. * Gets pipeline name
  112872. */
  112873. readonly name: string;
  112874. /**
  112875. * Initializes a PostProcessRenderPipeline
  112876. * @param engine engine to add the pipeline to
  112877. * @param name name of the pipeline
  112878. */
  112879. constructor(engine: Engine, name: string);
  112880. /**
  112881. * Gets the class name
  112882. * @returns "PostProcessRenderPipeline"
  112883. */
  112884. getClassName(): string;
  112885. /**
  112886. * If all the render effects in the pipeline are supported
  112887. */
  112888. readonly isSupported: boolean;
  112889. /**
  112890. * Adds an effect to the pipeline
  112891. * @param renderEffect the effect to add
  112892. */
  112893. addEffect(renderEffect: PostProcessRenderEffect): void;
  112894. /** @hidden */
  112895. _rebuild(): void;
  112896. /** @hidden */
  112897. _enableEffect(renderEffectName: string, cameras: Camera): void;
  112898. /** @hidden */
  112899. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  112900. /** @hidden */
  112901. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  112902. /** @hidden */
  112903. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  112904. /** @hidden */
  112905. _attachCameras(cameras: Camera, unique: boolean): void;
  112906. /** @hidden */
  112907. _attachCameras(cameras: Camera[], unique: boolean): void;
  112908. /** @hidden */
  112909. _detachCameras(cameras: Camera): void;
  112910. /** @hidden */
  112911. _detachCameras(cameras: Nullable<Camera[]>): void;
  112912. /** @hidden */
  112913. _update(): void;
  112914. /** @hidden */
  112915. _reset(): void;
  112916. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  112917. /**
  112918. * Disposes of the pipeline
  112919. */
  112920. dispose(): void;
  112921. }
  112922. }
  112923. declare module BABYLON {
  112924. /**
  112925. * PostProcessRenderPipelineManager class
  112926. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112927. */
  112928. export class PostProcessRenderPipelineManager {
  112929. private _renderPipelines;
  112930. /**
  112931. * Initializes a PostProcessRenderPipelineManager
  112932. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112933. */
  112934. constructor();
  112935. /**
  112936. * Gets the list of supported render pipelines
  112937. */
  112938. readonly supportedPipelines: PostProcessRenderPipeline[];
  112939. /**
  112940. * Adds a pipeline to the manager
  112941. * @param renderPipeline The pipeline to add
  112942. */
  112943. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  112944. /**
  112945. * Attaches a camera to the pipeline
  112946. * @param renderPipelineName The name of the pipeline to attach to
  112947. * @param cameras the camera to attach
  112948. * @param unique if the camera can be attached multiple times to the pipeline
  112949. */
  112950. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  112951. /**
  112952. * Detaches a camera from the pipeline
  112953. * @param renderPipelineName The name of the pipeline to detach from
  112954. * @param cameras the camera to detach
  112955. */
  112956. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  112957. /**
  112958. * Enables an effect by name on a pipeline
  112959. * @param renderPipelineName the name of the pipeline to enable the effect in
  112960. * @param renderEffectName the name of the effect to enable
  112961. * @param cameras the cameras that the effect should be enabled on
  112962. */
  112963. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  112964. /**
  112965. * Disables an effect by name on a pipeline
  112966. * @param renderPipelineName the name of the pipeline to disable the effect in
  112967. * @param renderEffectName the name of the effect to disable
  112968. * @param cameras the cameras that the effect should be disabled on
  112969. */
  112970. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  112971. /**
  112972. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  112973. */
  112974. update(): void;
  112975. /** @hidden */
  112976. _rebuild(): void;
  112977. /**
  112978. * Disposes of the manager and pipelines
  112979. */
  112980. dispose(): void;
  112981. }
  112982. }
  112983. declare module BABYLON {
  112984. interface Scene {
  112985. /** @hidden (Backing field) */
  112986. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  112987. /**
  112988. * Gets the postprocess render pipeline manager
  112989. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112990. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  112991. */
  112992. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  112993. }
  112994. /**
  112995. * Defines the Render Pipeline scene component responsible to rendering pipelines
  112996. */
  112997. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  112998. /**
  112999. * The component name helpfull to identify the component in the list of scene components.
  113000. */
  113001. readonly name: string;
  113002. /**
  113003. * The scene the component belongs to.
  113004. */
  113005. scene: Scene;
  113006. /**
  113007. * Creates a new instance of the component for the given scene
  113008. * @param scene Defines the scene to register the component in
  113009. */
  113010. constructor(scene: Scene);
  113011. /**
  113012. * Registers the component in a given scene
  113013. */
  113014. register(): void;
  113015. /**
  113016. * Rebuilds the elements related to this component in case of
  113017. * context lost for instance.
  113018. */
  113019. rebuild(): void;
  113020. /**
  113021. * Disposes the component and the associated ressources
  113022. */
  113023. dispose(): void;
  113024. private _gatherRenderTargets;
  113025. }
  113026. }
  113027. declare module BABYLON {
  113028. /**
  113029. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  113030. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  113031. */
  113032. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  113033. private _scene;
  113034. private _camerasToBeAttached;
  113035. /**
  113036. * ID of the sharpen post process,
  113037. */
  113038. private readonly SharpenPostProcessId;
  113039. /**
  113040. * @ignore
  113041. * ID of the image processing post process;
  113042. */
  113043. readonly ImageProcessingPostProcessId: string;
  113044. /**
  113045. * @ignore
  113046. * ID of the Fast Approximate Anti-Aliasing post process;
  113047. */
  113048. readonly FxaaPostProcessId: string;
  113049. /**
  113050. * ID of the chromatic aberration post process,
  113051. */
  113052. private readonly ChromaticAberrationPostProcessId;
  113053. /**
  113054. * ID of the grain post process
  113055. */
  113056. private readonly GrainPostProcessId;
  113057. /**
  113058. * Sharpen post process which will apply a sharpen convolution to enhance edges
  113059. */
  113060. sharpen: SharpenPostProcess;
  113061. private _sharpenEffect;
  113062. private bloom;
  113063. /**
  113064. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  113065. */
  113066. depthOfField: DepthOfFieldEffect;
  113067. /**
  113068. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  113069. */
  113070. fxaa: FxaaPostProcess;
  113071. /**
  113072. * Image post processing pass used to perform operations such as tone mapping or color grading.
  113073. */
  113074. imageProcessing: ImageProcessingPostProcess;
  113075. /**
  113076. * Chromatic aberration post process which will shift rgb colors in the image
  113077. */
  113078. chromaticAberration: ChromaticAberrationPostProcess;
  113079. private _chromaticAberrationEffect;
  113080. /**
  113081. * Grain post process which add noise to the image
  113082. */
  113083. grain: GrainPostProcess;
  113084. private _grainEffect;
  113085. /**
  113086. * Glow post process which adds a glow to emissive areas of the image
  113087. */
  113088. private _glowLayer;
  113089. /**
  113090. * Animations which can be used to tweak settings over a period of time
  113091. */
  113092. animations: Animation[];
  113093. private _imageProcessingConfigurationObserver;
  113094. private _sharpenEnabled;
  113095. private _bloomEnabled;
  113096. private _depthOfFieldEnabled;
  113097. private _depthOfFieldBlurLevel;
  113098. private _fxaaEnabled;
  113099. private _imageProcessingEnabled;
  113100. private _defaultPipelineTextureType;
  113101. private _bloomScale;
  113102. private _chromaticAberrationEnabled;
  113103. private _grainEnabled;
  113104. private _buildAllowed;
  113105. /**
  113106. * Gets active scene
  113107. */
  113108. readonly scene: Scene;
  113109. /**
  113110. * Enable or disable the sharpen process from the pipeline
  113111. */
  113112. sharpenEnabled: boolean;
  113113. private _resizeObserver;
  113114. private _hardwareScaleLevel;
  113115. private _bloomKernel;
  113116. /**
  113117. * Specifies the size of the bloom blur kernel, relative to the final output size
  113118. */
  113119. bloomKernel: number;
  113120. /**
  113121. * Specifies the weight of the bloom in the final rendering
  113122. */
  113123. private _bloomWeight;
  113124. /**
  113125. * Specifies the luma threshold for the area that will be blurred by the bloom
  113126. */
  113127. private _bloomThreshold;
  113128. private _hdr;
  113129. /**
  113130. * The strength of the bloom.
  113131. */
  113132. bloomWeight: number;
  113133. /**
  113134. * The strength of the bloom.
  113135. */
  113136. bloomThreshold: number;
  113137. /**
  113138. * The scale of the bloom, lower value will provide better performance.
  113139. */
  113140. bloomScale: number;
  113141. /**
  113142. * Enable or disable the bloom from the pipeline
  113143. */
  113144. bloomEnabled: boolean;
  113145. private _rebuildBloom;
  113146. /**
  113147. * If the depth of field is enabled.
  113148. */
  113149. depthOfFieldEnabled: boolean;
  113150. /**
  113151. * Blur level of the depth of field effect. (Higher blur will effect performance)
  113152. */
  113153. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  113154. /**
  113155. * If the anti aliasing is enabled.
  113156. */
  113157. fxaaEnabled: boolean;
  113158. private _samples;
  113159. /**
  113160. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113161. */
  113162. samples: number;
  113163. /**
  113164. * If image processing is enabled.
  113165. */
  113166. imageProcessingEnabled: boolean;
  113167. /**
  113168. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  113169. */
  113170. glowLayerEnabled: boolean;
  113171. /**
  113172. * Enable or disable the chromaticAberration process from the pipeline
  113173. */
  113174. chromaticAberrationEnabled: boolean;
  113175. /**
  113176. * Enable or disable the grain process from the pipeline
  113177. */
  113178. grainEnabled: boolean;
  113179. /**
  113180. * @constructor
  113181. * @param name - The rendering pipeline name (default: "")
  113182. * @param hdr - If high dynamic range textures should be used (default: true)
  113183. * @param scene - The scene linked to this pipeline (default: the last created scene)
  113184. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  113185. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  113186. */
  113187. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  113188. /**
  113189. * Get the class name
  113190. * @returns "DefaultRenderingPipeline"
  113191. */
  113192. getClassName(): string;
  113193. /**
  113194. * Force the compilation of the entire pipeline.
  113195. */
  113196. prepare(): void;
  113197. private _hasCleared;
  113198. private _prevPostProcess;
  113199. private _prevPrevPostProcess;
  113200. private _setAutoClearAndTextureSharing;
  113201. private _depthOfFieldSceneObserver;
  113202. private _buildPipeline;
  113203. private _disposePostProcesses;
  113204. /**
  113205. * Adds a camera to the pipeline
  113206. * @param camera the camera to be added
  113207. */
  113208. addCamera(camera: Camera): void;
  113209. /**
  113210. * Removes a camera from the pipeline
  113211. * @param camera the camera to remove
  113212. */
  113213. removeCamera(camera: Camera): void;
  113214. /**
  113215. * Dispose of the pipeline and stop all post processes
  113216. */
  113217. dispose(): void;
  113218. /**
  113219. * Serialize the rendering pipeline (Used when exporting)
  113220. * @returns the serialized object
  113221. */
  113222. serialize(): any;
  113223. /**
  113224. * Parse the serialized pipeline
  113225. * @param source Source pipeline.
  113226. * @param scene The scene to load the pipeline to.
  113227. * @param rootUrl The URL of the serialized pipeline.
  113228. * @returns An instantiated pipeline from the serialized object.
  113229. */
  113230. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  113231. }
  113232. }
  113233. declare module BABYLON {
  113234. /** @hidden */
  113235. export var lensHighlightsPixelShader: {
  113236. name: string;
  113237. shader: string;
  113238. };
  113239. }
  113240. declare module BABYLON {
  113241. /** @hidden */
  113242. export var depthOfFieldPixelShader: {
  113243. name: string;
  113244. shader: string;
  113245. };
  113246. }
  113247. declare module BABYLON {
  113248. /**
  113249. * BABYLON.JS Chromatic Aberration GLSL Shader
  113250. * Author: Olivier Guyot
  113251. * Separates very slightly R, G and B colors on the edges of the screen
  113252. * Inspired by Francois Tarlier & Martins Upitis
  113253. */
  113254. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  113255. /**
  113256. * @ignore
  113257. * The chromatic aberration PostProcess id in the pipeline
  113258. */
  113259. LensChromaticAberrationEffect: string;
  113260. /**
  113261. * @ignore
  113262. * The highlights enhancing PostProcess id in the pipeline
  113263. */
  113264. HighlightsEnhancingEffect: string;
  113265. /**
  113266. * @ignore
  113267. * The depth-of-field PostProcess id in the pipeline
  113268. */
  113269. LensDepthOfFieldEffect: string;
  113270. private _scene;
  113271. private _depthTexture;
  113272. private _grainTexture;
  113273. private _chromaticAberrationPostProcess;
  113274. private _highlightsPostProcess;
  113275. private _depthOfFieldPostProcess;
  113276. private _edgeBlur;
  113277. private _grainAmount;
  113278. private _chromaticAberration;
  113279. private _distortion;
  113280. private _highlightsGain;
  113281. private _highlightsThreshold;
  113282. private _dofDistance;
  113283. private _dofAperture;
  113284. private _dofDarken;
  113285. private _dofPentagon;
  113286. private _blurNoise;
  113287. /**
  113288. * @constructor
  113289. *
  113290. * Effect parameters are as follow:
  113291. * {
  113292. * chromatic_aberration: number; // from 0 to x (1 for realism)
  113293. * edge_blur: number; // from 0 to x (1 for realism)
  113294. * distortion: number; // from 0 to x (1 for realism)
  113295. * grain_amount: number; // from 0 to 1
  113296. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  113297. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  113298. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  113299. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  113300. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  113301. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  113302. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  113303. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  113304. * }
  113305. * Note: if an effect parameter is unset, effect is disabled
  113306. *
  113307. * @param name The rendering pipeline name
  113308. * @param parameters - An object containing all parameters (see above)
  113309. * @param scene The scene linked to this pipeline
  113310. * @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)
  113311. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113312. */
  113313. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  113314. /**
  113315. * Get the class name
  113316. * @returns "LensRenderingPipeline"
  113317. */
  113318. getClassName(): string;
  113319. /**
  113320. * Gets associated scene
  113321. */
  113322. readonly scene: Scene;
  113323. /**
  113324. * Gets or sets the edge blur
  113325. */
  113326. edgeBlur: number;
  113327. /**
  113328. * Gets or sets the grain amount
  113329. */
  113330. grainAmount: number;
  113331. /**
  113332. * Gets or sets the chromatic aberration amount
  113333. */
  113334. chromaticAberration: number;
  113335. /**
  113336. * Gets or sets the depth of field aperture
  113337. */
  113338. dofAperture: number;
  113339. /**
  113340. * Gets or sets the edge distortion
  113341. */
  113342. edgeDistortion: number;
  113343. /**
  113344. * Gets or sets the depth of field distortion
  113345. */
  113346. dofDistortion: number;
  113347. /**
  113348. * Gets or sets the darken out of focus amount
  113349. */
  113350. darkenOutOfFocus: number;
  113351. /**
  113352. * Gets or sets a boolean indicating if blur noise is enabled
  113353. */
  113354. blurNoise: boolean;
  113355. /**
  113356. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  113357. */
  113358. pentagonBokeh: boolean;
  113359. /**
  113360. * Gets or sets the highlight grain amount
  113361. */
  113362. highlightsGain: number;
  113363. /**
  113364. * Gets or sets the highlight threshold
  113365. */
  113366. highlightsThreshold: number;
  113367. /**
  113368. * Sets the amount of blur at the edges
  113369. * @param amount blur amount
  113370. */
  113371. setEdgeBlur(amount: number): void;
  113372. /**
  113373. * Sets edge blur to 0
  113374. */
  113375. disableEdgeBlur(): void;
  113376. /**
  113377. * Sets the amout of grain
  113378. * @param amount Amount of grain
  113379. */
  113380. setGrainAmount(amount: number): void;
  113381. /**
  113382. * Set grain amount to 0
  113383. */
  113384. disableGrain(): void;
  113385. /**
  113386. * Sets the chromatic aberration amount
  113387. * @param amount amount of chromatic aberration
  113388. */
  113389. setChromaticAberration(amount: number): void;
  113390. /**
  113391. * Sets chromatic aberration amount to 0
  113392. */
  113393. disableChromaticAberration(): void;
  113394. /**
  113395. * Sets the EdgeDistortion amount
  113396. * @param amount amount of EdgeDistortion
  113397. */
  113398. setEdgeDistortion(amount: number): void;
  113399. /**
  113400. * Sets edge distortion to 0
  113401. */
  113402. disableEdgeDistortion(): void;
  113403. /**
  113404. * Sets the FocusDistance amount
  113405. * @param amount amount of FocusDistance
  113406. */
  113407. setFocusDistance(amount: number): void;
  113408. /**
  113409. * Disables depth of field
  113410. */
  113411. disableDepthOfField(): void;
  113412. /**
  113413. * Sets the Aperture amount
  113414. * @param amount amount of Aperture
  113415. */
  113416. setAperture(amount: number): void;
  113417. /**
  113418. * Sets the DarkenOutOfFocus amount
  113419. * @param amount amount of DarkenOutOfFocus
  113420. */
  113421. setDarkenOutOfFocus(amount: number): void;
  113422. private _pentagonBokehIsEnabled;
  113423. /**
  113424. * Creates a pentagon bokeh effect
  113425. */
  113426. enablePentagonBokeh(): void;
  113427. /**
  113428. * Disables the pentagon bokeh effect
  113429. */
  113430. disablePentagonBokeh(): void;
  113431. /**
  113432. * Enables noise blur
  113433. */
  113434. enableNoiseBlur(): void;
  113435. /**
  113436. * Disables noise blur
  113437. */
  113438. disableNoiseBlur(): void;
  113439. /**
  113440. * Sets the HighlightsGain amount
  113441. * @param amount amount of HighlightsGain
  113442. */
  113443. setHighlightsGain(amount: number): void;
  113444. /**
  113445. * Sets the HighlightsThreshold amount
  113446. * @param amount amount of HighlightsThreshold
  113447. */
  113448. setHighlightsThreshold(amount: number): void;
  113449. /**
  113450. * Disables highlights
  113451. */
  113452. disableHighlights(): void;
  113453. /**
  113454. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  113455. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  113456. */
  113457. dispose(disableDepthRender?: boolean): void;
  113458. private _createChromaticAberrationPostProcess;
  113459. private _createHighlightsPostProcess;
  113460. private _createDepthOfFieldPostProcess;
  113461. private _createGrainTexture;
  113462. }
  113463. }
  113464. declare module BABYLON {
  113465. /** @hidden */
  113466. export var ssao2PixelShader: {
  113467. name: string;
  113468. shader: string;
  113469. };
  113470. }
  113471. declare module BABYLON {
  113472. /** @hidden */
  113473. export var ssaoCombinePixelShader: {
  113474. name: string;
  113475. shader: string;
  113476. };
  113477. }
  113478. declare module BABYLON {
  113479. /**
  113480. * Render pipeline to produce ssao effect
  113481. */
  113482. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  113483. /**
  113484. * @ignore
  113485. * The PassPostProcess id in the pipeline that contains the original scene color
  113486. */
  113487. SSAOOriginalSceneColorEffect: string;
  113488. /**
  113489. * @ignore
  113490. * The SSAO PostProcess id in the pipeline
  113491. */
  113492. SSAORenderEffect: string;
  113493. /**
  113494. * @ignore
  113495. * The horizontal blur PostProcess id in the pipeline
  113496. */
  113497. SSAOBlurHRenderEffect: string;
  113498. /**
  113499. * @ignore
  113500. * The vertical blur PostProcess id in the pipeline
  113501. */
  113502. SSAOBlurVRenderEffect: string;
  113503. /**
  113504. * @ignore
  113505. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  113506. */
  113507. SSAOCombineRenderEffect: string;
  113508. /**
  113509. * The output strength of the SSAO post-process. Default value is 1.0.
  113510. */
  113511. totalStrength: number;
  113512. /**
  113513. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  113514. */
  113515. maxZ: number;
  113516. /**
  113517. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  113518. */
  113519. minZAspect: number;
  113520. private _samples;
  113521. /**
  113522. * Number of samples used for the SSAO calculations. Default value is 8
  113523. */
  113524. samples: number;
  113525. private _textureSamples;
  113526. /**
  113527. * Number of samples to use for antialiasing
  113528. */
  113529. textureSamples: number;
  113530. /**
  113531. * Ratio object used for SSAO ratio and blur ratio
  113532. */
  113533. private _ratio;
  113534. /**
  113535. * Dynamically generated sphere sampler.
  113536. */
  113537. private _sampleSphere;
  113538. /**
  113539. * Blur filter offsets
  113540. */
  113541. private _samplerOffsets;
  113542. private _expensiveBlur;
  113543. /**
  113544. * If bilateral blur should be used
  113545. */
  113546. expensiveBlur: boolean;
  113547. /**
  113548. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  113549. */
  113550. radius: number;
  113551. /**
  113552. * The base color of the SSAO post-process
  113553. * The final result is "base + ssao" between [0, 1]
  113554. */
  113555. base: number;
  113556. /**
  113557. * Support test.
  113558. */
  113559. static readonly IsSupported: boolean;
  113560. private _scene;
  113561. private _depthTexture;
  113562. private _normalTexture;
  113563. private _randomTexture;
  113564. private _originalColorPostProcess;
  113565. private _ssaoPostProcess;
  113566. private _blurHPostProcess;
  113567. private _blurVPostProcess;
  113568. private _ssaoCombinePostProcess;
  113569. private _firstUpdate;
  113570. /**
  113571. * Gets active scene
  113572. */
  113573. readonly scene: Scene;
  113574. /**
  113575. * @constructor
  113576. * @param name The rendering pipeline name
  113577. * @param scene The scene linked to this pipeline
  113578. * @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 }
  113579. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113580. */
  113581. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  113582. /**
  113583. * Get the class name
  113584. * @returns "SSAO2RenderingPipeline"
  113585. */
  113586. getClassName(): string;
  113587. /**
  113588. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113589. */
  113590. dispose(disableGeometryBufferRenderer?: boolean): void;
  113591. private _createBlurPostProcess;
  113592. /** @hidden */
  113593. _rebuild(): void;
  113594. private _bits;
  113595. private _radicalInverse_VdC;
  113596. private _hammersley;
  113597. private _hemisphereSample_uniform;
  113598. private _generateHemisphere;
  113599. private _createSSAOPostProcess;
  113600. private _createSSAOCombinePostProcess;
  113601. private _createRandomTexture;
  113602. /**
  113603. * Serialize the rendering pipeline (Used when exporting)
  113604. * @returns the serialized object
  113605. */
  113606. serialize(): any;
  113607. /**
  113608. * Parse the serialized pipeline
  113609. * @param source Source pipeline.
  113610. * @param scene The scene to load the pipeline to.
  113611. * @param rootUrl The URL of the serialized pipeline.
  113612. * @returns An instantiated pipeline from the serialized object.
  113613. */
  113614. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  113615. }
  113616. }
  113617. declare module BABYLON {
  113618. /** @hidden */
  113619. export var ssaoPixelShader: {
  113620. name: string;
  113621. shader: string;
  113622. };
  113623. }
  113624. declare module BABYLON {
  113625. /**
  113626. * Render pipeline to produce ssao effect
  113627. */
  113628. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  113629. /**
  113630. * @ignore
  113631. * The PassPostProcess id in the pipeline that contains the original scene color
  113632. */
  113633. SSAOOriginalSceneColorEffect: string;
  113634. /**
  113635. * @ignore
  113636. * The SSAO PostProcess id in the pipeline
  113637. */
  113638. SSAORenderEffect: string;
  113639. /**
  113640. * @ignore
  113641. * The horizontal blur PostProcess id in the pipeline
  113642. */
  113643. SSAOBlurHRenderEffect: string;
  113644. /**
  113645. * @ignore
  113646. * The vertical blur PostProcess id in the pipeline
  113647. */
  113648. SSAOBlurVRenderEffect: string;
  113649. /**
  113650. * @ignore
  113651. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  113652. */
  113653. SSAOCombineRenderEffect: string;
  113654. /**
  113655. * The output strength of the SSAO post-process. Default value is 1.0.
  113656. */
  113657. totalStrength: number;
  113658. /**
  113659. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  113660. */
  113661. radius: number;
  113662. /**
  113663. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  113664. * Must not be equal to fallOff and superior to fallOff.
  113665. * Default value is 0.0075
  113666. */
  113667. area: number;
  113668. /**
  113669. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  113670. * Must not be equal to area and inferior to area.
  113671. * Default value is 0.000001
  113672. */
  113673. fallOff: number;
  113674. /**
  113675. * The base color of the SSAO post-process
  113676. * The final result is "base + ssao" between [0, 1]
  113677. */
  113678. base: number;
  113679. private _scene;
  113680. private _depthTexture;
  113681. private _randomTexture;
  113682. private _originalColorPostProcess;
  113683. private _ssaoPostProcess;
  113684. private _blurHPostProcess;
  113685. private _blurVPostProcess;
  113686. private _ssaoCombinePostProcess;
  113687. private _firstUpdate;
  113688. /**
  113689. * Gets active scene
  113690. */
  113691. readonly scene: Scene;
  113692. /**
  113693. * @constructor
  113694. * @param name - The rendering pipeline name
  113695. * @param scene - The scene linked to this pipeline
  113696. * @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 }
  113697. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  113698. */
  113699. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  113700. /**
  113701. * Get the class name
  113702. * @returns "SSAORenderingPipeline"
  113703. */
  113704. getClassName(): string;
  113705. /**
  113706. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113707. */
  113708. dispose(disableDepthRender?: boolean): void;
  113709. private _createBlurPostProcess;
  113710. /** @hidden */
  113711. _rebuild(): void;
  113712. private _createSSAOPostProcess;
  113713. private _createSSAOCombinePostProcess;
  113714. private _createRandomTexture;
  113715. }
  113716. }
  113717. declare module BABYLON {
  113718. /** @hidden */
  113719. export var standardPixelShader: {
  113720. name: string;
  113721. shader: string;
  113722. };
  113723. }
  113724. declare module BABYLON {
  113725. /**
  113726. * Standard rendering pipeline
  113727. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  113728. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  113729. */
  113730. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  113731. /**
  113732. * Public members
  113733. */
  113734. /**
  113735. * Post-process which contains the original scene color before the pipeline applies all the effects
  113736. */
  113737. originalPostProcess: Nullable<PostProcess>;
  113738. /**
  113739. * Post-process used to down scale an image x4
  113740. */
  113741. downSampleX4PostProcess: Nullable<PostProcess>;
  113742. /**
  113743. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  113744. */
  113745. brightPassPostProcess: Nullable<PostProcess>;
  113746. /**
  113747. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  113748. */
  113749. blurHPostProcesses: PostProcess[];
  113750. /**
  113751. * Post-process array storing all the vertical blur post-processes used by the pipeline
  113752. */
  113753. blurVPostProcesses: PostProcess[];
  113754. /**
  113755. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  113756. */
  113757. textureAdderPostProcess: Nullable<PostProcess>;
  113758. /**
  113759. * Post-process used to create volumetric lighting effect
  113760. */
  113761. volumetricLightPostProcess: Nullable<PostProcess>;
  113762. /**
  113763. * Post-process used to smooth the previous volumetric light post-process on the X axis
  113764. */
  113765. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  113766. /**
  113767. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  113768. */
  113769. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  113770. /**
  113771. * Post-process used to merge the volumetric light effect and the real scene color
  113772. */
  113773. volumetricLightMergePostProces: Nullable<PostProcess>;
  113774. /**
  113775. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  113776. */
  113777. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  113778. /**
  113779. * Base post-process used to calculate the average luminance of the final image for HDR
  113780. */
  113781. luminancePostProcess: Nullable<PostProcess>;
  113782. /**
  113783. * Post-processes used to create down sample post-processes in order to get
  113784. * the average luminance of the final image for HDR
  113785. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  113786. */
  113787. luminanceDownSamplePostProcesses: PostProcess[];
  113788. /**
  113789. * Post-process used to create a HDR effect (light adaptation)
  113790. */
  113791. hdrPostProcess: Nullable<PostProcess>;
  113792. /**
  113793. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  113794. */
  113795. textureAdderFinalPostProcess: Nullable<PostProcess>;
  113796. /**
  113797. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  113798. */
  113799. lensFlareFinalPostProcess: Nullable<PostProcess>;
  113800. /**
  113801. * Post-process used to merge the final HDR post-process and the real scene color
  113802. */
  113803. hdrFinalPostProcess: Nullable<PostProcess>;
  113804. /**
  113805. * Post-process used to create a lens flare effect
  113806. */
  113807. lensFlarePostProcess: Nullable<PostProcess>;
  113808. /**
  113809. * Post-process that merges the result of the lens flare post-process and the real scene color
  113810. */
  113811. lensFlareComposePostProcess: Nullable<PostProcess>;
  113812. /**
  113813. * Post-process used to create a motion blur effect
  113814. */
  113815. motionBlurPostProcess: Nullable<PostProcess>;
  113816. /**
  113817. * Post-process used to create a depth of field effect
  113818. */
  113819. depthOfFieldPostProcess: Nullable<PostProcess>;
  113820. /**
  113821. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  113822. */
  113823. fxaaPostProcess: Nullable<FxaaPostProcess>;
  113824. /**
  113825. * Represents the brightness threshold in order to configure the illuminated surfaces
  113826. */
  113827. brightThreshold: number;
  113828. /**
  113829. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  113830. */
  113831. blurWidth: number;
  113832. /**
  113833. * Sets if the blur for highlighted surfaces must be only horizontal
  113834. */
  113835. horizontalBlur: boolean;
  113836. /**
  113837. * Gets the overall exposure used by the pipeline
  113838. */
  113839. /**
  113840. * Sets the overall exposure used by the pipeline
  113841. */
  113842. exposure: number;
  113843. /**
  113844. * Texture used typically to simulate "dirty" on camera lens
  113845. */
  113846. lensTexture: Nullable<Texture>;
  113847. /**
  113848. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  113849. */
  113850. volumetricLightCoefficient: number;
  113851. /**
  113852. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  113853. */
  113854. volumetricLightPower: number;
  113855. /**
  113856. * Used the set the blur intensity to smooth the volumetric lights
  113857. */
  113858. volumetricLightBlurScale: number;
  113859. /**
  113860. * Light (spot or directional) used to generate the volumetric lights rays
  113861. * The source light must have a shadow generate so the pipeline can get its
  113862. * depth map
  113863. */
  113864. sourceLight: Nullable<SpotLight | DirectionalLight>;
  113865. /**
  113866. * For eye adaptation, represents the minimum luminance the eye can see
  113867. */
  113868. hdrMinimumLuminance: number;
  113869. /**
  113870. * For eye adaptation, represents the decrease luminance speed
  113871. */
  113872. hdrDecreaseRate: number;
  113873. /**
  113874. * For eye adaptation, represents the increase luminance speed
  113875. */
  113876. hdrIncreaseRate: number;
  113877. /**
  113878. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  113879. */
  113880. /**
  113881. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  113882. */
  113883. hdrAutoExposure: boolean;
  113884. /**
  113885. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  113886. */
  113887. lensColorTexture: Nullable<Texture>;
  113888. /**
  113889. * The overall strengh for the lens flare effect
  113890. */
  113891. lensFlareStrength: number;
  113892. /**
  113893. * Dispersion coefficient for lens flare ghosts
  113894. */
  113895. lensFlareGhostDispersal: number;
  113896. /**
  113897. * Main lens flare halo width
  113898. */
  113899. lensFlareHaloWidth: number;
  113900. /**
  113901. * Based on the lens distortion effect, defines how much the lens flare result
  113902. * is distorted
  113903. */
  113904. lensFlareDistortionStrength: number;
  113905. /**
  113906. * Lens star texture must be used to simulate rays on the flares and is available
  113907. * in the documentation
  113908. */
  113909. lensStarTexture: Nullable<Texture>;
  113910. /**
  113911. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  113912. * flare effect by taking account of the dirt texture
  113913. */
  113914. lensFlareDirtTexture: Nullable<Texture>;
  113915. /**
  113916. * Represents the focal length for the depth of field effect
  113917. */
  113918. depthOfFieldDistance: number;
  113919. /**
  113920. * Represents the blur intensity for the blurred part of the depth of field effect
  113921. */
  113922. depthOfFieldBlurWidth: number;
  113923. /**
  113924. * For motion blur, defines how much the image is blurred by the movement
  113925. */
  113926. motionStrength: number;
  113927. /**
  113928. * List of animations for the pipeline (IAnimatable implementation)
  113929. */
  113930. animations: Animation[];
  113931. /**
  113932. * Private members
  113933. */
  113934. private _scene;
  113935. private _currentDepthOfFieldSource;
  113936. private _basePostProcess;
  113937. private _fixedExposure;
  113938. private _currentExposure;
  113939. private _hdrAutoExposure;
  113940. private _hdrCurrentLuminance;
  113941. private _floatTextureType;
  113942. private _ratio;
  113943. private _bloomEnabled;
  113944. private _depthOfFieldEnabled;
  113945. private _vlsEnabled;
  113946. private _lensFlareEnabled;
  113947. private _hdrEnabled;
  113948. private _motionBlurEnabled;
  113949. private _fxaaEnabled;
  113950. private _motionBlurSamples;
  113951. private _volumetricLightStepsCount;
  113952. private _samples;
  113953. /**
  113954. * @ignore
  113955. * Specifies if the bloom pipeline is enabled
  113956. */
  113957. BloomEnabled: boolean;
  113958. /**
  113959. * @ignore
  113960. * Specifies if the depth of field pipeline is enabed
  113961. */
  113962. DepthOfFieldEnabled: boolean;
  113963. /**
  113964. * @ignore
  113965. * Specifies if the lens flare pipeline is enabed
  113966. */
  113967. LensFlareEnabled: boolean;
  113968. /**
  113969. * @ignore
  113970. * Specifies if the HDR pipeline is enabled
  113971. */
  113972. HDREnabled: boolean;
  113973. /**
  113974. * @ignore
  113975. * Specifies if the volumetric lights scattering effect is enabled
  113976. */
  113977. VLSEnabled: boolean;
  113978. /**
  113979. * @ignore
  113980. * Specifies if the motion blur effect is enabled
  113981. */
  113982. MotionBlurEnabled: boolean;
  113983. /**
  113984. * Specifies if anti-aliasing is enabled
  113985. */
  113986. fxaaEnabled: boolean;
  113987. /**
  113988. * Specifies the number of steps used to calculate the volumetric lights
  113989. * Typically in interval [50, 200]
  113990. */
  113991. volumetricLightStepsCount: number;
  113992. /**
  113993. * Specifies the number of samples used for the motion blur effect
  113994. * Typically in interval [16, 64]
  113995. */
  113996. motionBlurSamples: number;
  113997. /**
  113998. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113999. */
  114000. samples: number;
  114001. /**
  114002. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114003. * @constructor
  114004. * @param name The rendering pipeline name
  114005. * @param scene The scene linked to this pipeline
  114006. * @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)
  114007. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  114008. * @param cameras The array of cameras that the rendering pipeline will be attached to
  114009. */
  114010. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  114011. private _buildPipeline;
  114012. private _createDownSampleX4PostProcess;
  114013. private _createBrightPassPostProcess;
  114014. private _createBlurPostProcesses;
  114015. private _createTextureAdderPostProcess;
  114016. private _createVolumetricLightPostProcess;
  114017. private _createLuminancePostProcesses;
  114018. private _createHdrPostProcess;
  114019. private _createLensFlarePostProcess;
  114020. private _createDepthOfFieldPostProcess;
  114021. private _createMotionBlurPostProcess;
  114022. private _getDepthTexture;
  114023. private _disposePostProcesses;
  114024. /**
  114025. * Dispose of the pipeline and stop all post processes
  114026. */
  114027. dispose(): void;
  114028. /**
  114029. * Serialize the rendering pipeline (Used when exporting)
  114030. * @returns the serialized object
  114031. */
  114032. serialize(): any;
  114033. /**
  114034. * Parse the serialized pipeline
  114035. * @param source Source pipeline.
  114036. * @param scene The scene to load the pipeline to.
  114037. * @param rootUrl The URL of the serialized pipeline.
  114038. * @returns An instantiated pipeline from the serialized object.
  114039. */
  114040. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  114041. /**
  114042. * Luminance steps
  114043. */
  114044. static LuminanceSteps: number;
  114045. }
  114046. }
  114047. declare module BABYLON {
  114048. /** @hidden */
  114049. export var tonemapPixelShader: {
  114050. name: string;
  114051. shader: string;
  114052. };
  114053. }
  114054. declare module BABYLON {
  114055. /** Defines operator used for tonemapping */
  114056. export enum TonemappingOperator {
  114057. /** Hable */
  114058. Hable = 0,
  114059. /** Reinhard */
  114060. Reinhard = 1,
  114061. /** HejiDawson */
  114062. HejiDawson = 2,
  114063. /** Photographic */
  114064. Photographic = 3
  114065. }
  114066. /**
  114067. * Defines a post process to apply tone mapping
  114068. */
  114069. export class TonemapPostProcess extends PostProcess {
  114070. private _operator;
  114071. /** Defines the required exposure adjustement */
  114072. exposureAdjustment: number;
  114073. /**
  114074. * Creates a new TonemapPostProcess
  114075. * @param name defines the name of the postprocess
  114076. * @param _operator defines the operator to use
  114077. * @param exposureAdjustment defines the required exposure adjustement
  114078. * @param camera defines the camera to use (can be null)
  114079. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  114080. * @param engine defines the hosting engine (can be ignore if camera is set)
  114081. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  114082. */
  114083. constructor(name: string, _operator: TonemappingOperator,
  114084. /** Defines the required exposure adjustement */
  114085. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  114086. }
  114087. }
  114088. declare module BABYLON {
  114089. /** @hidden */
  114090. export var depthVertexShader: {
  114091. name: string;
  114092. shader: string;
  114093. };
  114094. }
  114095. declare module BABYLON {
  114096. /** @hidden */
  114097. export var volumetricLightScatteringPixelShader: {
  114098. name: string;
  114099. shader: string;
  114100. };
  114101. }
  114102. declare module BABYLON {
  114103. /** @hidden */
  114104. export var volumetricLightScatteringPassPixelShader: {
  114105. name: string;
  114106. shader: string;
  114107. };
  114108. }
  114109. declare module BABYLON {
  114110. /**
  114111. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  114112. */
  114113. export class VolumetricLightScatteringPostProcess extends PostProcess {
  114114. private _volumetricLightScatteringPass;
  114115. private _volumetricLightScatteringRTT;
  114116. private _viewPort;
  114117. private _screenCoordinates;
  114118. private _cachedDefines;
  114119. /**
  114120. * If not undefined, the mesh position is computed from the attached node position
  114121. */
  114122. attachedNode: {
  114123. position: Vector3;
  114124. };
  114125. /**
  114126. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  114127. */
  114128. customMeshPosition: Vector3;
  114129. /**
  114130. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  114131. */
  114132. useCustomMeshPosition: boolean;
  114133. /**
  114134. * If the post-process should inverse the light scattering direction
  114135. */
  114136. invert: boolean;
  114137. /**
  114138. * The internal mesh used by the post-process
  114139. */
  114140. mesh: Mesh;
  114141. /**
  114142. * @hidden
  114143. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  114144. */
  114145. useDiffuseColor: boolean;
  114146. /**
  114147. * Array containing the excluded meshes not rendered in the internal pass
  114148. */
  114149. excludedMeshes: AbstractMesh[];
  114150. /**
  114151. * Controls the overall intensity of the post-process
  114152. */
  114153. exposure: number;
  114154. /**
  114155. * Dissipates each sample's contribution in range [0, 1]
  114156. */
  114157. decay: number;
  114158. /**
  114159. * Controls the overall intensity of each sample
  114160. */
  114161. weight: number;
  114162. /**
  114163. * Controls the density of each sample
  114164. */
  114165. density: number;
  114166. /**
  114167. * @constructor
  114168. * @param name The post-process name
  114169. * @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)
  114170. * @param camera The camera that the post-process will be attached to
  114171. * @param mesh The mesh used to create the light scattering
  114172. * @param samples The post-process quality, default 100
  114173. * @param samplingModeThe post-process filtering mode
  114174. * @param engine The babylon engine
  114175. * @param reusable If the post-process is reusable
  114176. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  114177. */
  114178. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  114179. /**
  114180. * Returns the string "VolumetricLightScatteringPostProcess"
  114181. * @returns "VolumetricLightScatteringPostProcess"
  114182. */
  114183. getClassName(): string;
  114184. private _isReady;
  114185. /**
  114186. * Sets the new light position for light scattering effect
  114187. * @param position The new custom light position
  114188. */
  114189. setCustomMeshPosition(position: Vector3): void;
  114190. /**
  114191. * Returns the light position for light scattering effect
  114192. * @return Vector3 The custom light position
  114193. */
  114194. getCustomMeshPosition(): Vector3;
  114195. /**
  114196. * Disposes the internal assets and detaches the post-process from the camera
  114197. */
  114198. dispose(camera: Camera): void;
  114199. /**
  114200. * Returns the render target texture used by the post-process
  114201. * @return the render target texture used by the post-process
  114202. */
  114203. getPass(): RenderTargetTexture;
  114204. private _meshExcluded;
  114205. private _createPass;
  114206. private _updateMeshScreenCoordinates;
  114207. /**
  114208. * Creates a default mesh for the Volumeric Light Scattering post-process
  114209. * @param name The mesh name
  114210. * @param scene The scene where to create the mesh
  114211. * @return the default mesh
  114212. */
  114213. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  114214. }
  114215. }
  114216. declare module BABYLON {
  114217. interface Scene {
  114218. /** @hidden (Backing field) */
  114219. _boundingBoxRenderer: BoundingBoxRenderer;
  114220. /** @hidden (Backing field) */
  114221. _forceShowBoundingBoxes: boolean;
  114222. /**
  114223. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  114224. */
  114225. forceShowBoundingBoxes: boolean;
  114226. /**
  114227. * Gets the bounding box renderer associated with the scene
  114228. * @returns a BoundingBoxRenderer
  114229. */
  114230. getBoundingBoxRenderer(): BoundingBoxRenderer;
  114231. }
  114232. interface AbstractMesh {
  114233. /** @hidden (Backing field) */
  114234. _showBoundingBox: boolean;
  114235. /**
  114236. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  114237. */
  114238. showBoundingBox: boolean;
  114239. }
  114240. /**
  114241. * Component responsible of rendering the bounding box of the meshes in a scene.
  114242. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  114243. */
  114244. export class BoundingBoxRenderer implements ISceneComponent {
  114245. /**
  114246. * The component name helpfull to identify the component in the list of scene components.
  114247. */
  114248. readonly name: string;
  114249. /**
  114250. * The scene the component belongs to.
  114251. */
  114252. scene: Scene;
  114253. /**
  114254. * Color of the bounding box lines placed in front of an object
  114255. */
  114256. frontColor: Color3;
  114257. /**
  114258. * Color of the bounding box lines placed behind an object
  114259. */
  114260. backColor: Color3;
  114261. /**
  114262. * Defines if the renderer should show the back lines or not
  114263. */
  114264. showBackLines: boolean;
  114265. /**
  114266. * @hidden
  114267. */
  114268. renderList: SmartArray<BoundingBox>;
  114269. private _colorShader;
  114270. private _vertexBuffers;
  114271. private _indexBuffer;
  114272. /**
  114273. * Instantiates a new bounding box renderer in a scene.
  114274. * @param scene the scene the renderer renders in
  114275. */
  114276. constructor(scene: Scene);
  114277. /**
  114278. * Registers the component in a given scene
  114279. */
  114280. register(): void;
  114281. private _evaluateSubMesh;
  114282. private _activeMesh;
  114283. private _prepareRessources;
  114284. private _createIndexBuffer;
  114285. /**
  114286. * Rebuilds the elements related to this component in case of
  114287. * context lost for instance.
  114288. */
  114289. rebuild(): void;
  114290. /**
  114291. * @hidden
  114292. */
  114293. reset(): void;
  114294. /**
  114295. * Render the bounding boxes of a specific rendering group
  114296. * @param renderingGroupId defines the rendering group to render
  114297. */
  114298. render(renderingGroupId: number): void;
  114299. /**
  114300. * In case of occlusion queries, we can render the occlusion bounding box through this method
  114301. * @param mesh Define the mesh to render the occlusion bounding box for
  114302. */
  114303. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  114304. /**
  114305. * Dispose and release the resources attached to this renderer.
  114306. */
  114307. dispose(): void;
  114308. }
  114309. }
  114310. declare module BABYLON {
  114311. /** @hidden */
  114312. export var depthPixelShader: {
  114313. name: string;
  114314. shader: string;
  114315. };
  114316. }
  114317. declare module BABYLON {
  114318. /**
  114319. * This represents a depth renderer in Babylon.
  114320. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  114321. */
  114322. export class DepthRenderer {
  114323. private _scene;
  114324. private _depthMap;
  114325. private _effect;
  114326. private _cachedDefines;
  114327. private _camera;
  114328. /**
  114329. * Specifiess that the depth renderer will only be used within
  114330. * the camera it is created for.
  114331. * This can help forcing its rendering during the camera processing.
  114332. */
  114333. useOnlyInActiveCamera: boolean;
  114334. /** @hidden */
  114335. static _SceneComponentInitialization: (scene: Scene) => void;
  114336. /**
  114337. * Instantiates a depth renderer
  114338. * @param scene The scene the renderer belongs to
  114339. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  114340. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  114341. */
  114342. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  114343. /**
  114344. * Creates the depth rendering effect and checks if the effect is ready.
  114345. * @param subMesh The submesh to be used to render the depth map of
  114346. * @param useInstances If multiple world instances should be used
  114347. * @returns if the depth renderer is ready to render the depth map
  114348. */
  114349. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114350. /**
  114351. * Gets the texture which the depth map will be written to.
  114352. * @returns The depth map texture
  114353. */
  114354. getDepthMap(): RenderTargetTexture;
  114355. /**
  114356. * Disposes of the depth renderer.
  114357. */
  114358. dispose(): void;
  114359. }
  114360. }
  114361. declare module BABYLON {
  114362. interface Scene {
  114363. /** @hidden (Backing field) */
  114364. _depthRenderer: {
  114365. [id: string]: DepthRenderer;
  114366. };
  114367. /**
  114368. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  114369. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  114370. * @returns the created depth renderer
  114371. */
  114372. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  114373. /**
  114374. * Disables a depth renderer for a given camera
  114375. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  114376. */
  114377. disableDepthRenderer(camera?: Nullable<Camera>): void;
  114378. }
  114379. /**
  114380. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  114381. * in several rendering techniques.
  114382. */
  114383. export class DepthRendererSceneComponent implements ISceneComponent {
  114384. /**
  114385. * The component name helpfull to identify the component in the list of scene components.
  114386. */
  114387. readonly name: string;
  114388. /**
  114389. * The scene the component belongs to.
  114390. */
  114391. scene: Scene;
  114392. /**
  114393. * Creates a new instance of the component for the given scene
  114394. * @param scene Defines the scene to register the component in
  114395. */
  114396. constructor(scene: Scene);
  114397. /**
  114398. * Registers the component in a given scene
  114399. */
  114400. register(): void;
  114401. /**
  114402. * Rebuilds the elements related to this component in case of
  114403. * context lost for instance.
  114404. */
  114405. rebuild(): void;
  114406. /**
  114407. * Disposes the component and the associated ressources
  114408. */
  114409. dispose(): void;
  114410. private _gatherRenderTargets;
  114411. private _gatherActiveCameraRenderTargets;
  114412. }
  114413. }
  114414. declare module BABYLON {
  114415. /** @hidden */
  114416. export var outlinePixelShader: {
  114417. name: string;
  114418. shader: string;
  114419. };
  114420. }
  114421. declare module BABYLON {
  114422. /** @hidden */
  114423. export var outlineVertexShader: {
  114424. name: string;
  114425. shader: string;
  114426. };
  114427. }
  114428. declare module BABYLON {
  114429. interface Scene {
  114430. /** @hidden */
  114431. _outlineRenderer: OutlineRenderer;
  114432. /**
  114433. * Gets the outline renderer associated with the scene
  114434. * @returns a OutlineRenderer
  114435. */
  114436. getOutlineRenderer(): OutlineRenderer;
  114437. }
  114438. interface AbstractMesh {
  114439. /** @hidden (Backing field) */
  114440. _renderOutline: boolean;
  114441. /**
  114442. * Gets or sets a boolean indicating if the outline must be rendered as well
  114443. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  114444. */
  114445. renderOutline: boolean;
  114446. /** @hidden (Backing field) */
  114447. _renderOverlay: boolean;
  114448. /**
  114449. * Gets or sets a boolean indicating if the overlay must be rendered as well
  114450. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  114451. */
  114452. renderOverlay: boolean;
  114453. }
  114454. /**
  114455. * This class is responsible to draw bothe outline/overlay of meshes.
  114456. * It should not be used directly but through the available method on mesh.
  114457. */
  114458. export class OutlineRenderer implements ISceneComponent {
  114459. /**
  114460. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  114461. */
  114462. private static _StencilReference;
  114463. /**
  114464. * The name of the component. Each component must have a unique name.
  114465. */
  114466. name: string;
  114467. /**
  114468. * The scene the component belongs to.
  114469. */
  114470. scene: Scene;
  114471. /**
  114472. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  114473. */
  114474. zOffset: number;
  114475. private _engine;
  114476. private _effect;
  114477. private _cachedDefines;
  114478. private _savedDepthWrite;
  114479. /**
  114480. * Instantiates a new outline renderer. (There could be only one per scene).
  114481. * @param scene Defines the scene it belongs to
  114482. */
  114483. constructor(scene: Scene);
  114484. /**
  114485. * Register the component to one instance of a scene.
  114486. */
  114487. register(): void;
  114488. /**
  114489. * Rebuilds the elements related to this component in case of
  114490. * context lost for instance.
  114491. */
  114492. rebuild(): void;
  114493. /**
  114494. * Disposes the component and the associated ressources.
  114495. */
  114496. dispose(): void;
  114497. /**
  114498. * Renders the outline in the canvas.
  114499. * @param subMesh Defines the sumesh to render
  114500. * @param batch Defines the batch of meshes in case of instances
  114501. * @param useOverlay Defines if the rendering is for the overlay or the outline
  114502. */
  114503. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  114504. /**
  114505. * Returns whether or not the outline renderer is ready for a given submesh.
  114506. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  114507. * @param subMesh Defines the submesh to check readyness for
  114508. * @param useInstances Defines wheter wee are trying to render instances or not
  114509. * @returns true if ready otherwise false
  114510. */
  114511. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114512. private _beforeRenderingMesh;
  114513. private _afterRenderingMesh;
  114514. }
  114515. }
  114516. declare module BABYLON {
  114517. /**
  114518. * Defines the list of states available for a task inside a AssetsManager
  114519. */
  114520. export enum AssetTaskState {
  114521. /**
  114522. * Initialization
  114523. */
  114524. INIT = 0,
  114525. /**
  114526. * Running
  114527. */
  114528. RUNNING = 1,
  114529. /**
  114530. * Done
  114531. */
  114532. DONE = 2,
  114533. /**
  114534. * Error
  114535. */
  114536. ERROR = 3
  114537. }
  114538. /**
  114539. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  114540. */
  114541. export abstract class AbstractAssetTask {
  114542. /**
  114543. * Task name
  114544. */ name: string;
  114545. /**
  114546. * Callback called when the task is successful
  114547. */
  114548. onSuccess: (task: any) => void;
  114549. /**
  114550. * Callback called when the task is not successful
  114551. */
  114552. onError: (task: any, message?: string, exception?: any) => void;
  114553. /**
  114554. * Creates a new AssetsManager
  114555. * @param name defines the name of the task
  114556. */
  114557. constructor(
  114558. /**
  114559. * Task name
  114560. */ name: string);
  114561. private _isCompleted;
  114562. private _taskState;
  114563. private _errorObject;
  114564. /**
  114565. * Get if the task is completed
  114566. */
  114567. readonly isCompleted: boolean;
  114568. /**
  114569. * Gets the current state of the task
  114570. */
  114571. readonly taskState: AssetTaskState;
  114572. /**
  114573. * Gets the current error object (if task is in error)
  114574. */
  114575. readonly errorObject: {
  114576. message?: string;
  114577. exception?: any;
  114578. };
  114579. /**
  114580. * Internal only
  114581. * @hidden
  114582. */
  114583. _setErrorObject(message?: string, exception?: any): void;
  114584. /**
  114585. * Execute the current task
  114586. * @param scene defines the scene where you want your assets to be loaded
  114587. * @param onSuccess is a callback called when the task is successfully executed
  114588. * @param onError is a callback called if an error occurs
  114589. */
  114590. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114591. /**
  114592. * Execute the current task
  114593. * @param scene defines the scene where you want your assets to be loaded
  114594. * @param onSuccess is a callback called when the task is successfully executed
  114595. * @param onError is a callback called if an error occurs
  114596. */
  114597. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114598. /**
  114599. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  114600. * This can be used with failed tasks that have the reason for failure fixed.
  114601. */
  114602. reset(): void;
  114603. private onErrorCallback;
  114604. private onDoneCallback;
  114605. }
  114606. /**
  114607. * Define the interface used by progress events raised during assets loading
  114608. */
  114609. export interface IAssetsProgressEvent {
  114610. /**
  114611. * Defines the number of remaining tasks to process
  114612. */
  114613. remainingCount: number;
  114614. /**
  114615. * Defines the total number of tasks
  114616. */
  114617. totalCount: number;
  114618. /**
  114619. * Defines the task that was just processed
  114620. */
  114621. task: AbstractAssetTask;
  114622. }
  114623. /**
  114624. * Class used to share progress information about assets loading
  114625. */
  114626. export class AssetsProgressEvent implements IAssetsProgressEvent {
  114627. /**
  114628. * Defines the number of remaining tasks to process
  114629. */
  114630. remainingCount: number;
  114631. /**
  114632. * Defines the total number of tasks
  114633. */
  114634. totalCount: number;
  114635. /**
  114636. * Defines the task that was just processed
  114637. */
  114638. task: AbstractAssetTask;
  114639. /**
  114640. * Creates a AssetsProgressEvent
  114641. * @param remainingCount defines the number of remaining tasks to process
  114642. * @param totalCount defines the total number of tasks
  114643. * @param task defines the task that was just processed
  114644. */
  114645. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  114646. }
  114647. /**
  114648. * Define a task used by AssetsManager to load meshes
  114649. */
  114650. export class MeshAssetTask extends AbstractAssetTask {
  114651. /**
  114652. * Defines the name of the task
  114653. */
  114654. name: string;
  114655. /**
  114656. * Defines the list of mesh's names you want to load
  114657. */
  114658. meshesNames: any;
  114659. /**
  114660. * Defines the root url to use as a base to load your meshes and associated resources
  114661. */
  114662. rootUrl: string;
  114663. /**
  114664. * Defines the filename of the scene to load from
  114665. */
  114666. sceneFilename: string;
  114667. /**
  114668. * Gets the list of loaded meshes
  114669. */
  114670. loadedMeshes: Array<AbstractMesh>;
  114671. /**
  114672. * Gets the list of loaded particle systems
  114673. */
  114674. loadedParticleSystems: Array<IParticleSystem>;
  114675. /**
  114676. * Gets the list of loaded skeletons
  114677. */
  114678. loadedSkeletons: Array<Skeleton>;
  114679. /**
  114680. * Gets the list of loaded animation groups
  114681. */
  114682. loadedAnimationGroups: Array<AnimationGroup>;
  114683. /**
  114684. * Callback called when the task is successful
  114685. */
  114686. onSuccess: (task: MeshAssetTask) => void;
  114687. /**
  114688. * Callback called when the task is successful
  114689. */
  114690. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  114691. /**
  114692. * Creates a new MeshAssetTask
  114693. * @param name defines the name of the task
  114694. * @param meshesNames defines the list of mesh's names you want to load
  114695. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  114696. * @param sceneFilename defines the filename of the scene to load from
  114697. */
  114698. constructor(
  114699. /**
  114700. * Defines the name of the task
  114701. */
  114702. name: string,
  114703. /**
  114704. * Defines the list of mesh's names you want to load
  114705. */
  114706. meshesNames: any,
  114707. /**
  114708. * Defines the root url to use as a base to load your meshes and associated resources
  114709. */
  114710. rootUrl: string,
  114711. /**
  114712. * Defines the filename of the scene to load from
  114713. */
  114714. sceneFilename: string);
  114715. /**
  114716. * Execute the current task
  114717. * @param scene defines the scene where you want your assets to be loaded
  114718. * @param onSuccess is a callback called when the task is successfully executed
  114719. * @param onError is a callback called if an error occurs
  114720. */
  114721. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114722. }
  114723. /**
  114724. * Define a task used by AssetsManager to load text content
  114725. */
  114726. export class TextFileAssetTask extends AbstractAssetTask {
  114727. /**
  114728. * Defines the name of the task
  114729. */
  114730. name: string;
  114731. /**
  114732. * Defines the location of the file to load
  114733. */
  114734. url: string;
  114735. /**
  114736. * Gets the loaded text string
  114737. */
  114738. text: string;
  114739. /**
  114740. * Callback called when the task is successful
  114741. */
  114742. onSuccess: (task: TextFileAssetTask) => void;
  114743. /**
  114744. * Callback called when the task is successful
  114745. */
  114746. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  114747. /**
  114748. * Creates a new TextFileAssetTask object
  114749. * @param name defines the name of the task
  114750. * @param url defines the location of the file to load
  114751. */
  114752. constructor(
  114753. /**
  114754. * Defines the name of the task
  114755. */
  114756. name: string,
  114757. /**
  114758. * Defines the location of the file to load
  114759. */
  114760. url: string);
  114761. /**
  114762. * Execute the current task
  114763. * @param scene defines the scene where you want your assets to be loaded
  114764. * @param onSuccess is a callback called when the task is successfully executed
  114765. * @param onError is a callback called if an error occurs
  114766. */
  114767. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114768. }
  114769. /**
  114770. * Define a task used by AssetsManager to load binary data
  114771. */
  114772. export class BinaryFileAssetTask extends AbstractAssetTask {
  114773. /**
  114774. * Defines the name of the task
  114775. */
  114776. name: string;
  114777. /**
  114778. * Defines the location of the file to load
  114779. */
  114780. url: string;
  114781. /**
  114782. * Gets the lodaded data (as an array buffer)
  114783. */
  114784. data: ArrayBuffer;
  114785. /**
  114786. * Callback called when the task is successful
  114787. */
  114788. onSuccess: (task: BinaryFileAssetTask) => void;
  114789. /**
  114790. * Callback called when the task is successful
  114791. */
  114792. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  114793. /**
  114794. * Creates a new BinaryFileAssetTask object
  114795. * @param name defines the name of the new task
  114796. * @param url defines the location of the file to load
  114797. */
  114798. constructor(
  114799. /**
  114800. * Defines the name of the task
  114801. */
  114802. name: string,
  114803. /**
  114804. * Defines the location of the file to load
  114805. */
  114806. url: string);
  114807. /**
  114808. * Execute the current task
  114809. * @param scene defines the scene where you want your assets to be loaded
  114810. * @param onSuccess is a callback called when the task is successfully executed
  114811. * @param onError is a callback called if an error occurs
  114812. */
  114813. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114814. }
  114815. /**
  114816. * Define a task used by AssetsManager to load images
  114817. */
  114818. export class ImageAssetTask extends AbstractAssetTask {
  114819. /**
  114820. * Defines the name of the task
  114821. */
  114822. name: string;
  114823. /**
  114824. * Defines the location of the image to load
  114825. */
  114826. url: string;
  114827. /**
  114828. * Gets the loaded images
  114829. */
  114830. image: HTMLImageElement;
  114831. /**
  114832. * Callback called when the task is successful
  114833. */
  114834. onSuccess: (task: ImageAssetTask) => void;
  114835. /**
  114836. * Callback called when the task is successful
  114837. */
  114838. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  114839. /**
  114840. * Creates a new ImageAssetTask
  114841. * @param name defines the name of the task
  114842. * @param url defines the location of the image to load
  114843. */
  114844. constructor(
  114845. /**
  114846. * Defines the name of the task
  114847. */
  114848. name: string,
  114849. /**
  114850. * Defines the location of the image to load
  114851. */
  114852. url: string);
  114853. /**
  114854. * Execute the current task
  114855. * @param scene defines the scene where you want your assets to be loaded
  114856. * @param onSuccess is a callback called when the task is successfully executed
  114857. * @param onError is a callback called if an error occurs
  114858. */
  114859. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114860. }
  114861. /**
  114862. * Defines the interface used by texture loading tasks
  114863. */
  114864. export interface ITextureAssetTask<TEX extends BaseTexture> {
  114865. /**
  114866. * Gets the loaded texture
  114867. */
  114868. texture: TEX;
  114869. }
  114870. /**
  114871. * Define a task used by AssetsManager to load 2D textures
  114872. */
  114873. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  114874. /**
  114875. * Defines the name of the task
  114876. */
  114877. name: string;
  114878. /**
  114879. * Defines the location of the file to load
  114880. */
  114881. url: string;
  114882. /**
  114883. * Defines if mipmap should not be generated (default is false)
  114884. */
  114885. noMipmap?: boolean | undefined;
  114886. /**
  114887. * Defines if texture must be inverted on Y axis (default is false)
  114888. */
  114889. invertY?: boolean | undefined;
  114890. /**
  114891. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114892. */
  114893. samplingMode: number;
  114894. /**
  114895. * Gets the loaded texture
  114896. */
  114897. texture: Texture;
  114898. /**
  114899. * Callback called when the task is successful
  114900. */
  114901. onSuccess: (task: TextureAssetTask) => void;
  114902. /**
  114903. * Callback called when the task is successful
  114904. */
  114905. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  114906. /**
  114907. * Creates a new TextureAssetTask object
  114908. * @param name defines the name of the task
  114909. * @param url defines the location of the file to load
  114910. * @param noMipmap defines if mipmap should not be generated (default is false)
  114911. * @param invertY defines if texture must be inverted on Y axis (default is false)
  114912. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114913. */
  114914. constructor(
  114915. /**
  114916. * Defines the name of the task
  114917. */
  114918. name: string,
  114919. /**
  114920. * Defines the location of the file to load
  114921. */
  114922. url: string,
  114923. /**
  114924. * Defines if mipmap should not be generated (default is false)
  114925. */
  114926. noMipmap?: boolean | undefined,
  114927. /**
  114928. * Defines if texture must be inverted on Y axis (default is false)
  114929. */
  114930. invertY?: boolean | undefined,
  114931. /**
  114932. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114933. */
  114934. samplingMode?: number);
  114935. /**
  114936. * Execute the current task
  114937. * @param scene defines the scene where you want your assets to be loaded
  114938. * @param onSuccess is a callback called when the task is successfully executed
  114939. * @param onError is a callback called if an error occurs
  114940. */
  114941. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114942. }
  114943. /**
  114944. * Define a task used by AssetsManager to load cube textures
  114945. */
  114946. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  114947. /**
  114948. * Defines the name of the task
  114949. */
  114950. name: string;
  114951. /**
  114952. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114953. */
  114954. url: string;
  114955. /**
  114956. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114957. */
  114958. extensions?: string[] | undefined;
  114959. /**
  114960. * Defines if mipmaps should not be generated (default is false)
  114961. */
  114962. noMipmap?: boolean | undefined;
  114963. /**
  114964. * Defines the explicit list of files (undefined by default)
  114965. */
  114966. files?: string[] | undefined;
  114967. /**
  114968. * Gets the loaded texture
  114969. */
  114970. texture: CubeTexture;
  114971. /**
  114972. * Callback called when the task is successful
  114973. */
  114974. onSuccess: (task: CubeTextureAssetTask) => void;
  114975. /**
  114976. * Callback called when the task is successful
  114977. */
  114978. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  114979. /**
  114980. * Creates a new CubeTextureAssetTask
  114981. * @param name defines the name of the task
  114982. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114983. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114984. * @param noMipmap defines if mipmaps should not be generated (default is false)
  114985. * @param files defines the explicit list of files (undefined by default)
  114986. */
  114987. constructor(
  114988. /**
  114989. * Defines the name of the task
  114990. */
  114991. name: string,
  114992. /**
  114993. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114994. */
  114995. url: string,
  114996. /**
  114997. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114998. */
  114999. extensions?: string[] | undefined,
  115000. /**
  115001. * Defines if mipmaps should not be generated (default is false)
  115002. */
  115003. noMipmap?: boolean | undefined,
  115004. /**
  115005. * Defines the explicit list of files (undefined by default)
  115006. */
  115007. files?: string[] | undefined);
  115008. /**
  115009. * Execute the current task
  115010. * @param scene defines the scene where you want your assets to be loaded
  115011. * @param onSuccess is a callback called when the task is successfully executed
  115012. * @param onError is a callback called if an error occurs
  115013. */
  115014. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115015. }
  115016. /**
  115017. * Define a task used by AssetsManager to load HDR cube textures
  115018. */
  115019. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  115020. /**
  115021. * Defines the name of the task
  115022. */
  115023. name: string;
  115024. /**
  115025. * Defines the location of the file to load
  115026. */
  115027. url: string;
  115028. /**
  115029. * Defines the desired size (the more it increases the longer the generation will be)
  115030. */
  115031. size: number;
  115032. /**
  115033. * Defines if mipmaps should not be generated (default is false)
  115034. */
  115035. noMipmap: boolean;
  115036. /**
  115037. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115038. */
  115039. generateHarmonics: boolean;
  115040. /**
  115041. * 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)
  115042. */
  115043. gammaSpace: boolean;
  115044. /**
  115045. * Internal Use Only
  115046. */
  115047. reserved: boolean;
  115048. /**
  115049. * Gets the loaded texture
  115050. */
  115051. texture: HDRCubeTexture;
  115052. /**
  115053. * Callback called when the task is successful
  115054. */
  115055. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  115056. /**
  115057. * Callback called when the task is successful
  115058. */
  115059. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  115060. /**
  115061. * Creates a new HDRCubeTextureAssetTask object
  115062. * @param name defines the name of the task
  115063. * @param url defines the location of the file to load
  115064. * @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.
  115065. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115066. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115067. * @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)
  115068. * @param reserved Internal use only
  115069. */
  115070. constructor(
  115071. /**
  115072. * Defines the name of the task
  115073. */
  115074. name: string,
  115075. /**
  115076. * Defines the location of the file to load
  115077. */
  115078. url: string,
  115079. /**
  115080. * Defines the desired size (the more it increases the longer the generation will be)
  115081. */
  115082. size: number,
  115083. /**
  115084. * Defines if mipmaps should not be generated (default is false)
  115085. */
  115086. noMipmap?: boolean,
  115087. /**
  115088. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115089. */
  115090. generateHarmonics?: boolean,
  115091. /**
  115092. * 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)
  115093. */
  115094. gammaSpace?: boolean,
  115095. /**
  115096. * Internal Use Only
  115097. */
  115098. reserved?: boolean);
  115099. /**
  115100. * Execute the current task
  115101. * @param scene defines the scene where you want your assets to be loaded
  115102. * @param onSuccess is a callback called when the task is successfully executed
  115103. * @param onError is a callback called if an error occurs
  115104. */
  115105. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115106. }
  115107. /**
  115108. * Define a task used by AssetsManager to load Equirectangular cube textures
  115109. */
  115110. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  115111. /**
  115112. * Defines the name of the task
  115113. */
  115114. name: string;
  115115. /**
  115116. * Defines the location of the file to load
  115117. */
  115118. url: string;
  115119. /**
  115120. * Defines the desired size (the more it increases the longer the generation will be)
  115121. */
  115122. size: number;
  115123. /**
  115124. * Defines if mipmaps should not be generated (default is false)
  115125. */
  115126. noMipmap: boolean;
  115127. /**
  115128. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  115129. * but the standard material would require them in Gamma space) (default is true)
  115130. */
  115131. gammaSpace: boolean;
  115132. /**
  115133. * Gets the loaded texture
  115134. */
  115135. texture: EquiRectangularCubeTexture;
  115136. /**
  115137. * Callback called when the task is successful
  115138. */
  115139. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  115140. /**
  115141. * Callback called when the task is successful
  115142. */
  115143. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  115144. /**
  115145. * Creates a new EquiRectangularCubeTextureAssetTask object
  115146. * @param name defines the name of the task
  115147. * @param url defines the location of the file to load
  115148. * @param size defines the desired size (the more it increases the longer the generation will be)
  115149. * If the size is omitted this implies you are using a preprocessed cubemap.
  115150. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115151. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  115152. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  115153. * (default is true)
  115154. */
  115155. constructor(
  115156. /**
  115157. * Defines the name of the task
  115158. */
  115159. name: string,
  115160. /**
  115161. * Defines the location of the file to load
  115162. */
  115163. url: string,
  115164. /**
  115165. * Defines the desired size (the more it increases the longer the generation will be)
  115166. */
  115167. size: number,
  115168. /**
  115169. * Defines if mipmaps should not be generated (default is false)
  115170. */
  115171. noMipmap?: boolean,
  115172. /**
  115173. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  115174. * but the standard material would require them in Gamma space) (default is true)
  115175. */
  115176. gammaSpace?: boolean);
  115177. /**
  115178. * Execute the current task
  115179. * @param scene defines the scene where you want your assets to be loaded
  115180. * @param onSuccess is a callback called when the task is successfully executed
  115181. * @param onError is a callback called if an error occurs
  115182. */
  115183. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115184. }
  115185. /**
  115186. * This class can be used to easily import assets into a scene
  115187. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  115188. */
  115189. export class AssetsManager {
  115190. private _scene;
  115191. private _isLoading;
  115192. protected _tasks: AbstractAssetTask[];
  115193. protected _waitingTasksCount: number;
  115194. protected _totalTasksCount: number;
  115195. /**
  115196. * Callback called when all tasks are processed
  115197. */
  115198. onFinish: (tasks: AbstractAssetTask[]) => void;
  115199. /**
  115200. * Callback called when a task is successful
  115201. */
  115202. onTaskSuccess: (task: AbstractAssetTask) => void;
  115203. /**
  115204. * Callback called when a task had an error
  115205. */
  115206. onTaskError: (task: AbstractAssetTask) => void;
  115207. /**
  115208. * Callback called when a task is done (whatever the result is)
  115209. */
  115210. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  115211. /**
  115212. * Observable called when all tasks are processed
  115213. */
  115214. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  115215. /**
  115216. * Observable called when a task had an error
  115217. */
  115218. onTaskErrorObservable: Observable<AbstractAssetTask>;
  115219. /**
  115220. * Observable called when all tasks were executed
  115221. */
  115222. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  115223. /**
  115224. * Observable called when a task is done (whatever the result is)
  115225. */
  115226. onProgressObservable: Observable<IAssetsProgressEvent>;
  115227. /**
  115228. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  115229. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115230. */
  115231. useDefaultLoadingScreen: boolean;
  115232. /**
  115233. * Creates a new AssetsManager
  115234. * @param scene defines the scene to work on
  115235. */
  115236. constructor(scene: Scene);
  115237. /**
  115238. * Add a MeshAssetTask to the list of active tasks
  115239. * @param taskName defines the name of the new task
  115240. * @param meshesNames defines the name of meshes to load
  115241. * @param rootUrl defines the root url to use to locate files
  115242. * @param sceneFilename defines the filename of the scene file
  115243. * @returns a new MeshAssetTask object
  115244. */
  115245. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  115246. /**
  115247. * Add a TextFileAssetTask to the list of active tasks
  115248. * @param taskName defines the name of the new task
  115249. * @param url defines the url of the file to load
  115250. * @returns a new TextFileAssetTask object
  115251. */
  115252. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  115253. /**
  115254. * Add a BinaryFileAssetTask to the list of active tasks
  115255. * @param taskName defines the name of the new task
  115256. * @param url defines the url of the file to load
  115257. * @returns a new BinaryFileAssetTask object
  115258. */
  115259. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  115260. /**
  115261. * Add a ImageAssetTask to the list of active tasks
  115262. * @param taskName defines the name of the new task
  115263. * @param url defines the url of the file to load
  115264. * @returns a new ImageAssetTask object
  115265. */
  115266. addImageTask(taskName: string, url: string): ImageAssetTask;
  115267. /**
  115268. * Add a TextureAssetTask to the list of active tasks
  115269. * @param taskName defines the name of the new task
  115270. * @param url defines the url of the file to load
  115271. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115272. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  115273. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  115274. * @returns a new TextureAssetTask object
  115275. */
  115276. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  115277. /**
  115278. * Add a CubeTextureAssetTask to the list of active tasks
  115279. * @param taskName defines the name of the new task
  115280. * @param url defines the url of the file to load
  115281. * @param extensions defines the extension to use to load the cube map (can be null)
  115282. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115283. * @param files defines the list of files to load (can be null)
  115284. * @returns a new CubeTextureAssetTask object
  115285. */
  115286. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  115287. /**
  115288. *
  115289. * Add a HDRCubeTextureAssetTask to the list of active tasks
  115290. * @param taskName defines the name of the new task
  115291. * @param url defines the url of the file to load
  115292. * @param size defines the size you want for the cubemap (can be null)
  115293. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115294. * @param generateHarmonics defines if you want to automatically generate (true by default)
  115295. * @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)
  115296. * @param reserved Internal use only
  115297. * @returns a new HDRCubeTextureAssetTask object
  115298. */
  115299. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  115300. /**
  115301. *
  115302. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  115303. * @param taskName defines the name of the new task
  115304. * @param url defines the url of the file to load
  115305. * @param size defines the size you want for the cubemap (can be null)
  115306. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115307. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  115308. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  115309. * @returns a new EquiRectangularCubeTextureAssetTask object
  115310. */
  115311. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  115312. /**
  115313. * Remove a task from the assets manager.
  115314. * @param task the task to remove
  115315. */
  115316. removeTask(task: AbstractAssetTask): void;
  115317. private _decreaseWaitingTasksCount;
  115318. private _runTask;
  115319. /**
  115320. * Reset the AssetsManager and remove all tasks
  115321. * @return the current instance of the AssetsManager
  115322. */
  115323. reset(): AssetsManager;
  115324. /**
  115325. * Start the loading process
  115326. * @return the current instance of the AssetsManager
  115327. */
  115328. load(): AssetsManager;
  115329. /**
  115330. * Start the loading process as an async operation
  115331. * @return a promise returning the list of failed tasks
  115332. */
  115333. loadAsync(): Promise<void>;
  115334. }
  115335. }
  115336. declare module BABYLON {
  115337. /**
  115338. * Wrapper class for promise with external resolve and reject.
  115339. */
  115340. export class Deferred<T> {
  115341. /**
  115342. * The promise associated with this deferred object.
  115343. */
  115344. readonly promise: Promise<T>;
  115345. private _resolve;
  115346. private _reject;
  115347. /**
  115348. * The resolve method of the promise associated with this deferred object.
  115349. */
  115350. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  115351. /**
  115352. * The reject method of the promise associated with this deferred object.
  115353. */
  115354. readonly reject: (reason?: any) => void;
  115355. /**
  115356. * Constructor for this deferred object.
  115357. */
  115358. constructor();
  115359. }
  115360. }
  115361. declare module BABYLON {
  115362. /**
  115363. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  115364. */
  115365. export class MeshExploder {
  115366. private _centerMesh;
  115367. private _meshes;
  115368. private _meshesOrigins;
  115369. private _toCenterVectors;
  115370. private _scaledDirection;
  115371. private _newPosition;
  115372. private _centerPosition;
  115373. /**
  115374. * Explodes meshes from a center mesh.
  115375. * @param meshes The meshes to explode.
  115376. * @param centerMesh The mesh to be center of explosion.
  115377. */
  115378. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  115379. private _setCenterMesh;
  115380. /**
  115381. * Get class name
  115382. * @returns "MeshExploder"
  115383. */
  115384. getClassName(): string;
  115385. /**
  115386. * "Exploded meshes"
  115387. * @returns Array of meshes with the centerMesh at index 0.
  115388. */
  115389. getMeshes(): Array<Mesh>;
  115390. /**
  115391. * Explodes meshes giving a specific direction
  115392. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  115393. */
  115394. explode(direction?: number): void;
  115395. }
  115396. }
  115397. declare module BABYLON {
  115398. /**
  115399. * Class used to help managing file picking and drag'n'drop
  115400. */
  115401. export class FilesInput {
  115402. /**
  115403. * List of files ready to be loaded
  115404. */
  115405. static readonly FilesToLoad: {
  115406. [key: string]: File;
  115407. };
  115408. /**
  115409. * Callback called when a file is processed
  115410. */
  115411. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  115412. private _engine;
  115413. private _currentScene;
  115414. private _sceneLoadedCallback;
  115415. private _progressCallback;
  115416. private _additionalRenderLoopLogicCallback;
  115417. private _textureLoadingCallback;
  115418. private _startingProcessingFilesCallback;
  115419. private _onReloadCallback;
  115420. private _errorCallback;
  115421. private _elementToMonitor;
  115422. private _sceneFileToLoad;
  115423. private _filesToLoad;
  115424. /**
  115425. * Creates a new FilesInput
  115426. * @param engine defines the rendering engine
  115427. * @param scene defines the hosting scene
  115428. * @param sceneLoadedCallback callback called when scene is loaded
  115429. * @param progressCallback callback called to track progress
  115430. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  115431. * @param textureLoadingCallback callback called when a texture is loading
  115432. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  115433. * @param onReloadCallback callback called when a reload is requested
  115434. * @param errorCallback callback call if an error occurs
  115435. */
  115436. 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);
  115437. private _dragEnterHandler;
  115438. private _dragOverHandler;
  115439. private _dropHandler;
  115440. /**
  115441. * Calls this function to listen to drag'n'drop events on a specific DOM element
  115442. * @param elementToMonitor defines the DOM element to track
  115443. */
  115444. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  115445. /**
  115446. * Release all associated resources
  115447. */
  115448. dispose(): void;
  115449. private renderFunction;
  115450. private drag;
  115451. private drop;
  115452. private _traverseFolder;
  115453. private _processFiles;
  115454. /**
  115455. * Load files from a drop event
  115456. * @param event defines the drop event to use as source
  115457. */
  115458. loadFiles(event: any): void;
  115459. private _processReload;
  115460. /**
  115461. * Reload the current scene from the loaded files
  115462. */
  115463. reload(): void;
  115464. }
  115465. }
  115466. declare module BABYLON {
  115467. /**
  115468. * Defines the root class used to create scene optimization to use with SceneOptimizer
  115469. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115470. */
  115471. export class SceneOptimization {
  115472. /**
  115473. * Defines the priority of this optimization (0 by default which means first in the list)
  115474. */
  115475. priority: number;
  115476. /**
  115477. * Gets a string describing the action executed by the current optimization
  115478. * @returns description string
  115479. */
  115480. getDescription(): string;
  115481. /**
  115482. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115483. * @param scene defines the current scene where to apply this optimization
  115484. * @param optimizer defines the current optimizer
  115485. * @returns true if everything that can be done was applied
  115486. */
  115487. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115488. /**
  115489. * Creates the SceneOptimization object
  115490. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115491. * @param desc defines the description associated with the optimization
  115492. */
  115493. constructor(
  115494. /**
  115495. * Defines the priority of this optimization (0 by default which means first in the list)
  115496. */
  115497. priority?: number);
  115498. }
  115499. /**
  115500. * Defines an optimization used to reduce the size of render target textures
  115501. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115502. */
  115503. export class TextureOptimization extends SceneOptimization {
  115504. /**
  115505. * Defines the priority of this optimization (0 by default which means first in the list)
  115506. */
  115507. priority: number;
  115508. /**
  115509. * 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
  115510. */
  115511. maximumSize: number;
  115512. /**
  115513. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115514. */
  115515. step: number;
  115516. /**
  115517. * Gets a string describing the action executed by the current optimization
  115518. * @returns description string
  115519. */
  115520. getDescription(): string;
  115521. /**
  115522. * Creates the TextureOptimization object
  115523. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115524. * @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
  115525. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115526. */
  115527. constructor(
  115528. /**
  115529. * Defines the priority of this optimization (0 by default which means first in the list)
  115530. */
  115531. priority?: number,
  115532. /**
  115533. * 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
  115534. */
  115535. maximumSize?: number,
  115536. /**
  115537. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115538. */
  115539. step?: number);
  115540. /**
  115541. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115542. * @param scene defines the current scene where to apply this optimization
  115543. * @param optimizer defines the current optimizer
  115544. * @returns true if everything that can be done was applied
  115545. */
  115546. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115547. }
  115548. /**
  115549. * Defines an optimization used to increase or decrease the rendering resolution
  115550. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115551. */
  115552. export class HardwareScalingOptimization extends SceneOptimization {
  115553. /**
  115554. * Defines the priority of this optimization (0 by default which means first in the list)
  115555. */
  115556. priority: number;
  115557. /**
  115558. * Defines the maximum scale to use (2 by default)
  115559. */
  115560. maximumScale: number;
  115561. /**
  115562. * Defines the step to use between two passes (0.5 by default)
  115563. */
  115564. step: number;
  115565. private _currentScale;
  115566. private _directionOffset;
  115567. /**
  115568. * Gets a string describing the action executed by the current optimization
  115569. * @return description string
  115570. */
  115571. getDescription(): string;
  115572. /**
  115573. * Creates the HardwareScalingOptimization object
  115574. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115575. * @param maximumScale defines the maximum scale to use (2 by default)
  115576. * @param step defines the step to use between two passes (0.5 by default)
  115577. */
  115578. constructor(
  115579. /**
  115580. * Defines the priority of this optimization (0 by default which means first in the list)
  115581. */
  115582. priority?: number,
  115583. /**
  115584. * Defines the maximum scale to use (2 by default)
  115585. */
  115586. maximumScale?: number,
  115587. /**
  115588. * Defines the step to use between two passes (0.5 by default)
  115589. */
  115590. step?: number);
  115591. /**
  115592. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115593. * @param scene defines the current scene where to apply this optimization
  115594. * @param optimizer defines the current optimizer
  115595. * @returns true if everything that can be done was applied
  115596. */
  115597. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115598. }
  115599. /**
  115600. * Defines an optimization used to remove shadows
  115601. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115602. */
  115603. export class ShadowsOptimization extends SceneOptimization {
  115604. /**
  115605. * Gets a string describing the action executed by the current optimization
  115606. * @return description string
  115607. */
  115608. getDescription(): string;
  115609. /**
  115610. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115611. * @param scene defines the current scene where to apply this optimization
  115612. * @param optimizer defines the current optimizer
  115613. * @returns true if everything that can be done was applied
  115614. */
  115615. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115616. }
  115617. /**
  115618. * Defines an optimization used to turn post-processes off
  115619. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115620. */
  115621. export class PostProcessesOptimization extends SceneOptimization {
  115622. /**
  115623. * Gets a string describing the action executed by the current optimization
  115624. * @return description string
  115625. */
  115626. getDescription(): string;
  115627. /**
  115628. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115629. * @param scene defines the current scene where to apply this optimization
  115630. * @param optimizer defines the current optimizer
  115631. * @returns true if everything that can be done was applied
  115632. */
  115633. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115634. }
  115635. /**
  115636. * Defines an optimization used to turn lens flares off
  115637. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115638. */
  115639. export class LensFlaresOptimization extends SceneOptimization {
  115640. /**
  115641. * Gets a string describing the action executed by the current optimization
  115642. * @return description string
  115643. */
  115644. getDescription(): string;
  115645. /**
  115646. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115647. * @param scene defines the current scene where to apply this optimization
  115648. * @param optimizer defines the current optimizer
  115649. * @returns true if everything that can be done was applied
  115650. */
  115651. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115652. }
  115653. /**
  115654. * Defines an optimization based on user defined callback.
  115655. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115656. */
  115657. export class CustomOptimization extends SceneOptimization {
  115658. /**
  115659. * Callback called to apply the custom optimization.
  115660. */
  115661. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  115662. /**
  115663. * Callback called to get custom description
  115664. */
  115665. onGetDescription: () => string;
  115666. /**
  115667. * Gets a string describing the action executed by the current optimization
  115668. * @returns description string
  115669. */
  115670. getDescription(): string;
  115671. /**
  115672. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115673. * @param scene defines the current scene where to apply this optimization
  115674. * @param optimizer defines the current optimizer
  115675. * @returns true if everything that can be done was applied
  115676. */
  115677. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115678. }
  115679. /**
  115680. * Defines an optimization used to turn particles off
  115681. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115682. */
  115683. export class ParticlesOptimization extends SceneOptimization {
  115684. /**
  115685. * Gets a string describing the action executed by the current optimization
  115686. * @return description string
  115687. */
  115688. getDescription(): string;
  115689. /**
  115690. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115691. * @param scene defines the current scene where to apply this optimization
  115692. * @param optimizer defines the current optimizer
  115693. * @returns true if everything that can be done was applied
  115694. */
  115695. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115696. }
  115697. /**
  115698. * Defines an optimization used to turn render targets off
  115699. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115700. */
  115701. export class RenderTargetsOptimization extends SceneOptimization {
  115702. /**
  115703. * Gets a string describing the action executed by the current optimization
  115704. * @return description string
  115705. */
  115706. getDescription(): string;
  115707. /**
  115708. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115709. * @param scene defines the current scene where to apply this optimization
  115710. * @param optimizer defines the current optimizer
  115711. * @returns true if everything that can be done was applied
  115712. */
  115713. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115714. }
  115715. /**
  115716. * Defines an optimization used to merge meshes with compatible materials
  115717. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115718. */
  115719. export class MergeMeshesOptimization extends SceneOptimization {
  115720. private static _UpdateSelectionTree;
  115721. /**
  115722. * Gets or sets a boolean which defines if optimization octree has to be updated
  115723. */
  115724. /**
  115725. * Gets or sets a boolean which defines if optimization octree has to be updated
  115726. */
  115727. static UpdateSelectionTree: boolean;
  115728. /**
  115729. * Gets a string describing the action executed by the current optimization
  115730. * @return description string
  115731. */
  115732. getDescription(): string;
  115733. private _canBeMerged;
  115734. /**
  115735. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115736. * @param scene defines the current scene where to apply this optimization
  115737. * @param optimizer defines the current optimizer
  115738. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  115739. * @returns true if everything that can be done was applied
  115740. */
  115741. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  115742. }
  115743. /**
  115744. * Defines a list of options used by SceneOptimizer
  115745. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115746. */
  115747. export class SceneOptimizerOptions {
  115748. /**
  115749. * Defines the target frame rate to reach (60 by default)
  115750. */
  115751. targetFrameRate: number;
  115752. /**
  115753. * Defines the interval between two checkes (2000ms by default)
  115754. */
  115755. trackerDuration: number;
  115756. /**
  115757. * Gets the list of optimizations to apply
  115758. */
  115759. optimizations: SceneOptimization[];
  115760. /**
  115761. * Creates a new list of options used by SceneOptimizer
  115762. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  115763. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  115764. */
  115765. constructor(
  115766. /**
  115767. * Defines the target frame rate to reach (60 by default)
  115768. */
  115769. targetFrameRate?: number,
  115770. /**
  115771. * Defines the interval between two checkes (2000ms by default)
  115772. */
  115773. trackerDuration?: number);
  115774. /**
  115775. * Add a new optimization
  115776. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  115777. * @returns the current SceneOptimizerOptions
  115778. */
  115779. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  115780. /**
  115781. * Add a new custom optimization
  115782. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  115783. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  115784. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115785. * @returns the current SceneOptimizerOptions
  115786. */
  115787. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  115788. /**
  115789. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  115790. * @param targetFrameRate defines the target frame rate (60 by default)
  115791. * @returns a SceneOptimizerOptions object
  115792. */
  115793. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115794. /**
  115795. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  115796. * @param targetFrameRate defines the target frame rate (60 by default)
  115797. * @returns a SceneOptimizerOptions object
  115798. */
  115799. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115800. /**
  115801. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  115802. * @param targetFrameRate defines the target frame rate (60 by default)
  115803. * @returns a SceneOptimizerOptions object
  115804. */
  115805. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115806. }
  115807. /**
  115808. * Class used to run optimizations in order to reach a target frame rate
  115809. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115810. */
  115811. export class SceneOptimizer implements IDisposable {
  115812. private _isRunning;
  115813. private _options;
  115814. private _scene;
  115815. private _currentPriorityLevel;
  115816. private _targetFrameRate;
  115817. private _trackerDuration;
  115818. private _currentFrameRate;
  115819. private _sceneDisposeObserver;
  115820. private _improvementMode;
  115821. /**
  115822. * Defines an observable called when the optimizer reaches the target frame rate
  115823. */
  115824. onSuccessObservable: Observable<SceneOptimizer>;
  115825. /**
  115826. * Defines an observable called when the optimizer enables an optimization
  115827. */
  115828. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  115829. /**
  115830. * Defines an observable called when the optimizer is not able to reach the target frame rate
  115831. */
  115832. onFailureObservable: Observable<SceneOptimizer>;
  115833. /**
  115834. * Gets a boolean indicating if the optimizer is in improvement mode
  115835. */
  115836. readonly isInImprovementMode: boolean;
  115837. /**
  115838. * Gets the current priority level (0 at start)
  115839. */
  115840. readonly currentPriorityLevel: number;
  115841. /**
  115842. * Gets the current frame rate checked by the SceneOptimizer
  115843. */
  115844. readonly currentFrameRate: number;
  115845. /**
  115846. * Gets or sets the current target frame rate (60 by default)
  115847. */
  115848. /**
  115849. * Gets or sets the current target frame rate (60 by default)
  115850. */
  115851. targetFrameRate: number;
  115852. /**
  115853. * Gets or sets the current interval between two checks (every 2000ms by default)
  115854. */
  115855. /**
  115856. * Gets or sets the current interval between two checks (every 2000ms by default)
  115857. */
  115858. trackerDuration: number;
  115859. /**
  115860. * Gets the list of active optimizations
  115861. */
  115862. readonly optimizations: SceneOptimization[];
  115863. /**
  115864. * Creates a new SceneOptimizer
  115865. * @param scene defines the scene to work on
  115866. * @param options defines the options to use with the SceneOptimizer
  115867. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  115868. * @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)
  115869. */
  115870. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  115871. /**
  115872. * Stops the current optimizer
  115873. */
  115874. stop(): void;
  115875. /**
  115876. * Reset the optimizer to initial step (current priority level = 0)
  115877. */
  115878. reset(): void;
  115879. /**
  115880. * Start the optimizer. By default it will try to reach a specific framerate
  115881. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  115882. */
  115883. start(): void;
  115884. private _checkCurrentState;
  115885. /**
  115886. * Release all resources
  115887. */
  115888. dispose(): void;
  115889. /**
  115890. * Helper function to create a SceneOptimizer with one single line of code
  115891. * @param scene defines the scene to work on
  115892. * @param options defines the options to use with the SceneOptimizer
  115893. * @param onSuccess defines a callback to call on success
  115894. * @param onFailure defines a callback to call on failure
  115895. * @returns the new SceneOptimizer object
  115896. */
  115897. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  115898. }
  115899. }
  115900. declare module BABYLON {
  115901. /**
  115902. * Class used to serialize a scene into a string
  115903. */
  115904. export class SceneSerializer {
  115905. /**
  115906. * Clear cache used by a previous serialization
  115907. */
  115908. static ClearCache(): void;
  115909. /**
  115910. * Serialize a scene into a JSON compatible object
  115911. * @param scene defines the scene to serialize
  115912. * @returns a JSON compatible object
  115913. */
  115914. static Serialize(scene: Scene): any;
  115915. /**
  115916. * Serialize a mesh into a JSON compatible object
  115917. * @param toSerialize defines the mesh to serialize
  115918. * @param withParents defines if parents must be serialized as well
  115919. * @param withChildren defines if children must be serialized as well
  115920. * @returns a JSON compatible object
  115921. */
  115922. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  115923. }
  115924. }
  115925. declare module BABYLON {
  115926. /**
  115927. * Class used to host texture specific utilities
  115928. */
  115929. export class TextureTools {
  115930. /**
  115931. * Uses the GPU to create a copy texture rescaled at a given size
  115932. * @param texture Texture to copy from
  115933. * @param width defines the desired width
  115934. * @param height defines the desired height
  115935. * @param useBilinearMode defines if bilinear mode has to be used
  115936. * @return the generated texture
  115937. */
  115938. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  115939. }
  115940. }
  115941. declare module BABYLON {
  115942. /**
  115943. * This represents the different options avilable for the video capture.
  115944. */
  115945. export interface VideoRecorderOptions {
  115946. /** Defines the mime type of the video */
  115947. mimeType: string;
  115948. /** Defines the video the video should be recorded at */
  115949. fps: number;
  115950. /** Defines the chunk size for the recording data */
  115951. recordChunckSize: number;
  115952. /** The audio tracks to attach to the record */
  115953. audioTracks?: MediaStreamTrack[];
  115954. }
  115955. /**
  115956. * This can helps recording videos from BabylonJS.
  115957. * This is based on the available WebRTC functionalities of the browser.
  115958. *
  115959. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  115960. */
  115961. export class VideoRecorder {
  115962. private static readonly _defaultOptions;
  115963. /**
  115964. * Returns wehther or not the VideoRecorder is available in your browser.
  115965. * @param engine Defines the Babylon Engine to check the support for
  115966. * @returns true if supported otherwise false
  115967. */
  115968. static IsSupported(engine: Engine): boolean;
  115969. private readonly _options;
  115970. private _canvas;
  115971. private _mediaRecorder;
  115972. private _recordedChunks;
  115973. private _fileName;
  115974. private _resolve;
  115975. private _reject;
  115976. /**
  115977. * True wether a recording is already in progress.
  115978. */
  115979. readonly isRecording: boolean;
  115980. /**
  115981. * Create a new VideoCapture object which can help converting what you see in Babylon to
  115982. * a video file.
  115983. * @param engine Defines the BabylonJS Engine you wish to record
  115984. * @param options Defines options that can be used to customized the capture
  115985. */
  115986. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  115987. /**
  115988. * Stops the current recording before the default capture timeout passed in the startRecording
  115989. * functions.
  115990. */
  115991. stopRecording(): void;
  115992. /**
  115993. * Starts recording the canvas for a max duration specified in parameters.
  115994. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  115995. * @param maxDuration Defines the maximum recording time in seconds.
  115996. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  115997. * @return a promise callback at the end of the recording with the video data in Blob.
  115998. */
  115999. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  116000. /**
  116001. * Releases internal resources used during the recording.
  116002. */
  116003. dispose(): void;
  116004. private _handleDataAvailable;
  116005. private _handleError;
  116006. private _handleStop;
  116007. }
  116008. }
  116009. declare module BABYLON {
  116010. /**
  116011. * Class containing a set of static utilities functions for screenshots
  116012. */
  116013. export class ScreenshotTools {
  116014. /**
  116015. * Captures a screenshot of the current rendering
  116016. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  116017. * @param engine defines the rendering engine
  116018. * @param camera defines the source camera
  116019. * @param size This parameter can be set to a single number or to an object with the
  116020. * following (optional) properties: precision, width, height. If a single number is passed,
  116021. * it will be used for both width and height. If an object is passed, the screenshot size
  116022. * will be derived from the parameters. The precision property is a multiplier allowing
  116023. * rendering at a higher or lower resolution
  116024. * @param successCallback defines the callback receives a single parameter which contains the
  116025. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116026. * src parameter of an <img> to display it
  116027. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  116028. * Check your browser for supported MIME types
  116029. */
  116030. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  116031. /**
  116032. * Generates an image screenshot from the specified camera.
  116033. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  116034. * @param engine The engine to use for rendering
  116035. * @param camera The camera to use for rendering
  116036. * @param size This parameter can be set to a single number or to an object with the
  116037. * following (optional) properties: precision, width, height. If a single number is passed,
  116038. * it will be used for both width and height. If an object is passed, the screenshot size
  116039. * will be derived from the parameters. The precision property is a multiplier allowing
  116040. * rendering at a higher or lower resolution
  116041. * @param successCallback The callback receives a single parameter which contains the
  116042. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116043. * src parameter of an <img> to display it
  116044. * @param mimeType The MIME type of the screenshot image (default: image/png).
  116045. * Check your browser for supported MIME types
  116046. * @param samples Texture samples (default: 1)
  116047. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  116048. * @param fileName A name for for the downloaded file.
  116049. */
  116050. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  116051. }
  116052. }
  116053. declare module BABYLON {
  116054. /**
  116055. * A cursor which tracks a point on a path
  116056. */
  116057. export class PathCursor {
  116058. private path;
  116059. /**
  116060. * Stores path cursor callbacks for when an onchange event is triggered
  116061. */
  116062. private _onchange;
  116063. /**
  116064. * The value of the path cursor
  116065. */
  116066. value: number;
  116067. /**
  116068. * The animation array of the path cursor
  116069. */
  116070. animations: Animation[];
  116071. /**
  116072. * Initializes the path cursor
  116073. * @param path The path to track
  116074. */
  116075. constructor(path: Path2);
  116076. /**
  116077. * Gets the cursor point on the path
  116078. * @returns A point on the path cursor at the cursor location
  116079. */
  116080. getPoint(): Vector3;
  116081. /**
  116082. * Moves the cursor ahead by the step amount
  116083. * @param step The amount to move the cursor forward
  116084. * @returns This path cursor
  116085. */
  116086. moveAhead(step?: number): PathCursor;
  116087. /**
  116088. * Moves the cursor behind by the step amount
  116089. * @param step The amount to move the cursor back
  116090. * @returns This path cursor
  116091. */
  116092. moveBack(step?: number): PathCursor;
  116093. /**
  116094. * Moves the cursor by the step amount
  116095. * If the step amount is greater than one, an exception is thrown
  116096. * @param step The amount to move the cursor
  116097. * @returns This path cursor
  116098. */
  116099. move(step: number): PathCursor;
  116100. /**
  116101. * Ensures that the value is limited between zero and one
  116102. * @returns This path cursor
  116103. */
  116104. private ensureLimits;
  116105. /**
  116106. * Runs onchange callbacks on change (used by the animation engine)
  116107. * @returns This path cursor
  116108. */
  116109. private raiseOnChange;
  116110. /**
  116111. * Executes a function on change
  116112. * @param f A path cursor onchange callback
  116113. * @returns This path cursor
  116114. */
  116115. onchange(f: (cursor: PathCursor) => void): PathCursor;
  116116. }
  116117. }
  116118. declare module BABYLON {
  116119. /** @hidden */
  116120. export var blurPixelShader: {
  116121. name: string;
  116122. shader: string;
  116123. };
  116124. }
  116125. declare module BABYLON {
  116126. /** @hidden */
  116127. export var bones300Declaration: {
  116128. name: string;
  116129. shader: string;
  116130. };
  116131. }
  116132. declare module BABYLON {
  116133. /** @hidden */
  116134. export var instances300Declaration: {
  116135. name: string;
  116136. shader: string;
  116137. };
  116138. }
  116139. declare module BABYLON {
  116140. /** @hidden */
  116141. export var pointCloudVertexDeclaration: {
  116142. name: string;
  116143. shader: string;
  116144. };
  116145. }
  116146. // Mixins
  116147. interface Window {
  116148. mozIndexedDB: IDBFactory;
  116149. webkitIndexedDB: IDBFactory;
  116150. msIndexedDB: IDBFactory;
  116151. webkitURL: typeof URL;
  116152. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  116153. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  116154. WebGLRenderingContext: WebGLRenderingContext;
  116155. MSGesture: MSGesture;
  116156. CANNON: any;
  116157. AudioContext: AudioContext;
  116158. webkitAudioContext: AudioContext;
  116159. PointerEvent: any;
  116160. Math: Math;
  116161. Uint8Array: Uint8ArrayConstructor;
  116162. Float32Array: Float32ArrayConstructor;
  116163. mozURL: typeof URL;
  116164. msURL: typeof URL;
  116165. VRFrameData: any; // WebVR, from specs 1.1
  116166. DracoDecoderModule: any;
  116167. setImmediate(handler: (...args: any[]) => void): number;
  116168. }
  116169. interface HTMLCanvasElement {
  116170. requestPointerLock(): void;
  116171. msRequestPointerLock?(): void;
  116172. mozRequestPointerLock?(): void;
  116173. webkitRequestPointerLock?(): void;
  116174. /** Track wether a record is in progress */
  116175. isRecording: boolean;
  116176. /** Capture Stream method defined by some browsers */
  116177. captureStream(fps?: number): MediaStream;
  116178. }
  116179. interface CanvasRenderingContext2D {
  116180. msImageSmoothingEnabled: boolean;
  116181. }
  116182. interface MouseEvent {
  116183. mozMovementX: number;
  116184. mozMovementY: number;
  116185. webkitMovementX: number;
  116186. webkitMovementY: number;
  116187. msMovementX: number;
  116188. msMovementY: number;
  116189. }
  116190. interface Navigator {
  116191. mozGetVRDevices: (any: any) => any;
  116192. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116193. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116194. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116195. webkitGetGamepads(): Gamepad[];
  116196. msGetGamepads(): Gamepad[];
  116197. webkitGamepads(): Gamepad[];
  116198. }
  116199. interface HTMLVideoElement {
  116200. mozSrcObject: any;
  116201. }
  116202. interface Math {
  116203. fround(x: number): number;
  116204. imul(a: number, b: number): number;
  116205. }
  116206. interface WebGLRenderingContext {
  116207. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  116208. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  116209. vertexAttribDivisor(index: number, divisor: number): void;
  116210. createVertexArray(): any;
  116211. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  116212. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  116213. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  116214. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  116215. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  116216. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  116217. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  116218. // Queries
  116219. createQuery(): WebGLQuery;
  116220. deleteQuery(query: WebGLQuery): void;
  116221. beginQuery(target: number, query: WebGLQuery): void;
  116222. endQuery(target: number): void;
  116223. getQueryParameter(query: WebGLQuery, pname: number): any;
  116224. getQuery(target: number, pname: number): any;
  116225. MAX_SAMPLES: number;
  116226. RGBA8: number;
  116227. READ_FRAMEBUFFER: number;
  116228. DRAW_FRAMEBUFFER: number;
  116229. UNIFORM_BUFFER: number;
  116230. HALF_FLOAT_OES: number;
  116231. RGBA16F: number;
  116232. RGBA32F: number;
  116233. R32F: number;
  116234. RG32F: number;
  116235. RGB32F: number;
  116236. R16F: number;
  116237. RG16F: number;
  116238. RGB16F: number;
  116239. RED: number;
  116240. RG: number;
  116241. R8: number;
  116242. RG8: number;
  116243. UNSIGNED_INT_24_8: number;
  116244. DEPTH24_STENCIL8: number;
  116245. /* Multiple Render Targets */
  116246. drawBuffers(buffers: number[]): void;
  116247. readBuffer(src: number): void;
  116248. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  116249. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  116250. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  116251. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  116252. // Occlusion Query
  116253. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  116254. ANY_SAMPLES_PASSED: number;
  116255. QUERY_RESULT_AVAILABLE: number;
  116256. QUERY_RESULT: number;
  116257. }
  116258. interface WebGLProgram {
  116259. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  116260. }
  116261. interface EXT_disjoint_timer_query {
  116262. QUERY_COUNTER_BITS_EXT: number;
  116263. TIME_ELAPSED_EXT: number;
  116264. TIMESTAMP_EXT: number;
  116265. GPU_DISJOINT_EXT: number;
  116266. QUERY_RESULT_EXT: number;
  116267. QUERY_RESULT_AVAILABLE_EXT: number;
  116268. queryCounterEXT(query: WebGLQuery, target: number): void;
  116269. createQueryEXT(): WebGLQuery;
  116270. beginQueryEXT(target: number, query: WebGLQuery): void;
  116271. endQueryEXT(target: number): void;
  116272. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  116273. deleteQueryEXT(query: WebGLQuery): void;
  116274. }
  116275. interface WebGLUniformLocation {
  116276. _currentState: any;
  116277. }
  116278. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  116279. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  116280. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  116281. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116282. interface WebGLRenderingContext {
  116283. readonly RASTERIZER_DISCARD: number;
  116284. readonly DEPTH_COMPONENT24: number;
  116285. readonly TEXTURE_3D: number;
  116286. readonly TEXTURE_2D_ARRAY: number;
  116287. readonly TEXTURE_COMPARE_FUNC: number;
  116288. readonly TEXTURE_COMPARE_MODE: number;
  116289. readonly COMPARE_REF_TO_TEXTURE: number;
  116290. readonly TEXTURE_WRAP_R: number;
  116291. readonly HALF_FLOAT: number;
  116292. readonly RGB8: number;
  116293. readonly RED_INTEGER: number;
  116294. readonly RG_INTEGER: number;
  116295. readonly RGB_INTEGER: number;
  116296. readonly RGBA_INTEGER: number;
  116297. readonly R8_SNORM: number;
  116298. readonly RG8_SNORM: number;
  116299. readonly RGB8_SNORM: number;
  116300. readonly RGBA8_SNORM: number;
  116301. readonly R8I: number;
  116302. readonly RG8I: number;
  116303. readonly RGB8I: number;
  116304. readonly RGBA8I: number;
  116305. readonly R8UI: number;
  116306. readonly RG8UI: number;
  116307. readonly RGB8UI: number;
  116308. readonly RGBA8UI: number;
  116309. readonly R16I: number;
  116310. readonly RG16I: number;
  116311. readonly RGB16I: number;
  116312. readonly RGBA16I: number;
  116313. readonly R16UI: number;
  116314. readonly RG16UI: number;
  116315. readonly RGB16UI: number;
  116316. readonly RGBA16UI: number;
  116317. readonly R32I: number;
  116318. readonly RG32I: number;
  116319. readonly RGB32I: number;
  116320. readonly RGBA32I: number;
  116321. readonly R32UI: number;
  116322. readonly RG32UI: number;
  116323. readonly RGB32UI: number;
  116324. readonly RGBA32UI: number;
  116325. readonly RGB10_A2UI: number;
  116326. readonly R11F_G11F_B10F: number;
  116327. readonly RGB9_E5: number;
  116328. readonly RGB10_A2: number;
  116329. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  116330. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  116331. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  116332. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  116333. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  116334. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  116335. 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;
  116336. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  116337. readonly TRANSFORM_FEEDBACK: number;
  116338. readonly INTERLEAVED_ATTRIBS: number;
  116339. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  116340. createTransformFeedback(): WebGLTransformFeedback;
  116341. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  116342. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  116343. beginTransformFeedback(primitiveMode: number): void;
  116344. endTransformFeedback(): void;
  116345. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  116346. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116347. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116348. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116349. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  116350. }
  116351. interface ImageBitmap {
  116352. readonly width: number;
  116353. readonly height: number;
  116354. close(): void;
  116355. }
  116356. interface WebGLQuery extends WebGLObject {
  116357. }
  116358. declare var WebGLQuery: {
  116359. prototype: WebGLQuery;
  116360. new(): WebGLQuery;
  116361. };
  116362. interface WebGLSampler extends WebGLObject {
  116363. }
  116364. declare var WebGLSampler: {
  116365. prototype: WebGLSampler;
  116366. new(): WebGLSampler;
  116367. };
  116368. interface WebGLSync extends WebGLObject {
  116369. }
  116370. declare var WebGLSync: {
  116371. prototype: WebGLSync;
  116372. new(): WebGLSync;
  116373. };
  116374. interface WebGLTransformFeedback extends WebGLObject {
  116375. }
  116376. declare var WebGLTransformFeedback: {
  116377. prototype: WebGLTransformFeedback;
  116378. new(): WebGLTransformFeedback;
  116379. };
  116380. interface WebGLVertexArrayObject extends WebGLObject {
  116381. }
  116382. declare var WebGLVertexArrayObject: {
  116383. prototype: WebGLVertexArrayObject;
  116384. new(): WebGLVertexArrayObject;
  116385. };
  116386. // Type definitions for WebVR API
  116387. // Project: https://w3c.github.io/webvr/
  116388. // Definitions by: six a <https://github.com/lostfictions>
  116389. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116390. interface VRDisplay extends EventTarget {
  116391. /**
  116392. * Dictionary of capabilities describing the VRDisplay.
  116393. */
  116394. readonly capabilities: VRDisplayCapabilities;
  116395. /**
  116396. * z-depth defining the far plane of the eye view frustum
  116397. * enables mapping of values in the render target depth
  116398. * attachment to scene coordinates. Initially set to 10000.0.
  116399. */
  116400. depthFar: number;
  116401. /**
  116402. * z-depth defining the near plane of the eye view frustum
  116403. * enables mapping of values in the render target depth
  116404. * attachment to scene coordinates. Initially set to 0.01.
  116405. */
  116406. depthNear: number;
  116407. /**
  116408. * An identifier for this distinct VRDisplay. Used as an
  116409. * association point in the Gamepad API.
  116410. */
  116411. readonly displayId: number;
  116412. /**
  116413. * A display name, a user-readable name identifying it.
  116414. */
  116415. readonly displayName: string;
  116416. readonly isConnected: boolean;
  116417. readonly isPresenting: boolean;
  116418. /**
  116419. * If this VRDisplay supports room-scale experiences, the optional
  116420. * stage attribute contains details on the room-scale parameters.
  116421. */
  116422. readonly stageParameters: VRStageParameters | null;
  116423. /**
  116424. * Passing the value returned by `requestAnimationFrame` to
  116425. * `cancelAnimationFrame` will unregister the callback.
  116426. * @param handle Define the hanle of the request to cancel
  116427. */
  116428. cancelAnimationFrame(handle: number): void;
  116429. /**
  116430. * Stops presenting to the VRDisplay.
  116431. * @returns a promise to know when it stopped
  116432. */
  116433. exitPresent(): Promise<void>;
  116434. /**
  116435. * Return the current VREyeParameters for the given eye.
  116436. * @param whichEye Define the eye we want the parameter for
  116437. * @returns the eye parameters
  116438. */
  116439. getEyeParameters(whichEye: string): VREyeParameters;
  116440. /**
  116441. * Populates the passed VRFrameData with the information required to render
  116442. * the current frame.
  116443. * @param frameData Define the data structure to populate
  116444. * @returns true if ok otherwise false
  116445. */
  116446. getFrameData(frameData: VRFrameData): boolean;
  116447. /**
  116448. * Get the layers currently being presented.
  116449. * @returns the list of VR layers
  116450. */
  116451. getLayers(): VRLayer[];
  116452. /**
  116453. * Return a VRPose containing the future predicted pose of the VRDisplay
  116454. * when the current frame will be presented. The value returned will not
  116455. * change until JavaScript has returned control to the browser.
  116456. *
  116457. * The VRPose will contain the position, orientation, velocity,
  116458. * and acceleration of each of these properties.
  116459. * @returns the pose object
  116460. */
  116461. getPose(): VRPose;
  116462. /**
  116463. * Return the current instantaneous pose of the VRDisplay, with no
  116464. * prediction applied.
  116465. * @returns the current instantaneous pose
  116466. */
  116467. getImmediatePose(): VRPose;
  116468. /**
  116469. * The callback passed to `requestAnimationFrame` will be called
  116470. * any time a new frame should be rendered. When the VRDisplay is
  116471. * presenting the callback will be called at the native refresh
  116472. * rate of the HMD. When not presenting this function acts
  116473. * identically to how window.requestAnimationFrame acts. Content should
  116474. * make no assumptions of frame rate or vsync behavior as the HMD runs
  116475. * asynchronously from other displays and at differing refresh rates.
  116476. * @param callback Define the eaction to run next frame
  116477. * @returns the request handle it
  116478. */
  116479. requestAnimationFrame(callback: FrameRequestCallback): number;
  116480. /**
  116481. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  116482. * Repeat calls while already presenting will update the VRLayers being displayed.
  116483. * @param layers Define the list of layer to present
  116484. * @returns a promise to know when the request has been fulfilled
  116485. */
  116486. requestPresent(layers: VRLayer[]): Promise<void>;
  116487. /**
  116488. * Reset the pose for this display, treating its current position and
  116489. * orientation as the "origin/zero" values. VRPose.position,
  116490. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  116491. * updated when calling resetPose(). This should be called in only
  116492. * sitting-space experiences.
  116493. */
  116494. resetPose(): void;
  116495. /**
  116496. * The VRLayer provided to the VRDisplay will be captured and presented
  116497. * in the HMD. Calling this function has the same effect on the source
  116498. * canvas as any other operation that uses its source image, and canvases
  116499. * created without preserveDrawingBuffer set to true will be cleared.
  116500. * @param pose Define the pose to submit
  116501. */
  116502. submitFrame(pose?: VRPose): void;
  116503. }
  116504. declare var VRDisplay: {
  116505. prototype: VRDisplay;
  116506. new(): VRDisplay;
  116507. };
  116508. interface VRLayer {
  116509. leftBounds?: number[] | Float32Array | null;
  116510. rightBounds?: number[] | Float32Array | null;
  116511. source?: HTMLCanvasElement | null;
  116512. }
  116513. interface VRDisplayCapabilities {
  116514. readonly canPresent: boolean;
  116515. readonly hasExternalDisplay: boolean;
  116516. readonly hasOrientation: boolean;
  116517. readonly hasPosition: boolean;
  116518. readonly maxLayers: number;
  116519. }
  116520. interface VREyeParameters {
  116521. /** @deprecated */
  116522. readonly fieldOfView: VRFieldOfView;
  116523. readonly offset: Float32Array;
  116524. readonly renderHeight: number;
  116525. readonly renderWidth: number;
  116526. }
  116527. interface VRFieldOfView {
  116528. readonly downDegrees: number;
  116529. readonly leftDegrees: number;
  116530. readonly rightDegrees: number;
  116531. readonly upDegrees: number;
  116532. }
  116533. interface VRFrameData {
  116534. readonly leftProjectionMatrix: Float32Array;
  116535. readonly leftViewMatrix: Float32Array;
  116536. readonly pose: VRPose;
  116537. readonly rightProjectionMatrix: Float32Array;
  116538. readonly rightViewMatrix: Float32Array;
  116539. readonly timestamp: number;
  116540. }
  116541. interface VRPose {
  116542. readonly angularAcceleration: Float32Array | null;
  116543. readonly angularVelocity: Float32Array | null;
  116544. readonly linearAcceleration: Float32Array | null;
  116545. readonly linearVelocity: Float32Array | null;
  116546. readonly orientation: Float32Array | null;
  116547. readonly position: Float32Array | null;
  116548. readonly timestamp: number;
  116549. }
  116550. interface VRStageParameters {
  116551. sittingToStandingTransform?: Float32Array;
  116552. sizeX?: number;
  116553. sizeY?: number;
  116554. }
  116555. interface Navigator {
  116556. getVRDisplays(): Promise<VRDisplay[]>;
  116557. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  116558. }
  116559. interface Window {
  116560. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  116561. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  116562. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  116563. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116564. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116565. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  116566. }
  116567. interface Gamepad {
  116568. readonly displayId: number;
  116569. }
  116570. interface XRDevice {
  116571. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  116572. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  116573. }
  116574. interface XRSession {
  116575. getInputSources(): Array<any>;
  116576. baseLayer: XRWebGLLayer;
  116577. requestFrameOfReference(type: string): Promise<void>;
  116578. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  116579. end(): Promise<void>;
  116580. requestAnimationFrame: Function;
  116581. addEventListener: Function;
  116582. }
  116583. interface XRSessionCreationOptions {
  116584. outputContext?: WebGLRenderingContext | null;
  116585. immersive?: boolean;
  116586. environmentIntegration?: boolean;
  116587. }
  116588. interface XRLayer {
  116589. getViewport: Function;
  116590. framebufferWidth: number;
  116591. framebufferHeight: number;
  116592. }
  116593. interface XRView {
  116594. projectionMatrix: Float32Array;
  116595. }
  116596. interface XRFrame {
  116597. getDevicePose: Function;
  116598. getInputPose: Function;
  116599. views: Array<XRView>;
  116600. baseLayer: XRLayer;
  116601. }
  116602. interface XRFrameOfReference {
  116603. }
  116604. interface XRWebGLLayer extends XRLayer {
  116605. framebuffer: WebGLFramebuffer;
  116606. }
  116607. declare var XRWebGLLayer: {
  116608. prototype: XRWebGLLayer;
  116609. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  116610. };